From 7625c2177710ef8a1b5624fcf8a94c74fce2bf86 Mon Sep 17 00:00:00 2001 From: jlblancoc Date: Fri, 8 Feb 2019 22:18:21 +0100 Subject: [PATCH] Various fixes to cmake exported targets List of changes: * -I boost is no longer required (Since the use of Boost::xxx imported targets) * fix missing Boost deps in imported gtsam by searching for Boost inside GTSAMConfig.cmake * Including the dirs for Eigen/MKL/SuiteSparse/Metis into exported targets public interface. * Fix missing cmake changes in wrap/* * Split build flags into private/public, not to expose to users flags that may be invasive. * Removed now useless include_dirs in "extra cmake" * Update cmake/example_project * Make cppunitlite to find boost headers via Boost::boost * Update README / INSTALL to reflect the updated minimum CMake >= 3.0 --- CMakeLists.txt | 64 +++++++++------------------- CppUnitLite/CMakeLists.txt | 1 + INSTALL | 64 ++++++++++++++-------------- README.md | 10 ++--- cmake/Config.cmake.in | 8 +++- cmake/example_project/CMakeLists.txt | 5 ++- gtsam/CMakeLists.txt | 60 +++++++++++++++++++++++++- gtsam_extra.cmake.in | 12 ------ wrap/CMakeLists.txt | 19 ++++++--- 9 files changed, 139 insertions(+), 104 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 673f9a45f..d084840be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,15 +121,19 @@ if(MSVC) # If we use Boost shared libs, disable auto linking. # Some libraries, at least Boost Program Options, rely on this to export DLL symbols. if(NOT Boost_USE_STATIC_LIBS) - list(APPEND GTSAM_COMPILE_DEFINITIONS BOOST_ALL_NO_LIB BOOST_ALL_DYN_LINK) + list(APPEND GTSAM_COMPILE_DEFINITIONS_PUBLIC BOOST_ALL_NO_LIB BOOST_ALL_DYN_LINK) endif() # Virtual memory range for PCH exceeded on VS2015 if(MSVC_VERSION LESS 1910) # older than VS2017 - list(APPEND GTSAM_COMPILE_OPTIONS -Zm295) + list(APPEND GTSAM_COMPILE_OPTIONS_PRIVATE -Zm295) endif() endif() -find_package(Boost 1.43 COMPONENTS serialization system filesystem thread program_options date_time timer chrono regex) +# Store these in variables so they are automatically replicated in GTSAMConfig.cmake and such. +set(BOOST_FIND_MINIMUM_VERSION 1.43) +set(BOOST_FIND_MINIMUM_COMPONENTS serialization system filesystem thread program_options date_time timer chrono regex) + +find_package(Boost ${BOOST_FIND_MINIMUM_VERSION} COMPONENTS ${BOOST_FIND_MINIMUM_COMPONENTS}) # Required components if(NOT Boost_SERIALIZATION_LIBRARY OR NOT Boost_SYSTEM_LIBRARY OR NOT Boost_FILESYSTEM_LIBRARY OR @@ -149,7 +153,7 @@ set(GTSAM_BOOST_LIBRARIES ) if (GTSAM_DISABLE_NEW_TIMERS) message("WARNING: GTSAM timing instrumentation manually disabled") - list(APPEND GTSAM_COMPILE_DEFINITIONS DGTSAM_DISABLE_NEW_TIMERS) + list(APPEND GTSAM_COMPILE_DEFINITIONS_PUBLIC DGTSAM_DISABLE_NEW_TIMERS) else() if(Boost_TIMER_LIBRARY) list(APPEND GTSAM_BOOST_LIBRARIES Boost::timer Boost::chrono) @@ -162,7 +166,7 @@ endif() if(NOT (${Boost_VERSION} LESS 105600)) message("Ignoring Boost restriction on optional lvalue assignment from rvalues") - list(APPEND GTSAM_COMPILE_DEFINITIONS BOOST_OPTIONAL_ALLOW_BINDING_TO_RVALUES BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES) + list(APPEND GTSAM_COMPILE_DEFINITIONS_PUBLIC BOOST_OPTIONAL_ALLOW_BINDING_TO_RVALUES BOOST_OPTIONAL_CONFIG_ALLOW_BINDING_TO_RVALUES) endif() ############################################################################### @@ -212,7 +216,6 @@ find_package(MKL) if(MKL_FOUND AND GTSAM_WITH_EIGEN_MKL) set(GTSAM_USE_EIGEN_MKL 1) # This will go into config.h set(EIGEN_USE_MKL_ALL 1) # This will go into config.h - it makes Eigen use MKL - include_directories(${MKL_INCLUDE_DIR}) list(APPEND GTSAM_ADDITIONAL_LIBRARIES ${MKL_LIBRARIES}) # --no-as-needed is required with gcc according to the MKL link advisor @@ -247,10 +250,9 @@ option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', us # Switch for using system Eigen or GTSAM-bundled Eigen if(GTSAM_USE_SYSTEM_EIGEN) find_package(Eigen3 REQUIRED) - include_directories(AFTER "${EIGEN3_INCLUDE_DIR}") # Use generic Eigen include paths e.g. - set(GTSAM_EIGEN_INCLUDE_PREFIX "${EIGEN3_INCLUDE_DIR}") + set(GTSAM_EIGEN_INCLUDE_PREFIX "${EIGEN3_INCLUDE_DIR}") # check if MKL is also enabled - can have one or the other, but not both! # Note: Eigen >= v3.2.5 includes our patches @@ -270,22 +272,19 @@ else() if(EIGEN3_INCLUDE_DIR) set(EIGEN3_INCLUDE_DIR NOTFOUND CACHE STRING "" FORCE) endif() - # Add the bundled version of eigen to the include path so that it can still be included - # with #include - include_directories(BEFORE "gtsam/3rdparty/Eigen/") # set full path to be used by external projects # this will be added to GTSAM_INCLUDE_DIR by gtsam_extra.cmake.in - set(GTSAM_EIGEN_INCLUDE_PREFIX "${CMAKE_INSTALL_PREFIX}/include/gtsam/3rdparty/Eigen/") + set(GTSAM_EIGEN_INCLUDE_PREFIX "include/gtsam/3rdparty/Eigen/") endif() if (MSVC) if (BUILD_SHARED_LIBS) # mute eigen static assert to avoid errors in shared lib - list(APPEND GTSAM_COMPILE_DEFINITIONS DEIGEN_NO_STATIC_ASSERT) + list(APPEND GTSAM_COMPILE_DEFINITIONS_PUBLIC DEIGEN_NO_STATIC_ASSERT) endif() - list(APPEND GTSAM_COMPILE_OPTIONS "/wd4244") # Disable loss of precision which is thrown all over our Eigen + list(APPEND GTSAM_COMPILE_OPTIONS_PRIVATE "/wd4244") # Disable loss of precision which is thrown all over our Eigen endif() ############################################################################### @@ -326,52 +325,29 @@ elseif("${GTSAM_DEFAULT_ALLOCATOR}" STREQUAL "tcmalloc") list(APPEND GTSAM_ADDITIONAL_LIBRARIES "tcmalloc") endif() -# Include boost - use 'BEFORE' so that a specific boost specified to CMake -# takes precedence over a system-installed one. -include_directories(BEFORE SYSTEM ${Boost_INCLUDE_DIR}) - -if(GTSAM_SUPPORT_NESTED_DISSECTION) - set(METIS_INCLUDE_DIRECTORIES - gtsam/3rdparty/metis/include - gtsam/3rdparty/metis/libmetis - gtsam/3rdparty/metis/GKlib) -else() - set(METIS_INCLUDE_DIRECTORIES) -endif() - -# Add includes for source directories 'BEFORE' boost and any system include -# paths so that the compiler uses GTSAM headers in our source directory instead -# of any previously installed GTSAM headers. -include_directories(BEFORE - gtsam/3rdparty/SuiteSparse_config - gtsam/3rdparty/CCOLAMD/Include - ${METIS_INCLUDE_DIRECTORIES} - ${PROJECT_SOURCE_DIR} - ${PROJECT_BINARY_DIR} # So we can include generated config header files - CppUnitLite) - if(MSVC) - list(APPEND GTSAM_COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) - list(APPEND GTSAM_COMPILE_OPTIONS /wd4251 /wd4275 /wd4251 /wd4661 /wd4344 /wd4503) # Disable non-DLL-exported base class and other warnings - list(APPEND GTSAM_COMPILE_OPTIONS /bigobj) # Allow large object files for template-based code + list(APPEND GTSAM_COMPILE_DEFINITIONS_PRIVATE _CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS) + list(APPEND GTSAM_COMPILE_OPTIONS_PRIVATE /wd4251 /wd4275 /wd4251 /wd4661 /wd4344 /wd4503) # Disable non-DLL-exported base class and other warnings + list(APPEND GTSAM_COMPILE_OPTIONS_PRIVATE /bigobj) # Allow large object files for template-based code endif() # GCC 4.8+ complains about local typedefs which we use for shared_ptr etc. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) - list(APPEND GTSAM_COMPILE_OPTIONS -Wno-unused-local-typedefs) + list(APPEND GTSAM_COMPILE_OPTIONS_PRIVATE -Wno-unused-local-typedefs) endif() endif() # As of XCode 7, clang also complains about this if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) - list(APPEND GTSAM_COMPILE_OPTIONS -Wno-unused-local-typedefs) + list(APPEND GTSAM_COMPILE_OPTIONS_PRIVATE -Wno-unused-local-typedefs) endif() endif() if(GTSAM_ENABLE_CONSISTENCY_CHECKS) - list(APPEND GTSAM_COMPILE_DEFINITIONS GTSAM_EXTRA_CONSISTENCY_CHECKS) + # This should be made PUBLIC if GTSAM_EXTRA_CONSISTENCY_CHECKS is someday used in a public .h + list(APPEND GTSAM_COMPILE_DEFINITIONS_PRIVATE GTSAM_EXTRA_CONSISTENCY_CHECKS) endif() ############################################################################### diff --git a/CppUnitLite/CMakeLists.txt b/CppUnitLite/CMakeLists.txt index 35ecd71f8..f52841274 100644 --- a/CppUnitLite/CMakeLists.txt +++ b/CppUnitLite/CMakeLists.txt @@ -6,6 +6,7 @@ file(GLOB cppunitlite_src "*.cpp") add_library(CppUnitLite STATIC ${cppunitlite_src} ${cppunitlite_headers}) list(APPEND GTSAM_EXPORTED_TARGETS CppUnitLite) set(GTSAM_EXPORTED_TARGETS "${GTSAM_EXPORTED_TARGETS}" PARENT_SCOPE) +target_link_libraries(CppUnitLite PUBLIC Boost::boost) # boost/lexical_cast.h gtsam_assign_source_folders("${cppunitlite_headers};${cppunitlite_src}") # MSVC project structure diff --git a/INSTALL b/INSTALL index c71dcd4f9..d2f0b68df 100644 --- a/INSTALL +++ b/INSTALL @@ -14,7 +14,7 @@ Important Installation Notes 1) GTSAM requires the following libraries to be installed on your system: - BOOST version 1.43 or greater (install through Linux repositories or MacPorts) - - Cmake version 2.6 or higher + - Cmake version 3.0 or higher - Support for XCode 4.3 command line tools on Mac requires CMake 2.8.8 or higher Optional dependent libraries: @@ -33,20 +33,20 @@ Tested compilers: Tested systems: -- Ubuntu 11.04 - 13.10 +- Ubuntu 11.04 - 18.04 - MacOS 10.6 - 10.9 -- Windows 7, 8, 8.1 +- Windows 7, 8, 8.1, 10 Known issues: - MSVC 2013 is not yet supported because it cannot build the serialization module - of Boost 1.55 (or earlier). + of Boost 1.55 (or earlier). 2) GTSAM makes extensive use of debug assertions, and we highly recommend you work in Debug mode while developing (enabled by default). Likewise, it is imperative that you switch to release mode when running finished code and for timing. GTSAM -will run up to 10x faster in Release mode! See the end of this document for +will run up to 10x faster in Release mode! See the end of this document for additional debugging tips. 3) @@ -55,7 +55,7 @@ build directory. 4) The instructions below install the library to the default system install path and -build all components. From a terminal, starting in the root library folder, +build all components. From a terminal, starting in the root library folder, execute commands as follows for an out-of-source build: $] mkdir build @@ -64,7 +64,7 @@ $] cmake .. $] make check (optional, runs unit tests) $] make install -This will build the library and unit tests, run all of the unit tests, +This will build the library and unit tests, run all of the unit tests, and then install the library itself. - CMake Configuration Options and Details @@ -75,12 +75,12 @@ one of the following: ccmake the curses GUI for cmake cmake-gui a real GUI for cmake -Important Options: +Important Options: CMAKE_BUILD_TYPE: We support several build configurations for GTSAM (case insensitive) Debug (default) All error checking options on, no optimization. Use for development. - Release Optimizations turned on, no debug symbols. - Timing Adds ENABLE_TIMING flag to provide statistics on operation + Release Optimizations turned on, no debug symbols. + Timing Adds ENABLE_TIMING flag to provide statistics on operation Profiling Standard configuration for use during profiling RelWithDebInfo Same as Release, but with the -g flag for debug symbols @@ -92,42 +92,42 @@ GTSAM_TOOLBOX_INSTALL_PATH: The Matlab toolbox will be installed in a subdirecto of this folder, called 'gtsam'. $] cmake -DGTSAM_TOOLBOX_INSTALL_PATH:PATH=$HOME/toolbox .. -GTSAM_BUILD_CONVENIENCE_LIBRARIES: This is a build option to allow for tests in -subfolders to be linked against convenience libraries rather than the full libgtsam. +GTSAM_BUILD_CONVENIENCE_LIBRARIES: This is a build option to allow for tests in +subfolders to be linked against convenience libraries rather than the full libgtsam. Set with the command line as follows: $] cmake -DGTSAM_BUILD_CONVENIENCE_LIBRARIES:OPTION=ON .. - ON (Default) This builds convenience libraries and links tests against them. This - option is suggested for gtsam developers, as it is possible to build - and run tests without first building the rest of the library, and - speeds up compilation for a single test. The downside of this option - is that it will build the entire library again to build the full + ON (Default) This builds convenience libraries and links tests against them. This + option is suggested for gtsam developers, as it is possible to build + and run tests without first building the rest of the library, and + speeds up compilation for a single test. The downside of this option + is that it will build the entire library again to build the full libgtsam library, so build/install will be slower. - OFF This will build all of libgtsam before any of the tests, and then - link all of the tests at once. This option is best for users of GTSAM, - as it avoids rebuilding the entirety of gtsam an extra time. + OFF This will build all of libgtsam before any of the tests, and then + link all of the tests at once. This option is best for users of GTSAM, + as it avoids rebuilding the entirety of gtsam an extra time. -GTSAM_BUILD_UNSTABLE: Enable build and install for libgtsam_unstable library. +GTSAM_BUILD_UNSTABLE: Enable build and install for libgtsam_unstable library. Set with the command line as follows: $] cmake -DGTSAM_BUILD_UNSTABLE:OPTION=ON .. - ON When enabled, libgtsam_unstable will be built and installed with the - same options as libgtsam. In addition, if tests are enabled, the + ON When enabled, libgtsam_unstable will be built and installed with the + same options as libgtsam. In addition, if tests are enabled, the unit tests will be built as well. The Matlab toolbox will also - be generated if the matlab toolbox is enabled, installing into a + be generated if the matlab toolbox is enabled, installing into a folder called "gtsam_unstable". - OFF (Default) If disabled, no gtsam_unstable code will be included in build or install. + OFF (Default) If disabled, no gtsam_unstable code will be included in build or install. Check -"make check" will build and run all of the tests. Note that the tests will only be +"make check" will build and run all of the tests. Note that the tests will only be built when using the "check" targets, to prevent "make install" from building the tests -unnecessarily. You can also run "make timing" to build all of the timing scripts. +unnecessarily. You can also run "make timing" to build all of the timing scripts. To run check on a particular module only, run "make check.[subfolder]", so to run just the geometry tests, run "make check.geometry". Individual tests can be run by -appending ".run" to the name of the test, for example, to run testMatrix, run -"make testMatrix.run". +appending ".run" to the name of the test, for example, to run testMatrix, run +"make testMatrix.run". -MEX_COMMAND: Path to the mex compiler. Defaults to assume the path is included in your -shell's PATH environment variable. mex is installed with matlab at +MEX_COMMAND: Path to the mex compiler. Defaults to assume the path is included in your +shell's PATH environment variable. mex is installed with matlab at $MATLABROOT/bin/mex $MATLABROOT can be found by executing the command 'matlabroot' in MATLAB @@ -143,4 +143,4 @@ it impossible to use _GLIBCXX_DEBUG. MacPorts g++ compilers do work with it tho NOTE: If _GLIBCXX_DEBUG is used to compile gtsam, anything that links against gtsam will need to be compiled with _GLIBCXX_DEBUG as well, due to the use of -header-only Eigen. +header-only Eigen. diff --git a/README.md b/README.md index 02ed5149c..e815d7f4b 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ $ make install Prerequisites: - [Boost](http://www.boost.org/users/download/) >= 1.43 (Ubuntu: `sudo apt-get install libboost-all-dev`) -- [CMake](http://www.cmake.org/cmake/resources/software.html) >= 2.6 (Ubuntu: `sudo apt-get install cmake`) +- [CMake](http://www.cmake.org/cmake/resources/software.html) >= 3.0 (Ubuntu: `sudo apt-get install cmake`) - A modern compiler, i.e., at least gcc 4.7.3 on Linux. Optional prerequisites - used automatically if findable by CMake: @@ -54,7 +54,7 @@ GTSAM includes a state of the art IMU handling scheme based on Our implementation improves on this using integration on the manifold, as detailed in -- Luca Carlone, Zsolt Kira, Chris Beall, Vadim Indelman, and Frank Dellaert, "Eliminating conditionally independent sets in factor graphs: a unifying perspective based on smart factors", Int. Conf. on Robotics and Automation (ICRA), 2014. +- Luca Carlone, Zsolt Kira, Chris Beall, Vadim Indelman, and Frank Dellaert, "Eliminating conditionally independent sets in factor graphs: a unifying perspective based on smart factors", Int. Conf. on Robotics and Automation (ICRA), 2014. - Christian Forster, Luca Carlone, Frank Dellaert, and Davide Scaramuzza, "IMU Preintegration on Manifold for Efficient Visual-Inertial Maximum-a-Posteriori Estimation", Robotics: Science and Systems (RSS), 2015. If you are using the factor in academic work, please cite the publications above. @@ -67,8 +67,8 @@ Additional Information There is a [`GTSAM users Google group`](https://groups.google.com/forum/#!forum/gtsam-users) for general discussion. -Read about important [`GTSAM-Concepts`](GTSAM-Concepts.md) here. A primer on GTSAM Expressions, -which support (superfast) automatic differentiation, +Read about important [`GTSAM-Concepts`](GTSAM-Concepts.md) here. A primer on GTSAM Expressions, +which support (superfast) automatic differentiation, can be found on the [GTSAM wiki on BitBucket](https://bitbucket.org/gtborg/gtsam/wiki/Home). See the [`INSTALL`](INSTALL) file for more detailed installation instructions. @@ -77,4 +77,4 @@ GTSAM is open source under the BSD license, see the [`LICENSE`](LICENSE) and [`L Please see the [`examples/`](examples) directory and the [`USAGE`](USAGE.md) file for examples on how to use GTSAM. -GTSAM was developed in the lab of [Frank Dellaert](http://www.cc.gatech.edu/~dellaert) at the [Georgia Institute of Technology](http://www.gatech.edu), with the help of many contributors over the years, see [THANKS](THANKS). \ No newline at end of file +GTSAM was developed in the lab of [Frank Dellaert](http://www.cc.gatech.edu/~dellaert) at the [Georgia Institute of Technology](http://www.gatech.edu), with the help of many contributors over the years, see [THANKS](THANKS). diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in index 5f3956f07..4323f760b 100644 --- a/cmake/Config.cmake.in +++ b/cmake/Config.cmake.in @@ -1,7 +1,7 @@ # - Config file for @CMAKE_PROJECT_NAME@ # It defines the following variables # @PACKAGE_NAME@_INCLUDE_DIR - include directories for @CMAKE_PROJECT_NAME@ - + # Compute paths get_filename_component(OUR_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) if(EXISTS "${OUR_CMAKE_DIR}/CMakeCache.txt") @@ -11,7 +11,11 @@ else() # Find installed library set(@PACKAGE_NAME@_INCLUDE_DIR "${OUR_CMAKE_DIR}/@CONF_REL_INCLUDE_DIR@" CACHE PATH "@PACKAGE_NAME@ include directory") endif() - + +# Find dependencies, required by cmake exported targets: +include(CMakeFindDependencyMacro) +find_dependency(Boost @BOOST_FIND_MINIMUM_VERSION@ COMPONENTS @BOOST_FIND_MINIMUM_COMPONENTS@) + # Load exports include(${OUR_CMAKE_DIR}/@PACKAGE_NAME@-exports.cmake) diff --git a/cmake/example_project/CMakeLists.txt b/cmake/example_project/CMakeLists.txt index e287087d1..2afc6edc2 100644 --- a/cmake/example_project/CMakeLists.txt +++ b/cmake/example_project/CMakeLists.txt @@ -22,7 +22,10 @@ include_directories(BEFORE "${PROJECT_SOURCE_DIR}") ################################################################################### # Find GTSAM components find_package(GTSAM REQUIRED) # Uses installed package -include_directories(${GTSAM_INCLUDE_DIR}) +# Note: Since Jan-2019, GTSAMConfig.cmake defines exported CMake targets +# that automatically do include the include_directories() without the need +# to call include_directories(), just target_link_libraries(NAME gtsam) +#include_directories(${GTSAM_INCLUDE_DIR}) ################################################################################### # Build static library from common sources diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index d369009c0..034268fdb 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -103,14 +103,70 @@ message(STATUS "Building GTSAM - shared: ${BUILD_SHARED_LIBS}") add_library(gtsam ${gtsam_srcs}) target_link_libraries(gtsam PUBLIC ${GTSAM_BOOST_LIBRARIES}) target_link_libraries(gtsam PUBLIC ${GTSAM_ADDITIONAL_LIBRARIES}) -target_compile_definitions(gtsam PUBLIC ${GTSAM_COMPILE_DEFINITIONS}) -target_compile_options(gtsam PUBLIC ${GTSAM_COMPILE_OPTIONS}) +target_compile_definitions(gtsam PRIVATE ${GTSAM_COMPILE_DEFINITIONS_PRIVATE}) +target_compile_definitions(gtsam PUBLIC ${GTSAM_COMPILE_DEFINITIONS_PUBLIC}) +if (NOT "${GTSAM_COMPILE_OPTIONS_PUBLIC}" STREQUAL "") + target_compile_options(gtsam PUBLIC ${GTSAM_COMPILE_OPTIONS_PUBLIC}) +endif() +target_compile_options(gtsam PRIVATE ${GTSAM_COMPILE_OPTIONS_PRIVATE}) set_target_properties(gtsam PROPERTIES OUTPUT_NAME gtsam CLEAN_DIRECT_OUTPUT 1 VERSION ${gtsam_version} SOVERSION ${gtsam_soversion}) +# Append Eigen include path, set in top-level CMakeLists.txt to either +# system-eigen, or GTSAM eigen path +if (GTSAM_USE_SYSTEM_EIGEN) + target_include_directories(gtsam PUBLIC + $ + ) +else() + target_include_directories(gtsam PUBLIC + $ + ) +endif() +target_include_directories(gtsam PUBLIC + $ +) +# MKL include dir: +if (GTSAM_USE_EIGEN_MKL) + target_include_directories(gtsam PUBLIC ${MKL_INCLUDE_DIR}) +endif() + +if(GTSAM_USE_TBB) + target_include_directories(gtsam PUBLIC ${TBB_INCLUDE_DIRS}) +endif() + +# Add includes for source directories 'BEFORE' boost and any system include +# paths so that the compiler uses GTSAM headers in our source directory instead +# of any previously installed GTSAM headers. +target_include_directories(gtsam BEFORE PUBLIC + # SuiteSparse_config + $ + $ + # CCOLAMD + $ + $ + # main gtsam includes: + $ + $ + # config.h + $ + # unit tests: + $ +) +if(GTSAM_SUPPORT_NESTED_DISSECTION) + target_include_directories(gtsam BEFORE PUBLIC + $ + $ + $ + $ + ) +endif() + + + if(WIN32) # Add 'lib' prefix to static library to avoid filename collision with shared library if (NOT BUILD_SHARED_LIBS) set_target_properties(gtsam PROPERTIES diff --git a/gtsam_extra.cmake.in b/gtsam_extra.cmake.in index a1a8e3a90..b7990b3cc 100644 --- a/gtsam_extra.cmake.in +++ b/gtsam_extra.cmake.in @@ -9,18 +9,6 @@ set (GTSAM_VERSION_STRING "@GTSAM_VERSION_STRING@") set (GTSAM_USE_TBB @GTSAM_USE_TBB@) set (GTSAM_DEFAULT_ALLOCATOR @GTSAM_DEFAULT_ALLOCATOR@) -if("@GTSAM_USE_TBB@") - list(APPEND GTSAM_INCLUDE_DIR "@TBB_INCLUDE_DIRS@") -endif() - -# Append Eigen include path, set in top-level CMakeLists.txt to either -# system-eigen, or GTSAM eigen path -list(APPEND GTSAM_INCLUDE_DIR "@GTSAM_EIGEN_INCLUDE_PREFIX@") - -if("@GTSAM_USE_EIGEN_MKL@") - list(APPEND GTSAM_INCLUDE_DIR "@MKL_INCLUDE_DIR@") -endif() - if("@GTSAM_INSTALL_CYTHON_TOOLBOX@") list(APPEND GTSAM_EIGENCY_INSTALL_PATH "@GTSAM_EIGENCY_INSTALL_PATH@") endif() diff --git a/wrap/CMakeLists.txt b/wrap/CMakeLists.txt index 04d471b39..df8dc209f 100644 --- a/wrap/CMakeLists.txt +++ b/wrap/CMakeLists.txt @@ -1,22 +1,30 @@ # Build/install Wrap -set(WRAP_BOOST_LIBRARIES ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY}) +set(WRAP_BOOST_LIBRARIES + Boost::system + Boost::filesystem + Boost::thread +) # Allow for disabling serialization to handle errors related to Clang's linker option(GTSAM_WRAP_SERIALIZATION "If enabled, allows for wrapped objects to be saved via boost.serialization" ON) -if (NOT GTSAM_WRAP_SERIALIZATION) - add_definitions(-DWRAP_DISABLE_SERIALIZE) -endif() # Build the executable itself 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_include_directories(wrap_lib PUBLIC + $ +) +if (NOT GTSAM_WRAP_SERIALIZATION) + target_compile_definitions(wrap_lib PUBLIC -DWRAP_DISABLE_SERIALIZE) +endif() + 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}) +target_link_libraries(wrap PRIVATE wrap_lib) # Set folder in Visual Studio file(RELATIVE_PATH relative_path "${PROJECT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") @@ -32,4 +40,3 @@ install(FILES matlab.h DESTINATION include/wrap) # Build tests add_subdirectory(tests) -