blob: f46d1c246d3a442340d43a882c7c0576f16e0378 [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001project(wpilibcExamples)
2
3include(AddTest)
4include(SubDirList)
5
James Kuszmaulb13e13f2023-11-22 20:44:04 -08006subdir_list(TEMPLATES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/templates)
7subdir_list(EXAMPLES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/examples)
Austin Schuh812d0d12021-11-04 20:16:48 -07008
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})
James Kuszmaulcf324122023-01-14 14:07:17 -080013 wpilib_target_warnings(${example})
Austin Schuh812d0d12021-11-04 20:16:48 -070014 target_include_directories(${example} PUBLIC src/main/cpp/examples/${example}/include)
James Kuszmaulb13e13f2023-11-22 20:44:04 -080015 target_link_libraries(${example} apriltag wpilibc wpilibNewCommands romiVendordep xrpVendordep)
Austin Schuh812d0d12021-11-04 20:16:48 -070016
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 Kuszmaulcf324122023-01-14 14:07:17 -080020 target_include_directories(${example}_test PRIVATE
21 src/main/cpp/examples/${example}/include
22 src/test/cpp/examples/${example}/include)
Austin Schuh812d0d12021-11-04 20:16:48 -070023 target_compile_definitions(${example}_test PUBLIC RUNNING_FRC_TESTS)
James Kuszmaulb13e13f2023-11-22 20:44:04 -080024 target_link_libraries(${example}_test apriltag wpilibc wpilibNewCommands romiVendordep xrpVendordep gmock_main)
Austin Schuh812d0d12021-11-04 20:16:48 -070025 endif()
26endforeach()
27
28foreach(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 Kuszmaulcf324122023-01-14 14:07:17 -080032 wpilib_target_warnings(${template})
Austin Schuh812d0d12021-11-04 20:16:48 -070033 target_include_directories(${template} PUBLIC src/main/cpp/templates/${template}/include)
James Kuszmaulb13e13f2023-11-22 20:44:04 -080034 target_link_libraries(${template} wpilibc wpilibNewCommands romiVendordep xrpVendordep)
Austin Schuh812d0d12021-11-04 20:16:48 -070035endforeach()