Add support for examples.

This commit is contained in:
tastytea 2020-01-03 10:22:34 +01:00
parent a2e084eda0
commit b1b03bfa3e
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 18 additions and 1 deletions

View File

@ -20,7 +20,7 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# Project build options. # Project build options.
option(WITH_TESTS "Compile tests." NO) option(WITH_TESTS "Compile tests." NO)
# option(WITH_DOC "Generate HTML documentation." YES) # 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_DEB "Prepare for the building of .deb packages." NO)
# option(WITH_RPM "Prepare for the building of .rpm packages." NO) # option(WITH_RPM "Prepare for the building of .rpm packages." NO)
@ -36,4 +36,8 @@ if(WITH_TESTS)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
if(WITH_EXAMPLES)
add_subdirectory(examples)
endif()
# include(cmake/packages.cmake) # include(cmake/packages.cmake)

13
examples/CMakeLists.txt Normal file
View File

@ -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()