From c34379a5aaef6d30f031a01026d2885a560b834e Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Sun, 5 Jan 2020 11:15:01 +0100 Subject: build: add function to add examples --- CMakeLists.txt | 16 +++++++++------- 1 file 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 -- cgit v1.2.3