diff --git a/CMakeLists.txt b/CMakeLists.txt index e6c9bc422..5d2acb464 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,7 @@ endif(GTSAM_USE_QUATERNIONS) # Alternative version to keep tests from building during make install # Use the EXCLUDE_FROM_ALL property on test executables option(GTSAM_ENABLE_INSTALL_TEST_FIX "Enable/Disable fix to remove dependency of tests on 'all' target" ON) +option(GTSAM_ENABLE_INSTALL_EXAMPLE_FIX "Enable/Disable fix to remove dependency of examples on 'all' target" OFF) # Pull in infrastructure if (GTSAM_BUILD_TESTS) @@ -162,6 +163,7 @@ if(GTSAM_UNSTABLE_AVAILABLE) print_config_flag(${GTSAM_BUILD_UNSTABLE} "Build libgtsam_unstable ") endif() print_config_flag(${GTSAM_ENABLE_INSTALL_TEST_FIX} "Tests excluded from all target ") +print_config_flag(${GTSAM_ENABLE_INSTALL_EXAMPLE_FIX} "Examples excluded from all target ") string(TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_toupper) message(STATUS " Build type : ${CMAKE_BUILD_TYPE}") message(STATUS " C compilation flags : ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${cmake_build_type_toupper}}") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 55f2db60b..116379489 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -8,6 +8,12 @@ foreach(example_src ${example_srcs} ) message(STATUS "Adding Example ${example_bin}") add_dependencies(examples ${example_bin}) add_executable(${example_bin} ${example_src}) + + # Disable building during make all/install + if (GTSAM_ENABLE_INSTALL_EXAMPLE_FIX) + set_target_properties(${example_bin} PROPERTIES EXCLUDE_FROM_ALL ON) + endif() + target_link_libraries(${example_bin} gtsam-static) add_custom_target(${example_bin}.run ${EXECUTABLE_OUTPUT_PATH}${example_bin} ${ARGN}) endforeach(example_src) diff --git a/gtsam_unstable/discrete/CMakeLists.txt b/gtsam_unstable/discrete/CMakeLists.txt index 56f62b1bf..f3c481ad4 100644 --- a/gtsam_unstable/discrete/CMakeLists.txt +++ b/gtsam_unstable/discrete/CMakeLists.txt @@ -25,6 +25,14 @@ gtsam_add_subdir_tests(discrete_unstable "${discrete_local_libs}" "${discrete_fu # add examples foreach(example schedulingExample schedulingQuals12) add_executable(${example} "examples/${example}.cpp") + + # Disable building during make all/install + if (GTSAM_ENABLE_INSTALL_EXAMPLE_FIX) + set_target_properties(${example} PROPERTIES EXCLUDE_FROM_ALL ON) + endif() + + add_dependencies(examples ${example}) + add_dependencies(${example} gtsam-static gtsam_unstable-static) target_link_libraries(${example} gtsam-static gtsam_unstable-static) add_custom_target(${example}.run ${EXECUTABLE_OUTPUT_PATH}${example} ${ARGN})