diff --git a/CMakeLists.txt b/CMakeLists.txt index 2846e9f94..3074f13cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,8 +107,10 @@ endif() ############################################################################### # Find boost -if(CYGWIN OR MSVC OR WIN32) - set(Boost_USE_STATIC_LIBS 1) # Use static libs on Windows + +# If using Boost shared libs, set up auto linking for shared libs +if(NOT Boost_USE_STATIC_LIBS) + add_definitions(-DBOOST_ALL_DYN_LINK) endif() find_package(Boost 1.43 COMPONENTS serialization system filesystem thread date_time regex timer chrono) @@ -122,7 +124,7 @@ endif() # Allow for not using the timer libraries on boost < 1.48 (GTSAM timing code falls back to old timer library) set(GTSAM_BOOST_LIBRARIES ${Boost_SERIALIZATION_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY}) if(Boost_TIMER_LIBRARY) - set(GTSAM_BOOST_LIBRARIES ${GTSAM_BOOST_LIBRARIES} ${Boost_TIMER_LIBRARY} ${Boost_CHRONO_LIBRARY}) + list(APPEND GTSAM_BOOST_LIBRARIES ${GTSAM_BOOST_LIBRARIES} ${Boost_TIMER_LIBRARY} ${Boost_CHRONO_LIBRARY}) else() message("WARNING: Boost older than 1.48 was found, GTSAM timing instrumentation will use the older, less accurate, Boost timer library.") endif() diff --git a/gtsam_unstable/CMakeLists.txt b/gtsam_unstable/CMakeLists.txt index 4016caa39..400a77e84 100644 --- a/gtsam_unstable/CMakeLists.txt +++ b/gtsam_unstable/CMakeLists.txt @@ -10,6 +10,8 @@ set (gtsam_unstable_subdirs slam ) +set(GTSAM_UNSTABLE_BOOST_LIBRARIES ${GTSAM_BOOST_LIBRARIES} ${Boost_THREAD_LIBRARY}) + add_custom_target(check.unstable COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure) # assemble core libaries @@ -58,7 +60,7 @@ set_target_properties(gtsam_unstable-static PROPERTIES CLEAN_DIRECT_OUTPUT 1 VERSION ${gtsam_unstable_version} SOVERSION ${gtsam_unstable_soversion}) -target_link_libraries(gtsam_unstable-static gtsam-static) +target_link_libraries(gtsam_unstable-static gtsam-static ${GTSAM_UNSTABLE_BOOST_LIBRARIES}) set(gtsam_unstable-lib "gtsam_unstable-static") install(TARGETS gtsam_unstable-static EXPORT GTSAM-exports ARCHIVE DESTINATION lib) list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable-static) @@ -72,7 +74,7 @@ if (GTSAM_UNSTABLE_BUILD_SHARED_LIBRARY) CLEAN_DIRECT_OUTPUT 1 VERSION ${gtsam_unstable_version} SOVERSION ${gtsam_unstable_soversion}) - target_link_libraries(gtsam_unstable-shared gtsam-shared) + target_link_libraries(gtsam_unstable-shared gtsam-shared ${GTSAM_UNSTABLE_BOOST_LIBRARIES}) install(TARGETS gtsam_unstable-shared EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable-shared) set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) diff --git a/wrap/CMakeLists.txt b/wrap/CMakeLists.txt index 14d9a1f84..7226d8006 100644 --- a/wrap/CMakeLists.txt +++ b/wrap/CMakeLists.txt @@ -7,6 +7,7 @@ file(GLOB wrap_srcs "*.cpp") file(GLOB wrap_headers "*.h") list(REMOVE_ITEM wrap_srcs ${CMAKE_CURRENT_SOURCE_DIR}/wrap.cpp) add_library(wrap_lib STATIC ${wrap_srcs} ${wrap_headers}) +target_link_libraries(wrap_lib ${WRAP_BOOST_LIBRARIES}) gtsam_assign_source_folders(${wrap_srcs} ${wrap_headers}) add_executable(wrap wrap.cpp) target_link_libraries(wrap wrap_lib ${WRAP_BOOST_LIBRARIES})