Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 1 | project(wpilibcExamples) |
| 2 | |
| 3 | include(AddTest) |
| 4 | include(SubDirList) |
| 5 | |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 6 | subdir_list(TEMPLATES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/templates) |
| 7 | subdir_list(EXAMPLES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/examples) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 8 | |
| 9 | foreach(example ${EXAMPLES}) |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 10 | file( |
| 11 | GLOB_RECURSE sources |
| 12 | src/main/cpp/examples/${example}/cpp/*.cpp |
| 13 | src/main/cpp/examples/${example}/c/*.c |
| 14 | ) |
| 15 | add_executable(${example} ${sources}) |
| 16 | wpilib_target_warnings(${example}) |
| 17 | target_include_directories(${example} PUBLIC src/main/cpp/examples/${example}/include) |
| 18 | target_link_libraries( |
| 19 | ${example} |
| 20 | apriltag |
| 21 | wpilibc |
| 22 | wpilibNewCommands |
| 23 | romiVendordep |
| 24 | xrpVendordep |
| 25 | ) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 26 | |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 27 | if(WITH_TESTS AND EXISTS ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/test/cpp/examples/${example}) |
| 28 | wpilib_add_test(${example} src/test/cpp/examples/${example}/cpp) |
| 29 | target_sources(${example}_test PRIVATE ${sources}) |
| 30 | target_include_directories( |
| 31 | ${example}_test |
| 32 | PRIVATE |
| 33 | src/main/cpp/examples/${example}/include |
| 34 | src/test/cpp/examples/${example}/include |
| 35 | ) |
| 36 | target_compile_definitions(${example}_test PUBLIC RUNNING_FRC_TESTS) |
| 37 | target_link_libraries( |
| 38 | ${example}_test |
| 39 | apriltag |
| 40 | wpilibc |
| 41 | wpilibNewCommands |
| 42 | romiVendordep |
| 43 | xrpVendordep |
| 44 | gmock_main |
| 45 | ) |
| 46 | endif() |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 47 | endforeach() |
| 48 | |
| 49 | foreach(template ${TEMPLATES}) |
Maxwell Henderson | 80bec32 | 2024-01-09 15:48:44 -0800 | [diff] [blame^] | 50 | file( |
| 51 | GLOB_RECURSE sources |
| 52 | src/main/cpp/templates/${template}/cpp/*.cpp |
| 53 | src/main/cpp/templates/${template}/c/*.c |
| 54 | ) |
| 55 | add_executable(${template} ${sources}) |
| 56 | wpilib_target_warnings(${template}) |
| 57 | target_include_directories(${template} PUBLIC src/main/cpp/templates/${template}/include) |
| 58 | target_link_libraries(${template} wpilibc wpilibNewCommands romiVendordep xrpVendordep) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 59 | endforeach() |