blob: 27cff6b4d7791ace01ccce09f468fc6ccab4ca4f [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001project(wpilibcExamples)
2
3include(AddTest)
4include(SubDirList)
5
6SUBDIR_LIST(TEMPLATES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/templates)
7SUBDIR_LIST(EXAMPLES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/examples)
8
9foreach(example ${EXAMPLES})
10 file(GLOB_RECURSE sources src/main/cpp/examples/${example}/cpp/*.cpp
11 src/main/cpp/examples/${example}/c/*.c)
12 add_executable(${example} ${sources})
13 target_include_directories(${example} PUBLIC src/main/cpp/examples/${example}/include)
14 target_link_libraries(${example} wpilibc wpilibNewCommands wpilibOldCommands)
15
16 if (WITH_TESTS AND EXISTS ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/test/cpp/examples/${example})
17 wpilib_add_test(${example} src/test/cpp/examples/${example}/cpp)
18 target_sources(${example}_test PRIVATE ${sources})
19 target_include_directories(${example}_test PRIVATE src/test/cpp/examples/${example}/include)
20 target_compile_definitions(${example}_test PUBLIC RUNNING_FRC_TESTS)
21 target_link_libraries(${example}_test wpilibc wpilibNewCommands gmock_main)
22 endif()
23endforeach()
24
25foreach(template ${TEMPLATES})
26 file(GLOB_RECURSE sources src/main/cpp/templates/${template}/cpp/*.cpp
27 src/main/cpp/templates/${template}/c/*.c)
28 add_executable(${template} ${sources})
29 target_include_directories(${template} PUBLIC src/main/cpp/templates/${template}/include)
30 target_link_libraries(${template} wpilibc wpilibNewCommands)
31endforeach()