CMakeLists.txt (1453B)
1 cmake_minimum_required(VERSION 3.14) 2 3 project(stamenExamples CXX) 4 5 include(../cmake/project-is-top-level.cmake) 6 include(../cmake/folders.cmake) 7 8 if(PROJECT_IS_TOP_LEVEL) 9 find_package(stamen REQUIRED) 10 endif() 11 12 configure_file(demo_menu.conf demo_menu.conf COPYONLY) 13 configure_file(shared.h shared.h COPYONLY) 14 15 add_custom_target(run-examples) 16 17 add_custom_command( 18 OUTPUT demo_menu.hpp demo_menu.cpp 19 COMMAND stamen::exe -d test_display --cpp demo_menu.conf 20 DEPENDS demo_menu.conf stamen::exe 21 WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" 22 COMMENT "Generating menu files" 23 ) 24 25 add_custom_command( 26 OUTPUT demo_menu.h demo_menu.c 27 COMMAND stamen::exe --c demo_menu.conf 28 DEPENDS demo_menu.conf stamen::exe 29 WORKING_DIRECTORY "${PROJECT_BINARY_DIR}" 30 COMMENT "Generating cmenu files" 31 ) 32 33 function(add_example NAME EXT) 34 add_executable("${NAME}" "${NAME}.${EXT}") 35 target_include_directories("${NAME}" PRIVATE "${PROJECT_BINARY_DIR}") 36 target_link_libraries("${NAME}" PRIVATE stamen::stamen) 37 target_compile_features("${NAME}" PRIVATE cxx_std_20) 38 add_custom_target("run_${NAME}" COMMAND "${NAME}" demo_menu.conf VERBATIM) 39 add_dependencies("run_${NAME}" "${NAME}") 40 add_dependencies(run-examples "run_${NAME}") 41 42 endfunction() 43 44 add_example(example_c c) 45 target_sources(example_c PRIVATE "demo_menu.c") 46 47 add_example(example_cpp cpp) 48 target_sources(example_cpp PRIVATE "demo_menu.cpp") 49 50 add_example(dynamic cpp) 51 52 add_folders(Example)