aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2020-01-05 11:15:01 +0100
committerFelix Morgner <felix.morgner@gmail.com>2020-01-05 11:15:01 +0100
commitc34379a5aaef6d30f031a01026d2885a560b834e (patch)
treeb57c07ed9b89994828393942041ed1fa6262ee0e
parentf8441c895e611c35daa23bff50faff32efe7e198 (diff)
downloadnewtype-c34379a5aaef6d30f031a01026d2885a560b834e.tar.xz
newtype-c34379a5aaef6d30f031a01026d2885a560b834e.zip
build: add function to add examples
-rw-r--r--CMakeLists.txt16
1 files changed, 9 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 471befa..5d8929b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -150,14 +150,16 @@ endif()
option(BUILD_EXAMPLES "Build the library examples" OFF)
if(BUILD_EXAMPLES)
- add_executable("ex_basic_usage" "examples/src/basic_usage.cpp")
- target_link_libraries("ex_basic_usage" "${PROJECT_NAME}")
-
- add_executable("ex_basic_usage_with_show" "examples/src/basic_usage_with_show.cpp")
- target_link_libraries("ex_basic_usage_with_show" "${PROJECT_NAME}")
+ function(add_example NAME)
+ add_executable("ex_${NAME}"
+ "examples/src/${NAME}.cpp"
+ )
+ target_link_libraries("ex_${NAME}" "${PROJECT_NAME}")
+ endfunction()
- add_executable("ex_basic_usage_with_read" "examples/src/basic_usage_with_read.cpp")
- target_link_libraries("ex_basic_usage_with_read" "${PROJECT_NAME}")
+ add_example("basic_usage")
+ add_example("basic_usage_with_show")
+ add_example("basic_usage_with_read")
endif()
# CMake support files