blaze-config.cmake does not expose the location of the header files

Issue #139 closed
Parsa Amini created an issue

The instructions on the wiki page do not clarify how to locate Blaze header files and include the appropriate directory.

Minimal code to reproduce the issue:

#!/bin/bash
_RDIR_=$PWD
mkdir blaze
pushd blaze
git clone --depth=1 https://bitbucket.org/blaze-lib/blaze.git repo
mkdir -p {build,install}
pushd build
cmake -DCMAKE_INSTALL_PREFIX=$_RDIR_/install -DBLAZE_SMP_THREADS=Boost ../blaze
make -j
make -j install
popd
popd
mkdir -p project/{repo,build}
pushd project
cat >repo/blzapp1.cpp <<'EOF'
#include <iostream>
#include <blaze/Math.h>

int main(int argc, const char *argv[])
{
    blaze::DynamicMatrix<double> a {{1.0, 2.0}, {3.0, 4.0}};
    std::cout << "a =" << std::endl << a << std::endl;

    double d = blaze::det(a);
    std::cout << "det(a) = " << d << std::endl;

    return 0;
}
EOF
cat >repo/CMakeLists.txt <<'EOF'
cmake_minimum_required (VERSION 3.6)

project (blzapp1)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(BLAS REQUIRED)
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
  message(STATUS "${_variableName}=${${_variableName}}")
endforeach()

find_package(blaze)
if(NOT blaze_FOUND)
    message(FATAL_ERROR "Blaze NOT found.")
endif()

add_library(blaze_target INTERFACE)
target_link_libraries(blaze_target INTERFACE blaze::blaze)

#get_filename_component(blaze_INCLUDE_DIR ${blaze_CONFIG} DIRECTORY)
#list(APPEND CMAKE_REQUIRED_INCLUDES ${blaze_INCLUDE_DIR})
#
#set(CMAKE_REQUIRED_FLAGS "-std=c++14")
#
#include(CheckIncludeFileCXX)
#check_include_file_cxx("blaze/Math.h" HAVE_BLAZE_MATH_H)
#
#if(NOT HAVE_BLAZE_MATH_H)
#    message(FATAL_ERROR "Blaze could not be found. Please set blaze_DIR to help locating it.")
#endif()

add_executable (blzapp1 blzapp1.cpp)
target_link_libraries(blzapp1 blas ${BLAS_LIBRARIES})
EOF
pushd build/
cmake -DBLAZE_DIR=$_RDIR_/blaze/install/cmake ../repo
make

Script output is attached.

Comments (3)

  1. Parsa Amini reporter

    The problem is be solved by adding blaze_target declared in the script to the target_link_libraries statement that links the application.

  2. Log in to comment