Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 1 | project(wpilibcExamples) |
| 2 | |
| 3 | include(AddTest) |
| 4 | include(SubDirList) |
| 5 | |
| 6 | SUBDIR_LIST(TEMPLATES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/templates) |
| 7 | SUBDIR_LIST(EXAMPLES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/examples) |
| 8 | |
| 9 | foreach(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() |
| 23 | endforeach() |
| 24 | |
| 25 | foreach(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) |
| 31 | endforeach() |