Changed target name to 'gtsam' instead of 'gtsam-shared' and 'gtsam-static'. Modified CMake options to only allow building either static or shared, but not both. Enabled GTSAM_BUILD_TYPE_POSTFIXES by default on all platforms.

release/4.3a0
Richard Roberts 2014-01-30 14:41:25 -05:00
parent fe55148dd7
commit 4b8c17ec77
22 changed files with 72 additions and 96 deletions

View File

@ -52,8 +52,7 @@ option(GTSAM_BUILD_EXAMPLES "Enable/Disable building of examples"
if(GTSAM_UNSTABLE_AVAILABLE)
option(GTSAM_BUILD_UNSTABLE "Enable/Disable libgtsam_unstable" ON)
endif()
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" OFF)
option(GTSAM_BUILD_STATIC_LIBRARY "Build a static gtsam library, instead of shared" OFF)
option(GTSAM_USE_QUATERNIONS "Enable/Disable using an internal Quaternion representation for rotations instead of rotation matrices. If enable, Rot3::EXPMAP is enforced by default." OFF)
option(GTSAM_POSE3_EXPMAP "Enable/Disable using Pose3::EXPMAP as the default mode. If disabled, Pose3::FIRST_ORDER will be used." OFF)
option(GTSAM_ROT3_EXPMAP "Ignore if GTSAM_USE_QUATERNIONS is OFF (Rot3::EXPMAP by default). Otherwise, enable Rot3::EXPMAP, or if disabled, use Rot3::CAYLEY." OFF)
@ -76,15 +75,14 @@ if(GTSAM_INSTALL_WRAP AND NOT GTSAM_BUILD_WRAP)
message(FATAL_ERROR "GTSAM_INSTALL_WRAP is enabled, please also enable GTSAM_BUILD_WRAP")
endif()
if(GTSAM_INSTALL_MATLAB_TOOLBOX AND GTSAM_BUILD_STATIC_LIBRARY)
message(FATAL_ERROR "GTSAM_INSTALL_MATLAB_TOOLBOX and GTSAM_BUILD_STATIC_LIBRARY are both enabled. The MATLAB wrapper cannot be compiled with a static GTSAM library because mex modules are themselves shared libraries. If you want a self-contained mex module, enable GTSAM_MEX_BUILD_STATIC_MODULE instead of GTSAM_BUILD_STATIC_LIBRARY.")
endif()
# Flags for choosing default packaging tools
set(CPACK_SOURCE_GENERATOR "TGZ" CACHE STRING "CPack Default Source Generator")
set(CPACK_GENERATOR "TGZ" CACHE STRING "CPack Default Binary Generator")
# Sanity check building of libraries
if (NOT GTSAM_BUILD_SHARED_LIBRARY AND NOT GTSAM_BUILD_STATIC_LIBRARY)
message(FATAL_ERROR "Both shared and static version of GTSAM library disabled - need to choose at least one!")
endif()
# Flags to determine whether tests and examples are build during 'make install'
# Note that these remove the targets from the 'all'
option(GTSAM_DISABLE_TESTS_ON_INSTALL "Disables building tests during install" ON)
@ -286,24 +284,11 @@ endif()
if(GTSAM_ENABLE_CONSISTENCY_CHECKS)
add_definitions(-DGTSAM_EXTRA_CONSISTENCY_CHECKS)
endif()
endif()
###############################################################################
# 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)
@ -381,8 +366,7 @@ print_config_flag(${GTSAM_BUILD_TESTS} "Build Tests
if (DOXYGEN_FOUND)
print_config_flag(${GTSAM_BUILD_DOCS} "Build Docs ")
endif()
print_config_flag(${GTSAM_BUILD_SHARED_LIBRARY} "Build shared GTSAM Library ")
print_config_flag(${GTSAM_BUILD_STATIC_LIBRARY} "Build static GTSAM Library ")
print_config_flag(${GTSAM_BUILD_STATIC_LIBRARY} "Build static GTSAM library instead of shared")
print_config_flag(${GTSAM_BUILD_TYPE_POSTFIXES} "Put build type in library name ")
if(GTSAM_UNSTABLE_AVAILABLE)
print_config_flag(${GTSAM_BUILD_UNSTABLE} "Build libgtsam_unstable ")

View File

@ -10,11 +10,7 @@ if(NOT FIRST_PASS_DONE AND NOT CMAKE_BUILD_TYPE AND NOT MSVC AND NOT XCODE_VERSI
endif()
# Add option for using build type postfixes to allow installing multiple build modes
if(MSVC OR XCODE_VERSION)
option(GTSAM_BUILD_TYPE_POSTFIXES "Enable/Disable appending the build type to the name of compiled libraries" ON)
else()
option(GTSAM_BUILD_TYPE_POSTFIXES "Enable/Disable appending the build type to the name of compiled libraries" OFF)
endif()
option(GTSAM_BUILD_TYPE_POSTFIXES "Enable/Disable appending the build type to the name of compiled libraries" ON)
# Add debugging flags but only on the first pass
if(NOT FIRST_PASS_DONE)

View File

@ -28,7 +28,7 @@ foreach(example_src ${example_srcs} )
set_target_properties(${example_bin} PROPERTIES EXCLUDE_FROM_ALL ON)
endif()
target_link_libraries(${example_bin} ${gtsam-default} ${Boost_PROGRAM_OPTIONS_LIBRARY})
target_link_libraries(${example_bin} gtsam ${Boost_PROGRAM_OPTIONS_LIBRARY})
if(NOT MSVC)
add_custom_target(${example_bin}.run ${EXECUTABLE_OUTPUT_PATH}${example_bin} ${ARGN})
endif()

View File

@ -95,42 +95,40 @@ message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
# build shared and static versions of the library
if (GTSAM_BUILD_STATIC_LIBRARY)
message(STATUS "Building GTSAM - static")
add_library(gtsam-static STATIC ${gtsam_srcs})
target_link_libraries(gtsam-static ${GTSAM_BOOST_LIBRARIES} ${GTSAM_ADDITIONAL_LIBRARIES})
set_target_properties(gtsam-static PROPERTIES
add_library(gtsam STATIC ${gtsam_srcs})
target_link_libraries(gtsam ${GTSAM_BOOST_LIBRARIES} ${GTSAM_ADDITIONAL_LIBRARIES})
set_target_properties(gtsam PROPERTIES
OUTPUT_NAME gtsam
CLEAN_DIRECT_OUTPUT 1
VERSION ${gtsam_version}
SOVERSION ${gtsam_soversion})
if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with shared library
set_target_properties(gtsam-static PROPERTIES
set_target_properties(gtsam PROPERTIES
PREFIX "lib"
COMPILE_DEFINITIONS GTSAM_IMPORT_STATIC)
endif()
install(TARGETS gtsam-static EXPORT GTSAM-exports ARCHIVE DESTINATION lib)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam-static)
install(TARGETS gtsam EXPORT GTSAM-exports ARCHIVE DESTINATION lib)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
endif ()
if (GTSAM_BUILD_SHARED_LIBRARY)
else()
message(STATUS "Building GTSAM - shared")
add_library(gtsam-shared SHARED ${gtsam_srcs})
target_link_libraries(gtsam-shared ${GTSAM_BOOST_LIBRARIES} ${GTSAM_ADDITIONAL_LIBRARIES})
set_target_properties(gtsam-shared PROPERTIES
add_library(gtsam SHARED ${gtsam_srcs})
target_link_libraries(gtsam ${GTSAM_BOOST_LIBRARIES} ${GTSAM_ADDITIONAL_LIBRARIES})
set_target_properties(gtsam PROPERTIES
OUTPUT_NAME gtsam
CLEAN_DIRECT_OUTPUT 1
VERSION ${gtsam_version}
SOVERSION ${gtsam_soversion})
if(WIN32)
set_target_properties(gtsam-shared PROPERTIES
set_target_properties(gtsam PROPERTIES
PREFIX ""
DEFINE_SYMBOL GTSAM_EXPORTS
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
endif()
install(TARGETS gtsam-shared EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam-shared)
install(TARGETS gtsam EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
endif(GTSAM_BUILD_SHARED_LIBRARY)
endif()
# Set dataset paths
set_property(SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/slam/dataset.cpp"
@ -153,10 +151,10 @@ if (GTSAM_INSTALL_MATLAB_TOOLBOX)
# Generate, build and install toolbox
set(mexFlags "${GTSAM_BUILD_MEX_BINARY_FLAGS}")
if("${gtsam-default}" STREQUAL "gtsam-static")
if(GTSAM_BUILD_STATIC_LIBRARY)
list(APPEND mexFlags -DGTSAM_IMPORT_STATIC)
endif()
# Wrap
wrap_and_install_library(../gtsam.h "${gtsam-default};${GTSAM_ADDITIONAL_LIBRARIES}" "" "${mexFlags}")
wrap_and_install_library(../gtsam.h "gtsam;${GTSAM_ADDITIONAL_LIBRARIES}" "" "${mexFlags}")
endif ()

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,7 @@ set(linear_excluded_files
# Build tests
if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(linear "${gtsam-default}" "${gtsam-default}" "${linear_excluded_files}")
gtsam_add_subdir_tests(linear "gtsam" "gtsam" "${linear_excluded_files}")
endif(GTSAM_BUILD_TESTS)
if(MSVC)
@ -20,5 +20,5 @@ endif()
# Build timing scripts
if (GTSAM_BUILD_TIMING)
gtsam_add_subdir_timing(linear "${gtsam-default}" "${gtsam-default}" "${linear_excluded_files}")
gtsam_add_subdir_timing(linear "gtsam" "gtsam" "${linear_excluded_files}")
endif(GTSAM_BUILD_TIMING)

View File

@ -7,10 +7,10 @@ set (navigation_excluded_tests "")
# Add all tests
if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(navigation "${gtsam-default}" "${gtsam-default}" "${navigation_excluded_tests}")
gtsam_add_subdir_tests(navigation "gtsam" "gtsam" "${navigation_excluded_tests}")
endif()
# Build timing scripts
if (GTSAM_BUILD_TIMING)
gtsam_add_subdir_timing(navigation "${gtsam-default}" "${gtsam-default}" "${navigation_excluded_files}")
gtsam_add_subdir_timing(navigation "gtsam" "gtsam" "${navigation_excluded_files}")
endif(GTSAM_BUILD_TIMING)

View File

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

View File

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

View File

@ -10,11 +10,11 @@ set(symbolic_excluded_files
# Build tests
if (GTSAM_BUILD_TESTS)
gtsam_add_subdir_tests(symbolic "${gtsam-default}" "${gtsam-default}" "${symbolic_excluded_files}")
gtsam_add_subdir_tests(symbolic "gtsam" "gtsam" "${symbolic_excluded_files}")
endif(GTSAM_BUILD_TESTS)
# Build timing scripts
if (GTSAM_BUILD_TIMING)
gtsam_add_subdir_timing(symbolic "${gtsam-default}" "${gtsam-default}" "${symbolic_excluded_files}")
gtsam_add_subdir_timing(symbolic "gtsam" "gtsam" "${symbolic_excluded_files}")
endif(GTSAM_BUILD_TIMING)

View File

@ -58,40 +58,38 @@ 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
add_library(gtsam_unstable STATIC ${gtsam_unstable_srcs})
set_target_properties(gtsam_unstable PROPERTIES
OUTPUT_NAME gtsam_unstable
CLEAN_DIRECT_OUTPUT 1
VERSION ${gtsam_unstable_version}
SOVERSION ${gtsam_unstable_soversion})
if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with shared library
set_target_properties(gtsam_unstable-static PROPERTIES
set_target_properties(gtsam_unstable PROPERTIES
PREFIX "lib"
COMPILE_DEFINITIONS GTSAM_UNSTABLE_IMPORT_STATIC)
endif()
target_link_libraries(gtsam_unstable-static gtsam-static ${GTSAM_UNSTABLE_BOOST_LIBRARIES})
install(TARGETS gtsam_unstable-static EXPORT GTSAM-exports ARCHIVE DESTINATION lib)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable-static)
target_link_libraries(gtsam_unstable gtsam ${GTSAM_UNSTABLE_BOOST_LIBRARIES})
install(TARGETS gtsam_unstable EXPORT GTSAM-exports ARCHIVE DESTINATION lib)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
endif()
if (GTSAM_BUILD_SHARED_LIBRARY)
else()
message(STATUS "Building GTSAM_UNSTABLE - shared")
add_library(gtsam_unstable-shared SHARED ${gtsam_unstable_srcs})
set_target_properties(gtsam_unstable-shared PROPERTIES
add_library(gtsam_unstable SHARED ${gtsam_unstable_srcs})
set_target_properties(gtsam_unstable PROPERTIES
OUTPUT_NAME gtsam_unstable
CLEAN_DIRECT_OUTPUT 1
VERSION ${gtsam_unstable_version}
SOVERSION ${gtsam_unstable_soversion})
if(WIN32)
set_target_properties(gtsam_unstable-shared PROPERTIES
set_target_properties(gtsam_unstable PROPERTIES
PREFIX ""
DEFINE_SYMBOL GTSAM_UNSTABLE_EXPORTS
RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
endif()
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)
target_link_libraries(gtsam_unstable gtsam ${GTSAM_UNSTABLE_BOOST_LIBRARIES})
install(TARGETS gtsam_unstable EXPORT GTSAM-exports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin)
list(APPEND GTSAM_EXPORTED_TARGETS gtsam_unstable)
set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE)
endif()
@ -102,12 +100,12 @@ if (GTSAM_INSTALL_MATLAB_TOOLBOX)
# Generate, build and install toolbox
set(mexFlags "${GTSAM_BUILD_MEX_BINARY_FLAGS}")
if("${gtsam-default}" STREQUAL "gtsam-static")
if(GTSAM_BUILD_STATIC_LIBRARY)
list(APPEND mexFlags -DGTSAM_IMPORT_STATIC)
endif()
# Wrap
wrap_and_install_library(gtsam_unstable.h "${gtsam-default};${gtsam_unstable-default}" "" "${mexFlags}")
wrap_and_install_library(gtsam_unstable.h "gtsam;gtsam_unstable" "" "${mexFlags}")
endif(GTSAM_INSTALL_MATLAB_TOOLBOX)

View File

@ -3,8 +3,8 @@ file(GLOB base_headers "*.h")
install(FILES ${base_headers} DESTINATION include/gtsam_unstable/base)
set (base_full_libs
${gtsam-default}
${gtsam_unstable-default})
gtsam
gtsam_unstable)
# Exclude tests that don't work
set (base_excluded_tests "")

View File

@ -3,8 +3,8 @@ file(GLOB discrete_headers "*.h")
install(FILES ${discrete_headers} DESTINATION include/gtsam_unstable/discrete)
set (discrete_full_libs
${gtsam-default}
${gtsam_unstable-default})
gtsam
gtsam_unstable)
# Exclude tests that don't work
#set (discrete_excluded_tests
@ -37,6 +37,6 @@ if (GTSAM_BUILD_EXAMPLES)
add_custom_target(${example}.run ${EXECUTABLE_OUTPUT_PATH}${example} ${ARGN})
endif()
target_link_libraries(${example} ${gtsam-default} ${gtsam_unstable-default})
target_link_libraries(${example} gtsam gtsam_unstable)
endforeach(example)
endif (GTSAM_BUILD_EXAMPLES)

View File

@ -4,8 +4,8 @@ install(FILES ${dynamics_headers} DESTINATION include/gtsam_unstable/dynamics)
# Components to link tests in this subfolder against
set (dynamics_full_libs
${gtsam-default}
${gtsam_unstable-default})
gtsam
gtsam_unstable)
# Exclude tests that don't work
set (dynamics_excluded_tests "")

View File

@ -18,7 +18,7 @@ foreach(example_src ${example_srcs} )
set_target_properties(${example_bin} PROPERTIES EXCLUDE_FROM_ALL ON)
endif()
target_link_libraries(${example_bin} ${gtsam-default} ${gtsam_unstable-default})
target_link_libraries(${example_bin} gtsam gtsam_unstable)
if(NOT MSVC)
add_custom_target(${example_bin}.run ${EXECUTABLE_OUTPUT_PATH}${example_bin} ${ARGN})
endif()

View File

@ -4,8 +4,8 @@ install(FILES ${geometry_headers} DESTINATION include/gtsam_unstable/geometry)
# Components to link tests in this subfolder against
set (geometry_full_libs
${gtsam-default}
${gtsam_unstable-default})
gtsam
gtsam_unstable)
# Exclude tests that don't work
set (geometry_excluded_tests "")

View File

@ -4,8 +4,8 @@ install(FILES ${nonlinear_headers} DESTINATION include/gtsam_unstable/nonlinear)
# Components to link tests in this subfolder against
set (nonlinear_full_libs
${gtsam-default}
${gtsam_unstable-default})
gtsam
gtsam_unstable)
# Exclude tests that don't work
set (nonlinear_excluded_tests #"")

View File

@ -9,8 +9,8 @@ install(FILES ${slam_headers} DESTINATION include/gtsam_unstable/slam)
# Components to link tests in this subfolder against
set (slam_full_libs
${gtsam-default}
${gtsam_unstable-default})
gtsam
gtsam_unstable)
# Exclude tests that don't work
set (slam_excluded_tests

View File

@ -1,6 +1,6 @@
# Assemble local libraries
set (tests_full_libs
${gtsam-default}
gtsam
CppUnitLite)
# exclude certain files