cmake fixes:

- Builds up ENGINE_LIBRARY_LISTING correctly to pass to pkg-config
    - Previous behavior had major flaw and would result in paths in libosrm.pc like: "-L-L"
      when the data was "-L/path -lfoo" or just "-lpthread" with no -L/path. It only worked correctly for static libraries
  - Refactors to call find_package for boost in one place (helps prepare for upcoming mason PR)
This commit is contained in:
Dane Springmeyer
2016-10-20 09:59:37 -07:00
parent 865c6590fa
commit 502d9e10c2
2 changed files with 34 additions and 48 deletions
+5 -16
View File
@@ -44,31 +44,20 @@ add_executable(util-tests
$<TARGET_OBJECTS:UTIL>)
# FindPackage below overwrites Boost_LIBRARIES
set(AllBoostLibrariesExceptUnitTest ${Boost_LIBRARIES})
find_package(Boost 1.49.0 REQUIRED COMPONENTS unit_test_framework)
if(NOT WIN32 AND NOT Boost_USE_STATIC_LIBS)
add_definitions(-DBOOST_TEST_DYN_LINK)
endif()
# After the find_package call we got only the unit test library
set(BoostUnitTestLibrary ${Boost_LIBRARIES})
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
target_include_directories(engine-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(library-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(util-tests PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(engine-tests ${ENGINE_LIBRARIES} ${BoostUnitTestLibrary})
target_link_libraries(extractor-tests ${EXTRACTOR_LIBRARIES} ${BoostUnitTestLibrary})
target_link_libraries(library-tests osrm ${Boost_LIBRARIES} ${BoostUnitTestLibrary})
target_link_libraries(server-tests osrm ${Boost_LIBRARIES} ${BoostUnitTestLibrary})
target_link_libraries(util-tests ${UTIL_LIBRARIES} ${BoostUnitTestLibrary})
target_link_libraries(engine-tests ${ENGINE_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
target_link_libraries(extractor-tests ${EXTRACTOR_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
target_link_libraries(library-tests osrm ${Boost_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
target_link_libraries(server-tests osrm ${Boost_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
target_link_libraries(util-tests ${UTIL_LIBRARIES} ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
add_custom_target(tests