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()
if(NOT MSVC)
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()
set(GTSAM_BUILD_STATIC_LIBRARY ON)
endif()
option(GTSAM_USE_QUATERNIONS "Enable/Disable using an internal Quaternion representation for rotations instead of rotation matrices" OFF)
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()
@ -153,6 +153,19 @@ link_directories(${Boost_LIBRARY_DIRS})
###############################################################################
# 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
add_subdirectory(CppUnitLite)

View File

@ -94,8 +94,7 @@ if (GTSAM_BUILD_STATIC_LIBRARY)
install(TARGETS gtsam-static EXPORT GTSAM-exports ARCHIVE DESTINATION lib)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam-static)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
set(gtsam-lib gtsam-static)
endif (GTSAM_BUILD_STATIC_LIBRARY)
endif ()
if (GTSAM_BUILD_SHARED_LIBRARY)
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)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam-shared)
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)
# Set dataset paths

View File

@ -15,11 +15,11 @@ set(base_excluded_files
# 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)
# Build timing scripts
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)

View File

@ -17,7 +17,7 @@ set (discrete_excluded_tests "")
# Add all 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()
# Build timing scripts

View File

@ -16,11 +16,11 @@ set(geometry_excluded_files
# 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)
# Build timing scripts
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)

View File

@ -18,11 +18,11 @@ set(inference_excluded_files
# 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)
# Build timing scripts
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)

View File

@ -19,10 +19,10 @@ set(linear_excluded_files
# 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)
# Build timing scripts
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)

View File

@ -20,11 +20,11 @@ set(nonlinear_excluded_files
# 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)
# Build timing scripts
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)

View File

@ -21,10 +21,10 @@ set(slam_excluded_files
# 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)
# Build timing scripts
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)

View File

@ -44,10 +44,6 @@ set(gtsam_unstable_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
set(gtsam_unstable_version ${GTSAM_VERSION_MAJOR}.${GTSAM_VERSION_MINOR}.${GTSAM_VERSION_PATCH})
set(gtsam_unstable_soversion ${GTSAM_VERSION_MAJOR})
@ -55,6 +51,7 @@ message(STATUS "GTSAM_UNSTABLE Version: ${gtsam_unstable_version}")
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
# build shared and static versions of the library
if (GTSAM_BUILD_STATIC_LIBRARY)
message(STATUS "Building GTSAM_UNSTABLE - static")
add_library(gtsam_unstable-static STATIC ${gtsam_unstable_srcs})
set_target_properties(gtsam_unstable-static PROPERTIES
@ -63,12 +60,12 @@ set_target_properties(gtsam_unstable-static PROPERTIES
VERSION ${gtsam_unstable_version}
SOVERSION ${gtsam_unstable_soversion})
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)
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")
add_library(gtsam_unstable-shared SHARED ${gtsam_unstable_srcs})
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)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable-shared)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
endif(GTSAM_UNSTABLE_BUILD_SHARED_LIBRARY)
endif()
# Wrap version for gtsam_unstable
if (GTSAM_INSTALL_MATLAB_TOOLBOX)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,8 +15,8 @@ set(slam_local_libs
)
set (slam_full_libs
gtsam-static
gtsam_unstable-static)
${gtsam-default}
${gtsam_unstable-default})
# Exclude tests that don't work
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 ${time_srcs})
add_library(test_lib STATIC ${test_lib_srcs})
target_link_libraries(test_lib ${gtsam-default})
# Assemble local libraries
set(tests_local_libs
@ -38,7 +39,7 @@ if (GTSAM_BUILD_TESTS)
# Build grouped tests
gtsam_add_grouped_scripts("tests" # Use subdirectory as group label
"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
endif (GTSAM_BUILD_TESTS)
@ -51,6 +52,6 @@ if (GTSAM_BUILD_TIMING)
# Build grouped benchmarks
gtsam_add_grouped_scripts("tests" # Use subdirectory as group label
"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})
endif (GTSAM_BUILD_TIMING)