我尝试使用CheckIncludeFileCXX
模块验证系统中是否存在<gsl/gsl>
。 /usr/local/include/gsl/gsl
存在GSL,但"GSL not found"
project(cpp-binaries)
cmake_minimum_required(VERSION 3.2)
include(CheckIncludeFileCXX)
CHECK_INCLUDE_FILE_CXX("gsl/gsl" GSL_LIBRARY)
if(NOT GSL_LIBRARY)
message(FATAL_ERROR "GSL not found")
endif(NOT GSL_LIBRARY)
add_executable(
cpp-binaries
"main.cpp"
)
答案 0 :(得分:0)
好的,我更多地关注CheckIncludeFileCXX
,您基本上必须使用CMAKE_REQUIRED_INCLUDES
指定内容,否则它不知道在哪里搜索。为了给它一些东西,它会静静地搜索包含find_path
的内容,但如果找不到任何内容,则仍然会出错。
project(gsl_t)
cmake_minimum_required(VERSION 3.2)
find_path(
gsl_location
gsl
HINTS ENV GSLDIR
)
if(gsl_location)
get_filename_component(gsl_include_dir ${gsl_location} DIRECTORY)
list(APPEND CMAKE_INCLUDE_PATH ${gsl_include_dir})
endif(gsl_location)
include(CheckIncludeFileCXX)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH})
CHECK_INCLUDE_FILE_CXX("gsl/gsl" gsl_found)
if(NOT gsl_found)
message(FATAL_ERROR "GSL not found. \
Try setting the GSLDIR environment variable")
endif(NOT gsl_found)
add_executable(
gsl_t
"main.cpp"
)