diff options
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 13 |
2 files changed, 18 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bc30ed..ae44169 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") # Project build options. option(WITH_TESTS "Compile tests." NO) # option(WITH_DOC "Generate HTML documentation." YES) -# option(WITH_EXAMPLES "Compile examples." NO) +option(WITH_EXAMPLES "Compile examples." NO) # option(WITH_DEB "Prepare for the building of .deb packages." NO) # option(WITH_RPM "Prepare for the building of .rpm packages." NO) @@ -36,4 +36,8 @@ if(WITH_TESTS) add_subdirectory(tests) endif() +if(WITH_EXAMPLES) + add_subdirectory(examples) +endif() + # include(cmake/packages.cmake) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 0000000..4be6be0 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,13 @@ +include(GNUInstallDirs) + +file(GLOB sources_examples *.cpp) +foreach(src ${sources_examples}) + get_filename_component(bin ${src} NAME_WE) + add_executable(${bin} ${src}) + target_link_libraries(${bin} PRIVATE ${PROJECT_NAME}) +endforeach() + +if(WITH_DOC) + install(FILES ${sources_examples} + DESTINATION "${CMAKE_INSTALL_DOCDIR}/${PROJECT_NAME}/examples") +endif() |