gtsam/gtsam_unstable/CMakeLists.txt

137 lines
5.4 KiB
CMake
Raw Normal View History

# Build full gtsam_unstable library as a single library
# and also build tests
set (gtsam_unstable_subdirs
base
discrete
dynamics
2012-06-04 04:45:36 +08:00
linear
slam
)
add_custom_target(check.unstable COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure)
# assemble core libaries
foreach(subdir ${gtsam_unstable_subdirs})
# Build convenience libraries
file(GLOB subdir_srcs "${subdir}/*.cpp")
set(${subdir}_srcs ${subdir_srcs})
if (GTSAM_BUILD_CONVENIENCE_LIBRARIES)
message(STATUS "Building Convenience Library: ${subdir}_unstable")
add_library("${subdir}_unstable" STATIC ${subdir_srcs})
endif()
# Build local library and tests
message(STATUS "Building ${subdir}_unstable")
add_subdirectory(${subdir})
endforeach(subdir)
# assemble gtsam_unstable components
set(gtsam_unstable_srcs
${base_srcs}
${discrete_srcs}
${dynamics_srcs}
2012-06-04 04:45:36 +08:00
${linear_srcs}
${slam_srcs}
)
option (GTSAM_UNSTABLE_BUILD_SHARED_LIBRARY "Enable/Disable building of a shared version of gtsam_unstable" ON)
2012-05-04 01:03:27 +08:00
# 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})
message(STATUS "GTSAM_UNSTABLE Version: ${gtsam_unstable_version}")
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
# build shared and static versions of the library
message(STATUS "Building GTSAM_UNSTABLE - static")
add_library(gtsam_unstable-static STATIC ${gtsam_unstable_srcs})
set_target_properties(gtsam_unstable-static PROPERTIES
OUTPUT_NAME gtsam_unstable
CLEAN_DIRECT_OUTPUT 1
VERSION ${gtsam_unstable_version}
SOVERSION ${gtsam_unstable_soversion})
target_link_libraries(gtsam_unstable-static gtsam-static)
install(TARGETS gtsam_unstable-static ARCHIVE DESTINATION lib)
if (GTSAM_UNSTABLE_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
OUTPUT_NAME gtsam_unstable
CLEAN_DIRECT_OUTPUT 1
VERSION ${gtsam_unstable_version}
SOVERSION ${gtsam_unstable_soversion})
target_link_libraries(gtsam_unstable-shared gtsam-shared)
install(TARGETS gtsam_unstable-shared LIBRARY DESTINATION lib )
endif(GTSAM_UNSTABLE_BUILD_SHARED_LIBRARY)
# Wrap version for gtsam_unstable
if (GTSAM_BUILD_WRAP)
# Set up codegen
include(GtsamMatlabWrap)
# Wrap codegen
2012-06-05 05:14:47 +08:00
#usage: wrap mexExecutable mexExtension interfacePath moduleName toolboxPath [mexFlags]
# mexExecutable : command to execute mex if on path, use 'mex'
# mexExtension : OS/CPU-dependent extension for MEX binaries
# interfacePath : *absolute* path to directory of module interface file
# moduleName : the name of the module, interface file must be called moduleName.h
# toolboxPath : the directory in which to generate the wrappers
# [mexFlags] : extra flags for the mex command
# TODO: generate these includes programmatically
# Choose include flags depending on build process
if (GTSAM_BUILD_MEX_BIN)
set(MEX_INCLUDE_ROOT ${GTSAM_SOURCE_ROOT_DIR})
set(MEX_LIB_ROOT ${CMAKE_BINARY_DIR})
else()
set(MEX_INCLUDE_ROOT ${CMAKE_INSTALL_PREFIX}/include)
set(MEX_LIB_ROOT ${CMAKE_INSTALL_PREFIX}/lib)
endif()
set(mexFlags "-I${Boost_INCLUDE_DIR} -I${MEX_INCLUDE_ROOT} -I${MEX_INCLUDE_ROOT}/gtsam_unstable -I${MEX_INCLUDE_ROOT}/gtsam_unstable/dynamics -I${MEX_INCLUDE_ROOT}/gtsam_unstable/discrete -L${MEX_LIB_ROOT}/gtsam_unstable -L${MEX_LIB_ROOT}/gtsam -lgtsam -lgtsam_unstable")
if(MSVC OR CYGWIN OR WINGW)
set(mexFlags "${mexFlags} LINKFLAGS='$LINKFLAGS /LIBPATH:${Boost_LIBRARY_DIRS}'")
endif()
set(toolbox_path ${CMAKE_BINARY_DIR}/wrap/gtsam_unstable)
set(moduleName gtsam_unstable)
find_mexextension()
# Code generation command
add_custom_target(wrap_gtsam_unstable ALL COMMAND
2012-06-05 05:05:00 +08:00
${CMAKE_BINARY_DIR}/wrap/wrap
${MEX_COMMAND}
${GTSAM_MEX_BIN_EXTENSION}
${CMAKE_CURRENT_SOURCE_DIR}
${moduleName}
${toolbox_path}
"${mexFlags}"
DEPENDS wrap)
# Build command
if (GTSAM_BUILD_MEX_BIN)
# Actually compile the mex files when building the library
if (GTSAM_INSTALL_MEX_BIN)
add_custom_target(wrap_gtsam_unstable_build ALL
COMMAND make ${GTSAM_BUILD_MEX_BINARY_FLAGS}
WORKING_DIRECTORY ${toolbox_path}
DEPENDS wrap_gtsam_unstable)
else()
add_custom_target(wrap_gtsam_unstable_build
COMMAND make ${GTSAM_BUILD_MEX_BINARY_FLAGS}
WORKING_DIRECTORY ${toolbox_path}
DEPENDS wrap_gtsam_unstable)
endif()
endif ()
if (GTSAM_INSTALL_MATLAB_TOOLBOX)
# Primary toolbox files
message(STATUS "Installing Matlab Toolbox to ${GTSAM_TOOLBOX_INSTALL_PATH}")
install(DIRECTORY DESTINATION ${GTSAM_TOOLBOX_INSTALL_PATH}) # make an empty folder
# exploit need for trailing slash to specify a full folder, rather than just its contents to copy
install(DIRECTORY ${toolbox_path} DESTINATION ${GTSAM_TOOLBOX_INSTALL_PATH})
endif (GTSAM_INSTALL_MATLAB_TOOLBOX)
endif(GTSAM_BUILD_WRAP)