No quiero agregar boost.cxx si cmake find_package no encontró ningún boost instalado. Does find_package devuelve algo que puedo envolver para compilar boost.cxx o no. Aquí está mi actual archivo cmake:Cómo comprobar si find_package encontró el paquete (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)
¡Impresionante! Hiciste todo esto para mí, ¡gracias! – Cynede
Tenga cuidado: la variable Libname_FOUND es sensible a mayúsculas y minúsculas para algunas bibliotecas. P.ej. GTest_FOUND no se establecerá aunque find_package (GTest) sea exitoso. En cambio, se establece GTEST_FOUND (usando cmake 3.0.2). –