Files
allwpilib/wpilibcExamples/CMakeLists.txt
Gold856 f1adce4cf7 [examples] Clean up examples (#8674)
Move various "examples" into snippets. Several examples that were less
than a full mechanism or robot were moved to snippets. `arcadedrive` and
`tankdrive` were removed in favor of their Gamepad variants. `hidrumble`
was removed due to being too simple. `potentiometerpid` was removed
because of low utility. `gyromecanum` replaced `mecanumdrive` for
deduplication and because very few teams run holonomic drivetrains
without gyros.
2026-03-14 14:13:45 -07:00

110 lines
3.7 KiB
CMake

project(wpilibcExamples)
include(AddTest)
include(SubDirList)
subdir_list(TEMPLATES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/templates)
subdir_list(EXAMPLES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/examples)
subdir_list(SNIPPETS ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/snippets)
add_custom_target(wpilibcExamples)
add_custom_target(wpilibcExamples_test)
add_custom_target(wpilibcExamples_snippets)
foreach(example ${EXAMPLES})
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
commandsv2
romiVendordep
xrpVendordep
)
add_dependencies(wpilibcExamples ${example})
if(WITH_TESTS AND EXISTS ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/test/cpp/examples/${example})
wpilib_add_test(Example_${example} src/test/cpp/examples/${example}/cpp)
target_sources(Example_${example}_test PRIVATE ${sources})
target_include_directories(
Example_${example}_test
PRIVATE
src/main/cpp/examples/${example}/include
src/test/cpp/examples/${example}/include
)
target_compile_definitions(Example_${example}_test PUBLIC RUNNING_WPILIB_TESTS)
target_link_libraries(
Example_${example}_test
apriltag
wpilibc
commandsv2
romiVendordep
xrpVendordep
googletest
)
add_dependencies(wpilibcExamples_test Example_${example}_test)
endif()
endforeach()
foreach(template ${TEMPLATES})
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)
target_link_libraries(${template} wpilibc commandsv2 romiVendordep xrpVendordep)
add_dependencies(wpilibcExamples ${template})
endforeach()
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})
wpilib_target_warnings(snippet${snippet})
target_include_directories(snippet${snippet} PUBLIC src/main/cpp/snippets/${snippet}/include)
target_link_libraries(
snippet${snippet}
apriltag
wpilibc
commandsv2
romiVendordep
xrpVendordep
)
add_dependencies(wpilibcExamples_snippets snippet${snippet})
if(WITH_TESTS AND EXISTS ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/test/cpp/snippets/${snippet})
wpilib_add_test(Snippet_${snippet} src/test/cpp/snippets/${snippet}/cpp)
target_sources(Snippet_${snippet}_test PRIVATE ${sources})
target_include_directories(
Snippet_${snippet}_test
PRIVATE
src/main/cpp/snippets/${snippet}/include
src/test/cpp/snippets/${snippet}/include
)
target_compile_definitions(Snippet_${snippet}_test PUBLIC RUNNING_WPILIB_TESTS)
target_link_libraries(
Snippet_${snippet}_test
apriltag
wpilibc
commandsv2
romiVendordep
xrpVendordep
googletest
)
add_dependencies(wpilibcExamples_test Snippet_${snippet}_test)
endif()
endforeach()