Skip to content

Commit

Permalink
[build] Add exports to CMake subprojects (wpilibsuite#6505)
Browse files Browse the repository at this point in the history
This allows consuming allwpilib via FetchContent.
  • Loading branch information
calcmogul authored Apr 11, 2024
1 parent 2def62a commit 74f6486
Show file tree
Hide file tree
Showing 22 changed files with 35 additions and 0 deletions.
2 changes: 2 additions & 0 deletions apriltag/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ if(WITH_JAVA)
add_dependencies(apriltagjni apriltag_jar)

install(TARGETS apriltagjni EXPORT apriltagjni)
export(TARGETS apriltagjni FILE apriltagjni.cmake NAMESPACE apriltagjni::)
endif()

if(WITH_JAVA_SOURCE)
Expand Down Expand Up @@ -137,6 +138,7 @@ target_include_directories(
)

install(TARGETS apriltag EXPORT apriltag)
export(TARGETS apriltag FILE apriltag.cmake NAMESPACE apriltag::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/apriltag")

configure_file(apriltag-config.cmake.in ${WPILIB_BINARY_DIR}/apriltag-config.cmake)
Expand Down
1 change: 1 addition & 0 deletions cameraserver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ target_link_libraries(cameraserver PUBLIC ntcore cscore wpiutil ${OpenCV_LIBS})
set_property(TARGET cameraserver PROPERTY FOLDER "libraries")

install(TARGETS cameraserver EXPORT cameraserver)
export(TARGETS cameraserver FILE cameraserver.cmake NAMESPACE cameraserver::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cameraserver")

configure_file(cameraserver-config.cmake.in ${WPILIB_BINARY_DIR}/cameraserver-config.cmake)
Expand Down
2 changes: 2 additions & 0 deletions cscore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ target_link_libraries(cscore PUBLIC wpinet wpiutil ${OpenCV_LIBS})
set_property(TARGET cscore PROPERTY FOLDER "libraries")

install(TARGETS cscore EXPORT cscore)
export(TARGETS cscore FILE cscore.cmake NAMESPACE cscore::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cscore")

configure_file(cscore-config.cmake.in ${WPILIB_BINARY_DIR}/cscore-config.cmake)
Expand Down Expand Up @@ -163,6 +164,7 @@ if(WITH_JAVA)
add_dependencies(cscorejni cscore_jar)

install(TARGETS cscorejni EXPORT cscorejni)
export(TARGETS cscorejni FILE cscorejni.cmake NAMESPACE cscorejni::)
endif()

if(WITH_JAVA_SOURCE)
Expand Down
3 changes: 3 additions & 0 deletions fieldImages/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/fields>
)

install(TARGETS fieldImages EXPORT fieldimages)
export(TARGETS fieldImages FILE fieldimages.cmake NAMESPACE fieldimages::)
2 changes: 2 additions & 0 deletions glass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ target_include_directories(
)

install(TARGETS libglass EXPORT libglass)
export(TARGETS libglass FILE libglass.cmake NAMESPACE libglass::)
install(DIRECTORY src/lib/native/include/ DESTINATION "${include_dest}/glass")

#
Expand All @@ -50,6 +51,7 @@ target_include_directories(
)

install(TARGETS libglassnt EXPORT libglassnt)
export(TARGETS libglassnt FILE libglassnt.cmake NAMESPACE libglassnt::)
install(DIRECTORY src/libnt/native/include/ DESTINATION "${include_dest}/glass")

#
Expand Down
2 changes: 2 additions & 0 deletions hal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ target_link_libraries(hal PUBLIC wpiutil)
set_property(TARGET hal PROPERTY FOLDER "libraries")

install(TARGETS hal EXPORT hal)
export(TARGETS hal FILE hal.cmake NAMESPACE hal::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/hal")
install(DIRECTORY src/generated/main/native/include/ DESTINATION "${include_dest}/hal")

Expand Down Expand Up @@ -94,6 +95,7 @@ if(WITH_JAVA)
add_dependencies(haljni hal_jar)

install(TARGETS haljni EXPORT haljni)
export(TARGETS haljni FILE haljni.cmake NAMESPACE haljni::)
endif()

if(WITH_JAVA_SOURCE)
Expand Down
4 changes: 4 additions & 0 deletions imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if(NOT glfw3_POPULATED)
add_subdirectory(${glfw3_SOURCE_DIR} ${glfw3_BINARY_DIR} EXCLUDE_FROM_ALL)
set_property(TARGET glfw PROPERTY POSITION_INDEPENDENT_CODE ON)
set(BUILD_SHARED_LIBS ${SAVE_BUILD_SHARED_LIBS})
export(TARGETS glfw FILE glfw.cmake NAMESPACE glfw::)
endif()

# Don't use gl3w CMakeLists.txt due to https://github.com/skaslev/gl3w/issues/66
Expand Down Expand Up @@ -106,3 +107,6 @@ target_include_directories(

set_property(TARGET imgui PROPERTY POSITION_INDEPENDENT_CODE ON)
target_compile_features(imgui PUBLIC cxx_std_20)

install(TARGETS imgui EXPORT imgui)
export(TARGETS imgui FILE imgui.cmake NAMESPACE imgui::)
2 changes: 2 additions & 0 deletions ntcore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target_link_libraries(ntcore PUBLIC wpinet wpiutil)
set_property(TARGET ntcore PROPERTY FOLDER "libraries")

install(TARGETS ntcore EXPORT ntcore)
export(TARGETS ntcore FILE ntcore.cmake NAMESPACE ntcore::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/ntcore")
install(DIRECTORY src/generated/main/native/include/ DESTINATION "${include_dest}/ntcore")

Expand Down Expand Up @@ -77,6 +78,7 @@ if(WITH_JAVA)
add_dependencies(ntcorejni ntcore_jar)

install(TARGETS ntcorejni EXPORT ntcorejni)
export(TARGETS ntcorejni FILE ntcorejni.cmake NAMESPACE ntcorejni::)
endif()

if(WITH_JAVA_SOURCE)
Expand Down
1 change: 1 addition & 0 deletions romiVendordep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ target_include_directories(
)

install(TARGETS romiVendordep EXPORT romivendordep DESTINATION "${main_lib_dest}")
export(TARGETS romiVendordep FILE romivendordep.cmake NAMESPACE romivendordep::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/romiVendordep")

configure_file(romivendordep-config.cmake.in ${WPILIB_BINARY_DIR}/romivendordep-config.cmake)
Expand Down
1 change: 1 addition & 0 deletions simulation/halsim_ds_socket/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ target_include_directories(halsim_ds_socket PRIVATE src/main/native/include)
set_property(TARGET halsim_ds_socket PROPERTY FOLDER "libraries")

install(TARGETS halsim_ds_socket EXPORT halsim_ds_socket)
export(TARGETS halsim_ds_socket FILE halsim_ds_socket.cmake NAMESPACE halsim_ds_socket::)
1 change: 1 addition & 0 deletions simulation/halsim_gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ target_include_directories(halsim_gui PRIVATE src/main/native/include)
set_property(TARGET halsim_gui PROPERTY FOLDER "libraries")

install(TARGETS halsim_gui EXPORT halsim_gui)
export(TARGETS halsim_gui FILE halsim_gui.cmake NAMESPACE halsim_gui::)
1 change: 1 addition & 0 deletions simulation/halsim_ws_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ target_include_directories(halsim_ws_client PRIVATE src/main/native/include)
set_property(TARGET halsim_ws_client PROPERTY FOLDER "libraries")

install(TARGETS halsim_ws_client EXPORT halsim_ws_client)
export(TARGETS halsim_ws_client FILE halsim_ws_client.cmake NAMESPACE halsim_ws_client::)
1 change: 1 addition & 0 deletions simulation/halsim_ws_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ target_include_directories(halsim_ws_core PUBLIC src/main/native/include)
set_property(TARGET halsim_ws_core PROPERTY FOLDER "libraries")

install(TARGETS halsim_ws_core EXPORT halsim_ws_core)
export(TARGETS halsim_ws_core FILE halsim_ws_core.cmake NAMESPACE halsim_ws_core::)
1 change: 1 addition & 0 deletions simulation/halsim_ws_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ target_include_directories(halsim_ws_server PRIVATE src/main/native/include)
set_property(TARGET halsim_ws_server PROPERTY FOLDER "libraries")

install(TARGETS halsim_ws_server EXPORT halsim_ws_server)
export(TARGETS halsim_ws_server FILE halsim_ws_server.cmake NAMESPACE halsim_ws_server::)
1 change: 1 addition & 0 deletions simulation/halsim_xrp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ target_include_directories(halsim_xrp PRIVATE src/main/native/include)
set_property(TARGET halsim_xrp PROPERTY FOLDER "libraries")

install(TARGETS halsim_xrp EXPORT halsim_xrp DESTINATION "${main_lib_dest}")
export(TARGETS halsim_xrp FILE halsim_xrp.cmake NAMESPACE halsim_xrp::)
1 change: 1 addition & 0 deletions wpigui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ wpilib_target_warnings(wpiguidev)
target_link_libraries(wpiguidev wpigui)

install(TARGETS wpigui EXPORT wpigui)
export(TARGETS wpigui FILE wpigui.cmake NAMESPACE wpigui::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/wpigui")
1 change: 1 addition & 0 deletions wpilibNewCommands/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ target_include_directories(
)

install(TARGETS wpilibNewCommands EXPORT wpilibnewcommands)
export(TARGETS wpilibNewCommands FILE wpilibnewcommands.cmake NAMESPACE wpilibnewcommands::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/wpilibNewCommands")

configure_file(
Expand Down
1 change: 1 addition & 0 deletions wpilibc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ target_link_libraries(wpilibc PUBLIC hal ntcore wpimath wpiutil)
set_property(TARGET wpilibc PROPERTY FOLDER "libraries")

install(TARGETS wpilibc EXPORT wpilibc)
export(TARGETS wpilibc FILE wpilibc.cmake NAMESPACE wpilibc::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/wpilibc")

configure_file(wpilibc-config.cmake.in ${WPILIB_BINARY_DIR}/wpilibc-config.cmake)
Expand Down
2 changes: 2 additions & 0 deletions wpimath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ if(WITH_JAVA)
add_dependencies(wpimathjni wpimath_jar)

install(TARGETS wpimathjni EXPORT wpimathjni)
export(TARGETS wpimathjni FILE wpimathjni.cmake NAMESPACE wpimathjni::)
endif()

if(WITH_JAVA_SOURCE)
Expand Down Expand Up @@ -200,6 +201,7 @@ target_include_directories(
)

install(TARGETS wpimath EXPORT wpimath)
export(TARGETS wpimath FILE wpimath.cmake NAMESPACE wpimath::)

configure_file(wpimath-config.cmake.in ${WPILIB_BINARY_DIR}/wpimath-config.cmake)
install(FILES ${WPILIB_BINARY_DIR}/wpimath-config.cmake DESTINATION share/wpimath)
Expand Down
2 changes: 2 additions & 0 deletions wpinet/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if(WITH_JAVA)
add_dependencies(wpinetjni wpinet_jar)

install(TARGETS wpinetjni EXPORT wpinetjni)
export(TARGETS wpinetjni FILE wpinetjni.cmake NAMESPACE wpinetjni::)
endif()

if(WITH_JAVA_SOURCE)
Expand Down Expand Up @@ -196,6 +197,7 @@ target_include_directories(
)

install(TARGETS wpinet EXPORT wpinet)
export(TARGETS wpinet FILE wpinet.cmake NAMESPACE wpinet::)

configure_file(wpinet-config.cmake.in ${WPILIB_BINARY_DIR}/wpinet-config.cmake)
install(FILES ${WPILIB_BINARY_DIR}/wpinet-config.cmake DESTINATION share/wpinet)
Expand Down
2 changes: 2 additions & 0 deletions wpiutil/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ if(WITH_JAVA)
add_dependencies(wpiutiljni wpiutil_jar)

install(TARGETS wpiutiljni EXPORT wpiutiljni)
export(TARGETS wpiutiljni FILE wpiutiljni.cmake NAMESPACE wpiutiljni::)
endif()

if(WITH_JAVA_SOURCE)
Expand Down Expand Up @@ -258,6 +259,7 @@ target_include_directories(
)

install(TARGETS wpiutil EXPORT wpiutil)
export(TARGETS wpiutil FILE wpiutil.cmake NAMESPACE wpiutil::)

configure_file(wpiutil-config.cmake.in ${WPILIB_BINARY_DIR}/wpiutil-config.cmake)
install(FILES ${WPILIB_BINARY_DIR}/wpiutil-config.cmake DESTINATION share/wpiutil)
Expand Down
1 change: 1 addition & 0 deletions xrpVendordep/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ target_include_directories(
)

install(TARGETS xrpVendordep EXPORT xrpvendordep DESTINATION "${main_lib_dest}")
export(TARGETS xrpVendordep FILE xrpvendordep.cmake NAMESPACE xrpvendordep::)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/xrpVendordep")

configure_file(xrpvendordep-config.cmake.in ${WPILIB_BINARY_DIR}/xrpvendordep-config.cmake)
Expand Down

0 comments on commit 74f6486

Please sign in to comment.