Better Boost detection in CMAKE

master
Nicholas Brown 2019-12-18 17:58:18 +00:00 committed by Lothar Braun
parent d4c84e1576
commit e59a8a8e71
3 changed files with 17 additions and 39 deletions

View File

@ -234,46 +234,24 @@ ENDIF (HIREDIS_FOUND)
### boost ### boost
FIND_PACKAGE(Boost REQUIRED) FIND_PACKAGE(Boost REQUIRED COMPONENTS
MARK_AS_ADVANCED( regex
Boost_INCLUDE_DIR thread
Boost_REGEX_LIBRARY filesystem
Boost_THREAD_LIBRARY unit_test_framework
Boost_FILESYSTEM_LIBRARY system)
Boost_UNIT_TEST_FRAMEWORK_LIBRARY
)
IF (Boost_FOUND) IF (Boost_FOUND)
MESSAGE(STATUS "Found boost libraries") MESSAGE(STATUS "Found boost libraries")
ADD_DEFINITIONS(-DHAVE_BOOST_FILESYSTEM) ADD_DEFINITIONS(-DHAVE_BOOST_FILESYSTEM)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS}) INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
FIND_LIBRARY(Boost_REGEX_LIBRARY NAMES boost_regex-mt boost_regex PATHS ${Boost_LIBRARY_DIRS})
IF (NOT Boost_REGEX_LIBRARY)
MESSAGE(FATAL_ERROR "Could not find boost regex library")
ENDIF(NOT Boost_REGEX_LIBRARY)
FIND_LIBRARY(Boost_THREAD_LIBRARY NAMES boost_thread-mt boost_thread PATHS ${Boost_LIBRARY_DIRS})
IF (NOT Boost_THREAD_LIBRARY)
MESSAGE(FATAL_ERROR "Could not find boost thread library")
ENDIF(NOT Boost_THREAD_LIBRARY)
FIND_LIBRARY(Boost_FILESYSTEM_LIBRARY NAMES boost_filesystem-mt boost_filesystem PATHS ${Boost_LIBRARY_DIRS})
IF (NOT Boost_FILESYSTEM_LIBRARY)
MESSAGE(FATAL_ERROR "Could not find boost filesystem library")
ENDIF(NOT Boost_FILESYSTEM_LIBRARY)
FIND_LIBRARY(Boost_UNIT_TEST_FRAMEWORK_LIBRARY NAMES boost_unit_test_framework-mt boost_unit_test_framework PATHS ${Boost_LIBRARY_DIRS})
IF (NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY)
MESSAGE(FATAL_ERROR "Could not find boost unit test framework")
ENDIF (NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY)
FIND_LIBRARY(Boost_SYSTEM_LIBRARY NAMES boost_system-mt boost_system PATHS ${Boost_LIBRARY_DIRS})
IF (NOT Boost_SYSTEM_LIBRARY)
MESSAGE(FATAL_ERROR "Could not find boost system library")
ENDIF (NOT Boost_SYSTEM_LIBRARY)
TARGET_LINK_LIBRARIES(vermont TARGET_LINK_LIBRARIES(vermont
${Boost_REGEX_LIBRARY} Boost::regex
${Boost_FILESYSTEM_LIBRARY} Boost::filesystem
${Boost_SYSTEM_LIBRARY} Boost::system
) )
IF (SUPPORT_MONGO) IF (SUPPORT_MONGO)
TARGET_LINK_LIBRARIES(vermont TARGET_LINK_LIBRARIES(vermont Boost::thread
${Boost_THREAD_LIBRARY}
) )
ENDIF (SUPPORT_MONGO) ENDIF (SUPPORT_MONGO)

View File

@ -36,9 +36,9 @@ TARGET_LINK_LIBRARIES(vermonttest
common common
osdep osdep
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${Boost_REGEX_LIBRARY} Boost::regex
${Boost_FILESYSTEM_LIBRARY} Boost::filesystem
${Boost_SYSTEM_LIBRARY} Boost::system
${PCAP_LIBRARY} ${PCAP_LIBRARY}
${LIBXML2_LIBRARIES} ${LIBXML2_LIBRARIES}
) )

View File

@ -27,9 +27,9 @@ TARGET_LINK_LIBRARIES(testCollector
ipfixlolib ipfixlolib
common common
osdep osdep
${Boost_REGEX_LIBRARY} Boost::regex
${Boost_FILESYSTEM_LIBRARY} Boost::filesystem
${Boost_SYSTEM_LIBRARY} Boost::system
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${PCAP_LIBRARY} ${PCAP_LIBRARY}
) )