From ebf5e20cb77aea3678e0f9db4faed38c7b3b327f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93mar=20H=C3=B6gni=20Gu=C3=B0marsson?= Date: Mon, 27 Nov 2023 17:27:54 +0000 Subject: [PATCH] Dont build examples when BUILD_EXAMPLES off --- libs/confman/testing/CMakeLists.txt | 4 +++- libs/dbus_util/tests/CMakeLists.txt | 2 ++ libs/ipc/testing/CMakeLists.txt | 4 +++- libs/logger/tests/CMakeLists.txt | 4 +++- libs/motor/tests/CMakeLists.txt | 4 +++- libs/mqtt-sparkplug/CMakeLists.txt | 4 +++- .../{example => examples}/CMakeLists.txt | 0 .../mqtt-sparkplug-example.cpp | 0 libs/operation_mode/tests/CMakeLists.txt | 4 +++- libs/progbase/tests/CMakeLists.txt | 15 +++------------ libs/progbase/tests/examples/CMakeLists.txt | 12 ++++++++++++ 11 files changed, 35 insertions(+), 18 deletions(-) rename libs/mqtt-sparkplug/{example => examples}/CMakeLists.txt (100%) rename libs/mqtt-sparkplug/{example => examples}/mqtt-sparkplug-example.cpp (100%) create mode 100644 libs/progbase/tests/examples/CMakeLists.txt diff --git a/libs/confman/testing/CMakeLists.txt b/libs/confman/testing/CMakeLists.txt index 791170ccb4..b21308266e 100644 --- a/libs/confman/testing/CMakeLists.txt +++ b/libs/confman/testing/CMakeLists.txt @@ -1,4 +1,6 @@ -add_subdirectory(examples) +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() add_subdirectory(mocks) add_subdirectory(stubs) add_subdirectory(tests) diff --git a/libs/dbus_util/tests/CMakeLists.txt b/libs/dbus_util/tests/CMakeLists.txt index bc8f38566a..32720ea9c9 100644 --- a/libs/dbus_util/tests/CMakeLists.txt +++ b/libs/dbus_util/tests/CMakeLists.txt @@ -7,4 +7,6 @@ target_link_libraries(dbus_util_test PRIVATE Boost::ut tfc::logger tfc::base tfc add_test(NAME dbus_util_test COMMAND dbus_util_test) +if(BUILD_EXAMPLES) add_subdirectory(examples) +endif() diff --git a/libs/ipc/testing/CMakeLists.txt b/libs/ipc/testing/CMakeLists.txt index 7ec0122f84..bc6c30fde1 100644 --- a/libs/ipc/testing/CMakeLists.txt +++ b/libs/ipc/testing/CMakeLists.txt @@ -1,3 +1,5 @@ -add_subdirectory(examples) +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() add_subdirectory(tests) add_subdirectory(mocks) diff --git a/libs/logger/tests/CMakeLists.txt b/libs/logger/tests/CMakeLists.txt index c7c2f3a1d5..79168eab03 100644 --- a/libs/logger/tests/CMakeLists.txt +++ b/libs/logger/tests/CMakeLists.txt @@ -12,4 +12,6 @@ add_test( logging_test ) -add_subdirectory(examples) +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() \ No newline at end of file diff --git a/libs/motor/tests/CMakeLists.txt b/libs/motor/tests/CMakeLists.txt index 73d002f6b5..d857b60de9 100644 --- a/libs/motor/tests/CMakeLists.txt +++ b/libs/motor/tests/CMakeLists.txt @@ -10,4 +10,6 @@ add_test( COMMAND motor_impl_test ) -add_subdirectory(example) \ No newline at end of file +if(BUILD_EXAMPLES) + add_subdirectory(example) +endif() \ No newline at end of file diff --git a/libs/mqtt-sparkplug/CMakeLists.txt b/libs/mqtt-sparkplug/CMakeLists.txt index e36b9f39f7..f6b7f13b09 100644 --- a/libs/mqtt-sparkplug/CMakeLists.txt +++ b/libs/mqtt-sparkplug/CMakeLists.txt @@ -34,4 +34,6 @@ target_link_libraries(sparkplug_proto target_include_directories(sparkplug_proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) protobuf_generate(TARGET sparkplug_proto LANGUAGE cpp) -add_subdirectory(example) +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/libs/mqtt-sparkplug/example/CMakeLists.txt b/libs/mqtt-sparkplug/examples/CMakeLists.txt similarity index 100% rename from libs/mqtt-sparkplug/example/CMakeLists.txt rename to libs/mqtt-sparkplug/examples/CMakeLists.txt diff --git a/libs/mqtt-sparkplug/example/mqtt-sparkplug-example.cpp b/libs/mqtt-sparkplug/examples/mqtt-sparkplug-example.cpp similarity index 100% rename from libs/mqtt-sparkplug/example/mqtt-sparkplug-example.cpp rename to libs/mqtt-sparkplug/examples/mqtt-sparkplug-example.cpp diff --git a/libs/operation_mode/tests/CMakeLists.txt b/libs/operation_mode/tests/CMakeLists.txt index cbce7e5caa..1fae35340d 100644 --- a/libs/operation_mode/tests/CMakeLists.txt +++ b/libs/operation_mode/tests/CMakeLists.txt @@ -1 +1,3 @@ -add_subdirectory(example) \ No newline at end of file +if(BUILD_EXAMPLES) + add_subdirectory(example) +endif() \ No newline at end of file diff --git a/libs/progbase/tests/CMakeLists.txt b/libs/progbase/tests/CMakeLists.txt index 2fcd42fdbf..d2d82e3453 100644 --- a/libs/progbase/tests/CMakeLists.txt +++ b/libs/progbase/tests/CMakeLists.txt @@ -5,15 +5,6 @@ target_link_libraries(progbase_options_test Boost::ut Boost::program_options tfc add_test(NAME progbase_options_test COMMAND progbase_options_test) -# Add examples to tests so that they definitely compile -add_executable(progbase_example_base examples/example_base.cpp) -target_link_libraries(progbase_example_base tfc::base Boost::program_options) -add_test( - NAME - progbase_example_base - COMMAND - progbase_example_base -) - -# Tell doxygen where to find this example -add_example_to_docs(progbase_example_base) \ No newline at end of file +if(BUILD_EXAMPLES) + add_subdirectory(examples) +endif() \ No newline at end of file diff --git a/libs/progbase/tests/examples/CMakeLists.txt b/libs/progbase/tests/examples/CMakeLists.txt new file mode 100644 index 0000000000..0109b58133 --- /dev/null +++ b/libs/progbase/tests/examples/CMakeLists.txt @@ -0,0 +1,12 @@ +# Add examples to tests so that they definitely compile +add_executable(progbase_example_base example_base.cpp) +target_link_libraries(progbase_example_base tfc::base Boost::program_options) +add_test( + NAME + progbase_example_base + COMMAND + progbase_example_base +) + +# Tell doxygen where to find this example +add_example_to_docs(progbase_example_base) \ No newline at end of file