Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] cmake: Add meta target for examples and example tests #7015

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions wpilibcExamples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ include(SubDirList)
subdir_list(TEMPLATES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/templates)
subdir_list(EXAMPLES ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/main/cpp/examples)

add_custom_target(wpilibcExamples)
add_custom_target(wpilibcExamples_test)

foreach(example ${EXAMPLES})
file(
GLOB_RECURSE sources
Expand All @@ -23,26 +26,28 @@ foreach(example ${EXAMPLES})
romiVendordep
xrpVendordep
)
add_dependencies(wpilibcExamples ${example})

if(WITH_TESTS AND EXISTS ${CMAKE_SOURCE_DIR}/wpilibcExamples/src/test/cpp/examples/${example})
wpilib_add_test(${example} src/test/cpp/examples/${example}/cpp)
target_sources(${example}_test PRIVATE ${sources})
wpilib_add_test(Example_${example} src/test/cpp/examples/${example}/cpp)
target_sources(Example_${example}_test PRIVATE ${sources})
target_include_directories(
${example}_test
Example_${example}_test
PRIVATE
src/main/cpp/examples/${example}/include
src/test/cpp/examples/${example}/include
)
target_compile_definitions(${example}_test PUBLIC RUNNING_FRC_TESTS)
target_compile_definitions(Example_${example}_test PUBLIC RUNNING_FRC_TESTS)
target_link_libraries(
${example}_test
Example_${example}_test
apriltag
wpilibc
wpilibNewCommands
romiVendordep
xrpVendordep
googletest
)
add_dependencies(wpilibcExamples_test Example_${example}_test)
endif()
endforeach()

Expand All @@ -56,4 +61,5 @@ foreach(template ${TEMPLATES})
wpilib_target_warnings(${template})
target_include_directories(${template} PUBLIC src/main/cpp/templates/${template}/include)
target_link_libraries(${template} wpilibc wpilibNewCommands romiVendordep xrpVendordep)
add_dependencies(wpilibcExamples ${template})
endforeach()
Loading