cmake find_packageにboostがインストールされていないことがわかったらboost.cxxを追加しません。 find_packageは、boost.cxxをコンパイルするかどうかを条件としてラップできるものを返しますか?ここに私の現在のcmakeファイルがあります。find_packageがパッケージを見つけたかどうかを確認する方法(boost)
add_executable (complex complex.cxx lexer.cxx boost.cxx ../../src/lili.cxx ../../src/lilu.cxx)
# Make sure the compiler can find all include files
include_directories (../../src)
include_directories (.)
# Make sure the linker can find all needed libraries
# rt: clock_gettime()
target_link_libraries(complex rt)
# Install example application
install (TARGETS complex
RUNTIME DESTINATION bin)
IF(UNIX)
find_package(Boost COMPONENTS system filesystem REQUIRED)
## Compiler flags
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-O2")
set(CMAKE_EXE_LINKER_FLAGS "-lsqlite3 -lrt -lpthread")
endif()
target_link_libraries(complex
${Boost_FILESYSTEM_LIBRARY}
${Boost_SYSTEM_LIBRARY}
#${PROTOBUF_LIBRARY}
)
ENDIF(UNIX)
恐ろしい!あなたはこのすべての仕事を私のために作った、ありがとう! – Cynede
注意 - Libname_FOUND変数は大文字と小文字を区別し、一部のライブラリでは大文字と小文字を区別します。例えば。 find_package(GTest)が成功しても、GTest_FOUNDは設定されません。代わりにGTEST_FOUNDが設定されます(cmake 3.0.2を使用)。 –