diff options
| author | Felix Morgner <felix.morgner@gmail.com> | 2020-01-05 11:15:01 +0100 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@gmail.com> | 2020-01-05 11:15:01 +0100 |
| commit | c34379a5aaef6d30f031a01026d2885a560b834e (patch) | |
| tree | b57c07ed9b89994828393942041ed1fa6262ee0e | |
| parent | f8441c895e611c35daa23bff50faff32efe7e198 (diff) | |
| download | newtype-c34379a5aaef6d30f031a01026d2885a560b834e.tar.xz newtype-c34379a5aaef6d30f031a01026d2885a560b834e.zip | |
build: add function to add examples
| -rw-r--r-- | CMakeLists.txt | 16 |
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 |
