2020-11-26 14:47:35 -05:00
|
|
|
project(wpilibcExamples)
|
|
|
|
|
|
|
|
|
|
include(AddTest)
|
|
|
|
|
include(SubDirList)
|
|
|
|
|
|
2023-08-30 21:17:09 -07:00
|
|
|
subdir_list(TEMPLATES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/templates)
|
2024-05-24 13:48:05 -04:00
|
|
|
subdir_list(EXAMPLES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/examples)
|
2025-04-22 14:26:26 -07:00
|
|
|
subdir_list(SNIPPETS ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/snippets)
|
2020-11-26 14:47:35 -05:00
|
|
|
|
2024-08-29 17:03:41 -04:00
|
|
|
add_custom_target(wpilibcExamples)
|
|
|
|
|
add_custom_target(wpilibcExamples_test)
|
2025-04-28 16:25:49 -07:00
|
|
|
add_custom_target(wpilibcExamples_snippets)
|
2024-08-29 17:03:41 -04:00
|
|
|
|
2020-11-26 14:47:35 -05:00
|
|
|
foreach(example ${EXAMPLES})
|
2023-11-30 19:52:21 -05:00
|
|
|
file(
|
|
|
|
|
GLOB_RECURSE sources
|
|
|
|
|
src/main/cpp/examples/${example}/cpp/*.cpp
|
|
|
|
|
src/main/cpp/examples/${example}/c/*.c
|
|
|
|
|
)
|
|
|
|
|
add_executable(${example} ${sources})
|
|
|
|
|
wpilib_target_warnings(${example})
|
|
|
|
|
target_include_directories(${example} PUBLIC src/main/cpp/examples/${example}/include)
|
|
|
|
|
target_link_libraries(
|
|
|
|
|
${example}
|
|
|
|
|
apriltag
|
|
|
|
|
wpilibc
|
2025-11-07 19:55:39 -05:00
|
|
|
commandsv2
|
2023-11-30 19:52:21 -05:00
|
|
|
romiVendordep
|
|
|
|
|
xrpVendordep
|
|
|
|
|
)
|
2024-08-29 17:03:41 -04:00
|
|
|
add_dependencies(wpilibcExamples ${example})
|
2020-11-26 14:47:35 -05:00
|
|
|
|
2023-11-30 19:52:21 -05:00
|
|
|
if(WITH_TESTS AND EXISTS ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/test/cpp/examples/${example})
|
2024-08-29 17:03:41 -04:00
|
|
|
wpilib_add_test(Example_${example} src/test/cpp/examples/${example}/cpp)
|
|
|
|
|
target_sources(Example_${example}_test PRIVATE ${sources})
|
2023-11-30 19:52:21 -05:00
|
|
|
target_include_directories(
|
2024-08-29 17:03:41 -04:00
|
|
|
Example_${example}_test
|
2023-11-30 19:52:21 -05:00
|
|
|
PRIVATE
|
|
|
|
|
src/main/cpp/examples/${example}/include
|
|
|
|
|
src/test/cpp/examples/${example}/include
|
|
|
|
|
)
|
2024-08-29 17:03:41 -04:00
|
|
|
target_compile_definitions(Example_${example}_test PUBLIC RUNNING_FRC_TESTS)
|
2023-11-30 19:52:21 -05:00
|
|
|
target_link_libraries(
|
2024-08-29 17:03:41 -04:00
|
|
|
Example_${example}_test
|
2023-11-30 19:52:21 -05:00
|
|
|
apriltag
|
|
|
|
|
wpilibc
|
2025-11-07 19:55:39 -05:00
|
|
|
commandsv2
|
2023-11-30 19:52:21 -05:00
|
|
|
romiVendordep
|
|
|
|
|
xrpVendordep
|
2024-07-19 00:10:26 -04:00
|
|
|
googletest
|
2023-11-30 19:52:21 -05:00
|
|
|
)
|
2024-08-29 17:03:41 -04:00
|
|
|
add_dependencies(wpilibcExamples_test Example_${example}_test)
|
2023-11-30 19:52:21 -05:00
|
|
|
endif()
|
2020-11-26 14:47:35 -05:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
|
|
foreach(template ${TEMPLATES})
|
2023-11-30 19:52:21 -05:00
|
|
|
file(
|
|
|
|
|
GLOB_RECURSE sources
|
|
|
|
|
src/main/cpp/templates/${template}/cpp/*.cpp
|
|
|
|
|
src/main/cpp/templates/${template}/c/*.c
|
|
|
|
|
)
|
|
|
|
|
add_executable(${template} ${sources})
|
|
|
|
|
wpilib_target_warnings(${template})
|
|
|
|
|
target_include_directories(${template} PUBLIC src/main/cpp/templates/${template}/include)
|
2025-11-07 19:55:39 -05:00
|
|
|
target_link_libraries(${template} wpilibc commandsv2 romiVendordep xrpVendordep)
|
2024-08-29 17:03:41 -04:00
|
|
|
add_dependencies(wpilibcExamples ${template})
|
2020-11-26 14:47:35 -05:00
|
|
|
endforeach()
|
2025-04-22 14:26:26 -07:00
|
|
|
|
|
|
|
|
foreach(snippet ${SNIPPETS})
|
|
|
|
|
file(
|
|
|
|
|
GLOB_RECURSE sources
|
|
|
|
|
src/main/cpp/snippets/${snippet}/cpp/*.cpp
|
|
|
|
|
src/main/cpp/snippets/${snippet}/c/*.c
|
|
|
|
|
)
|
|
|
|
|
add_executable(snippet${snippet} ${sources})
|
2025-04-28 16:25:49 -07:00
|
|
|
wpilib_target_warnings(snippet${snippet})
|
2025-04-22 14:26:26 -07:00
|
|
|
target_include_directories(snippet${snippet} PUBLIC src/main/cpp/snippets/${snippet}/include)
|
2025-11-07 19:55:39 -05:00
|
|
|
target_link_libraries(snippet${snippet} wpilibc commandsv2 romiVendordep xrpVendordep)
|
2025-04-28 16:25:49 -07:00
|
|
|
add_dependencies(wpilibcExamples_snippets snippet${snippet})
|
2025-04-22 14:26:26 -07:00
|
|
|
endforeach()
|