Improved build of shared vs static GTSAM libraries - now possible to build either one or both, executables link to the shared if it is being build, or otherwise to the static. Also removed separate shared/static CMake flags for gtsam_unstable, now uses the same GTSAM_BUILD_SHARED and GTSAM_BUILD_STATIC as gtsam.

release/4.3a0
Richard Roberts 2013-03-13 18:17:39 +00:00
parent 3ddb6e6f5c
commit 6111c099ab
19 changed files with 64 additions and 58 deletions

View File

@ -53,13 +53,13 @@ if(GTSAM_UNSTABLE_AVAILABLE)
endif() endif()
if(NOT MSVC) if(NOT MSVC)
option(GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" ON) option(GTSAM_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam" ON)
option(GTSAM_BUILD_STATIC_LIBRARY "Enable/Disable building of a static version of gtsam" ON) option(GTSAM_BUILD_STATIC_LIBRARY "Enable/Disable building of a static version of gtsam" OFF)
else() else()
set(GTSAM_BUILD_STATIC_LIBRARY ON) set(GTSAM_BUILD_STATIC_LIBRARY ON)
endif() endif()
option(GTSAM_USE_QUATERNIONS "Enable/Disable using an internal Quaternion representation for rotations instead of rotation matrices" OFF) option(GTSAM_USE_QUATERNIONS "Enable/Disable using an internal Quaternion representation for rotations instead of rotation matrices" OFF)
if(NOT MSVC) if(NOT MSVC)
option(GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable use of convenience libraries for faster development rebuilds, but slower install" ON) option(GTSAM_BUILD_CONVENIENCE_LIBRARIES "Enable/Disable use of convenience libraries for faster development rebuilds, but slower install" OFF)
endif() endif()
@ -153,6 +153,19 @@ link_directories(${Boost_LIBRARY_DIRS})
############################################################################### ###############################################################################
# Add components # Add components
# Set default library - static or shared, before adding subdirectories
if(GTSAM_BUILD_SHARED_LIBRARY)
set(gtsam-default gtsam-shared)
if(GTSAM_BUILD_UNSTABLE)
set(gtsam_unstable-default gtsam_unstable-shared)
endif()
else()
set(gtsam-default gtsam-static)
if(GTSAM_BUILD_UNSTABLE)
set(gtsam_unstable-default gtsam_unstable-static)
endif()
endif()
# Build CppUnitLite # Build CppUnitLite
add_subdirectory(CppUnitLite) add_subdirectory(CppUnitLite)

View File

@ -94,8 +94,7 @@ if (GTSAM_BUILD_STATIC_LIBRARY)
install(TARGETS gtsam-static EXPORT GTSAM-exports ARCHIVE DESTINATION lib) install(TARGETS gtsam-static EXPORT GTSAM-exports ARCHIVE DESTINATION lib)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam-static) list(APPEND GTSAM_EXPORTED_TARGETS gtsam-static)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
set(gtsam-lib gtsam-static) endif ()
endif (GTSAM_BUILD_STATIC_LIBRARY)
if (GTSAM_BUILD_SHARED_LIBRARY) if (GTSAM_BUILD_SHARED_LIBRARY)
message(STATUS "Building GTSAM - shared") message(STATUS "Building GTSAM - shared")
@ -109,9 +108,6 @@ if (GTSAM_BUILD_SHARED_LIBRARY)
install(TARGETS gtsam-shared EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) install(TARGETS gtsam-shared EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam-shared) list(APPEND GTSAM_EXPORTED_TARGETS gtsam-shared)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
if (NOT GTSAM_BUILD_STATIC_LIBRARY)
set(gtsam-lib "gtsam-shared")
endif()
endif(GTSAM_BUILD_SHARED_LIBRARY) endif(GTSAM_BUILD_SHARED_LIBRARY)
# Set dataset paths # Set dataset paths

View File

@ -15,11 +15,11 @@ set(base_excluded_files
# Build tests # Build tests
if (GTSAM_BUILD_TESTS) if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(base "${base_local_libs}" "gtsam-static" "${base_excluded_files}") gtsam_add_subdir_tests(base "${base_local_libs}" "${gtsam-default}" "${base_excluded_files}")
endif(GTSAM_BUILD_TESTS) endif(GTSAM_BUILD_TESTS)
# Build timing scripts # Build timing scripts
if (GTSAM_BUILD_TIMING) if (GTSAM_BUILD_TIMING)
gtsam_add_subdir_timing(base "${base_local_libs}" "gtsam-static" "${base_excluded_files}") gtsam_add_subdir_timing(base "${base_local_libs}" "${gtsam-default}" "${base_excluded_files}")
endif(GTSAM_BUILD_TIMING) endif(GTSAM_BUILD_TIMING)

View File

@ -17,7 +17,7 @@ set (discrete_excluded_tests "")
# Add all tests # Add all tests
if (GTSAM_BUILD_TESTS) if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(discrete "${discrete_local_libs}" "gtsam-static" "${discrete_excluded_tests}") gtsam_add_subdir_tests(discrete "${discrete_local_libs}" "${gtsam-default}" "${discrete_excluded_tests}")
endif() endif()
# Build timing scripts # Build timing scripts

View File

@ -16,11 +16,11 @@ set(geometry_excluded_files
# Build tests # Build tests
if (GTSAM_BUILD_TESTS) if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(geometry "${geometry_local_libs}" "gtsam-static" "${geometry_excluded_files}") gtsam_add_subdir_tests(geometry "${geometry_local_libs}" "${gtsam-default}" "${geometry_excluded_files}")
endif(GTSAM_BUILD_TESTS) endif(GTSAM_BUILD_TESTS)
# Build timing scripts # Build timing scripts
if (GTSAM_BUILD_TIMING) if (GTSAM_BUILD_TIMING)
gtsam_add_subdir_timing(geometry "${geometry_local_libs}" "gtsam-static" "${geometry_excluded_files}") gtsam_add_subdir_timing(geometry "${geometry_local_libs}" "${gtsam-default}" "${geometry_excluded_files}")
endif(GTSAM_BUILD_TIMING) endif(GTSAM_BUILD_TIMING)

View File

@ -18,11 +18,11 @@ set(inference_excluded_files
# Build tests # Build tests
if (GTSAM_BUILD_TESTS) if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(inference "${inference_local_libs}" "gtsam-static" "${inference_excluded_files}") gtsam_add_subdir_tests(inference "${inference_local_libs}" "${gtsam-default}" "${inference_excluded_files}")
endif(GTSAM_BUILD_TESTS) endif(GTSAM_BUILD_TESTS)
# Build timing scripts # Build timing scripts
if (GTSAM_BUILD_TIMING) if (GTSAM_BUILD_TIMING)
gtsam_add_subdir_timing(inference "${inference_local_libs}" "gtsam-static" "${inference_excluded_files}") gtsam_add_subdir_timing(inference "${inference_local_libs}" "${gtsam-default}" "${inference_excluded_files}")
endif(GTSAM_BUILD_TIMING) endif(GTSAM_BUILD_TIMING)

View File

@ -19,10 +19,10 @@ set(linear_excluded_files
# Build tests # Build tests
if (GTSAM_BUILD_TESTS) if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(linear "${linear_local_libs}" "gtsam-static" "${linear_excluded_files}") gtsam_add_subdir_tests(linear "${linear_local_libs}" "${gtsam-default}" "${linear_excluded_files}")
endif(GTSAM_BUILD_TESTS) endif(GTSAM_BUILD_TESTS)
# Build timing scripts # Build timing scripts
if (GTSAM_BUILD_TIMING) if (GTSAM_BUILD_TIMING)
gtsam_add_subdir_timing(linear "${linear_local_libs}" "gtsam-static" "${linear_excluded_files}") gtsam_add_subdir_timing(linear "${linear_local_libs}" "${gtsam-default}" "${linear_excluded_files}")
endif(GTSAM_BUILD_TIMING) endif(GTSAM_BUILD_TIMING)

View File

@ -20,11 +20,11 @@ set(nonlinear_excluded_files
# Build tests # Build tests
if (GTSAM_BUILD_TESTS) if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(nonlinear "${nonlinear_local_libs}" "gtsam-static" "${nonlinear_excluded_files}") gtsam_add_subdir_tests(nonlinear "${nonlinear_local_libs}" "${gtsam-default}" "${nonlinear_excluded_files}")
endif(GTSAM_BUILD_TESTS) endif(GTSAM_BUILD_TESTS)
# Build timing scripts # Build timing scripts
if (GTSAM_BUILD_TIMING) if (GTSAM_BUILD_TIMING)
gtsam_add_subdir_timing(nonlinear "${nonlinear_local_libs}" "gtsam-static" "${nonlinear_excluded_files}") gtsam_add_subdir_timing(nonlinear "${nonlinear_local_libs}" "${gtsam-default}" "${nonlinear_excluded_files}")
endif(GTSAM_BUILD_TIMING) endif(GTSAM_BUILD_TIMING)

View File

@ -21,10 +21,10 @@ set(slam_excluded_files
# Build tests # Build tests
if (GTSAM_BUILD_TESTS) if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(slam "${slam_local_libs}" "gtsam-static" "${slam_excluded_files}") gtsam_add_subdir_tests(slam "${slam_local_libs}" "${gtsam-default}" "${slam_excluded_files}")
endif(GTSAM_BUILD_TESTS) endif(GTSAM_BUILD_TESTS)
# Build timing scripts # Build timing scripts
if (GTSAM_BUILD_TIMING) if (GTSAM_BUILD_TIMING)
gtsam_add_subdir_timing(slam "${slam_local_libs}" "gtsam-static" "${slam_excluded_files}") gtsam_add_subdir_timing(slam "${slam_local_libs}" "${gtsam-default}" "${slam_excluded_files}")
endif(GTSAM_BUILD_TIMING) endif(GTSAM_BUILD_TIMING)

View File

@ -44,10 +44,6 @@ set(gtsam_unstable_srcs
${navigation_srcs} ${navigation_srcs}
) )
if(NOT MSVC)
option (GTSAM_UNSTABLE_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam_unstable" ON)
endif()
# Versions - same as core gtsam library # Versions - same as core gtsam library
set(gtsam_unstable_version ${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH}) set(gtsam_unstable_version ${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH})
set(gtsam_unstable_soversion ${GTSAM_VERSION_MAJOR}) set(gtsam_unstable_soversion ${GTSAM_VERSION_MAJOR})
@ -55,20 +51,21 @@ message(STATUS "GTSAM_UNSTABLE Version: ${gtsam_unstable_version}")
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
# build shared and static versions of the library # build shared and static versions of the library
message(STATUS "Building GTSAM_UNSTABLE - static") if (GTSAM_BUILD_STATIC_LIBRARY)
add_library(gtsam_unstable-static STATIC ${gtsam_unstable_srcs}) message(STATUS "Building GTSAM_UNSTABLE - static")
set_target_properties(gtsam_unstable-static PROPERTIES add_library(gtsam_unstable-static STATIC ${gtsam_unstable_srcs})
OUTPUT_NAME gtsam_unstable set_target_properties(gtsam_unstable-static PROPERTIES
CLEAN_DIRECT_OUTPUT 1 OUTPUT_NAME gtsam_unstable
VERSION ${gtsam_unstable_version} CLEAN_DIRECT_OUTPUT 1
SOVERSION ${gtsam_unstable_soversion}) VERSION ${gtsam_unstable_version}
target_link_libraries(gtsam_unstable-static gtsam-static ${GTSAM_UNSTABLE_BOOST_LIBRARIES}) SOVERSION ${gtsam_unstable_soversion})
set(gtsam_unstable-lib "gtsam_unstable-static") target_link_libraries(gtsam_unstable-static gtsam-static ${GTSAM_UNSTABLE_BOOST_LIBRARIES})
install(TARGETS gtsam_unstable-static EXPORT GTSAM-exports ARCHIVE DESTINATION lib) install(TARGETS gtsam_unstable-static EXPORT GTSAM-exports ARCHIVE DESTINATION lib)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable-static) list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable-static)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
endif()
if (GTSAM_UNSTABLE_BUILD_SHARED_LIBRARY) if (GTSAM_BUILD_SHARED_LIBRARY)
message(STATUS "Building GTSAM_UNSTABLE - shared") message(STATUS "Building GTSAM_UNSTABLE - shared")
add_library(gtsam_unstable-shared SHARED ${gtsam_unstable_srcs}) add_library(gtsam_unstable-shared SHARED ${gtsam_unstable_srcs})
set_target_properties(gtsam_unstable-shared PROPERTIES set_target_properties(gtsam_unstable-shared PROPERTIES
@ -80,7 +77,7 @@ if (GTSAM_UNSTABLE_BUILD_SHARED_LIBRARY)
install(TARGETS gtsam_unstable-shared EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin) 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) list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable-shared)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
endif(GTSAM_UNSTABLE_BUILD_SHARED_LIBRARY) endif()
# Wrap version for gtsam_unstable # Wrap version for gtsam_unstable
if (GTSAM_INSTALL_MATLAB_TOOLBOX) if (GTSAM_INSTALL_MATLAB_TOOLBOX)

View File

@ -8,8 +8,8 @@ set(base_local_libs
base_unstable) base_unstable)
set (base_full_libs set (base_full_libs
gtsam-static ${gtsam-default}
gtsam_unstable-static) ${gtsam_unstable-default})
# Exclude tests that don't work # Exclude tests that don't work
set (base_excluded_tests "") set (base_excluded_tests "")

View File

@ -12,8 +12,8 @@ set(discrete_local_libs
) )
set (discrete_full_libs set (discrete_full_libs
gtsam-static ${gtsam-default}
gtsam_unstable-static) ${gtsam_unstable-default})
# Exclude tests that don't work # Exclude tests that don't work
#set (discrete_excluded_tests #set (discrete_excluded_tests
@ -45,7 +45,6 @@ if (GTSAM_BUILD_EXAMPLES)
add_custom_target(${example}.run ${EXECUTABLE_OUTPUT_PATH}${example} ${ARGN}) add_custom_target(${example}.run ${EXECUTABLE_OUTPUT_PATH}${example} ${ARGN})
endif() endif()
add_dependencies(${example} gtsam-static gtsam_unstable-static) target_link_libraries(${example} ${gtsam-default} ${gtsam_unstable-default})
target_link_libraries(${example} gtsam-static gtsam_unstable-static)
endforeach(example) endforeach(example)
endif (GTSAM_BUILD_EXAMPLES) endif (GTSAM_BUILD_EXAMPLES)

View File

@ -15,8 +15,8 @@ set(dynamics_local_libs
) )
set (dynamics_full_libs set (dynamics_full_libs
gtsam-static ${gtsam-default}
gtsam_unstable-static) ${gtsam_unstable-default})
# Exclude tests that don't work # Exclude tests that don't work
set (dynamics_excluded_tests "") set (dynamics_excluded_tests "")

View File

@ -11,8 +11,8 @@ set(geometry_local_libs
) )
set (geometry_full_libs set (geometry_full_libs
gtsam-static ${gtsam-default}
gtsam_unstable-static) ${gtsam_unstable-default})
# Exclude tests that don't work # Exclude tests that don't work
set (geometry_excluded_tests "") set (geometry_excluded_tests "")

View File

@ -9,8 +9,8 @@ set(linear_local_libs
base) base)
set (linear_full_libs set (linear_full_libs
gtsam-static ${gtsam-default}
gtsam_unstable-static) ${gtsam_unstable-default})
# Exclude tests that don't work # Exclude tests that don't work
set (base_excluded_tests "") set (base_excluded_tests "")

View File

@ -15,8 +15,8 @@ set(navigation_local_libs
) )
set (navigation_full_libs set (navigation_full_libs
gtsam-static ${gtsam-default}
gtsam_unstable-static) ${gtsam_unstable-default})
# Exclude tests that don't work # Exclude tests that don't work
set (navigation_excluded_tests "") set (navigation_excluded_tests "")

View File

@ -14,8 +14,8 @@ set(nonlinear_local_libs
) )
set (nonlinear_full_libs set (nonlinear_full_libs
gtsam-static ${gtsam-default}
gtsam_unstable-static) ${gtsam_unstable-default})
# Exclude tests that don't work # Exclude tests that don't work
set (nonlinear_excluded_tests "") set (nonlinear_excluded_tests "")

View File

@ -15,8 +15,8 @@ set(slam_local_libs
) )
set (slam_full_libs set (slam_full_libs
gtsam-static ${gtsam-default}
gtsam_unstable-static) ${gtsam_unstable-default})
# Exclude tests that don't work # Exclude tests that don't work
set (slam_excluded_tests "") set (slam_excluded_tests "")

View File

@ -5,6 +5,7 @@ file(GLOB time_srcs "time*.cpp")
list(REMOVE_ITEM test_lib_srcs ${test_srcs}) list(REMOVE_ITEM test_lib_srcs ${test_srcs})
list(REMOVE_ITEM test_lib_srcs ${time_srcs}) list(REMOVE_ITEM test_lib_srcs ${time_srcs})
add_library(test_lib STATIC ${test_lib_srcs}) add_library(test_lib STATIC ${test_lib_srcs})
target_link_libraries(test_lib ${gtsam-default})
# Assemble local libraries # Assemble local libraries
set(tests_local_libs set(tests_local_libs
@ -38,7 +39,7 @@ if (GTSAM_BUILD_TESTS)
# Build grouped tests # Build grouped tests
gtsam_add_grouped_scripts("tests" # Use subdirectory as group label gtsam_add_grouped_scripts("tests" # Use subdirectory as group label
"test*.cpp" check "Test" # Standard for all tests "test*.cpp" check "Test" # Standard for all tests
"${tests_local_libs}" "gtsam-static;CppUnitLite;test_lib" "${tests_exclude}" # Pass in linking and exclusion lists "${tests_local_libs}" "${gtsam-default};CppUnitLite;test_lib" "${tests_exclude}" # Pass in linking and exclusion lists
${is_test}) # Set all as tests ${is_test}) # Set all as tests
endif (GTSAM_BUILD_TESTS) endif (GTSAM_BUILD_TESTS)
@ -51,6 +52,6 @@ if (GTSAM_BUILD_TIMING)
# Build grouped benchmarks # Build grouped benchmarks
gtsam_add_grouped_scripts("tests" # Use subdirectory as group label gtsam_add_grouped_scripts("tests" # Use subdirectory as group label
"time*.cpp" timing "Timing Benchmark" # Standard for all timing scripts "time*.cpp" timing "Timing Benchmark" # Standard for all timing scripts
"${tests_local_libs}" "gtsam-static;CppUnitLite;test_lib" "${tests_exclude}" # Pass in linking and exclusion lists "${tests_local_libs}" "${gtsam-default};CppUnitLite;test_lib" "${tests_exclude}" # Pass in linking and exclusion lists
${is_test}) ${is_test})
endif (GTSAM_BUILD_TIMING) endif (GTSAM_BUILD_TIMING)