From bda4ba7f1ea11deae8cbf8226b44a0b78a4afacf Mon Sep 17 00:00:00 2001 From: Perry Naseck Date: Wed, 14 Dec 2022 12:05:23 -0500 Subject: [PATCH] make example optional in CMake --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59c10a2..059dbb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,10 +65,12 @@ else() target_link_libraries(${PROJECT_NAME} setupapi) endif() -## Uncomment for example -add_executable(serial_example examples/serial_example.cc) -add_dependencies(serial_example ${PROJECT_NAME}) -target_link_libraries(serial_example ${PROJECT_NAME}) +option(SERIAL_ENABLE_EXAMPLE "Enable example" ON) +if(${SERIAL_ENABLE_EXAMPLE}) + add_executable(serial_example examples/serial_example.cc) + add_dependencies(serial_example ${PROJECT_NAME}) + target_link_libraries(serial_example ${PROJECT_NAME}) +endif()