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}) |
| 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}) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 13 | wpilib_target_warnings(${example}) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 14 | target_include_directories(${example} PUBLIC src/main/cpp/examples/${example}/include) |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 15 | target_link_libraries(${example} apriltag wpilibc wpilibNewCommands romiVendordep xrpVendordep) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 16 | |
| 17 | if (WITH_TESTS AND EXISTS ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/test/cpp/examples/${example}) |
| 18 | wpilib_add_test(${example} src/test/cpp/examples/${example}/cpp) |
| 19 | target_sources(${example}_test PRIVATE ${sources}) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 20 | target_include_directories(${example}_test PRIVATE |
| 21 | src/main/cpp/examples/${example}/include |
| 22 | src/test/cpp/examples/${example}/include) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 23 | target_compile_definitions(${example}_test PUBLIC RUNNING_FRC_TESTS) |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 24 | target_link_libraries(${example}_test apriltag wpilibc wpilibNewCommands romiVendordep xrpVendordep gmock_main) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 25 | endif() |
| 26 | endforeach() |
| 27 | |
| 28 | foreach(template ${TEMPLATES}) |
| 29 | file(GLOB_RECURSE sources src/main/cpp/templates/${template}/cpp/*.cpp |
| 30 | src/main/cpp/templates/${template}/c/*.c) |
| 31 | add_executable(${template} ${sources}) |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 32 | wpilib_target_warnings(${template}) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 33 | target_include_directories(${template} PUBLIC src/main/cpp/templates/${template}/include) |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame^] | 34 | target_link_libraries(${template} wpilibc wpilibNewCommands romiVendordep xrpVendordep) |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 35 | endforeach() |