mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[build] Allow building wpilibc in cmake without cscore and opencv (#3605)
The hard dependency on cscore was removed a while ago in gradle, so make it not a hard requirement in cmake.
This commit is contained in:
@@ -270,19 +270,20 @@ if (WITH_CSCORE)
|
||||
set(CAMERASERVER_DEP_REPLACE ${CAMERASERVER_DEP_REPLACE_IMPL})
|
||||
add_subdirectory(cscore)
|
||||
add_subdirectory(cameraserver)
|
||||
if (WITH_WPILIB)
|
||||
set(WPILIBC_DEP_REPLACE ${WPILIBC_DEP_REPLACE_IMPL})
|
||||
add_subdirectory(wpilibj)
|
||||
add_subdirectory(wpilibc)
|
||||
add_subdirectory(wpilibNewCommands)
|
||||
if (WITH_OLD_COMMANDS)
|
||||
add_subdirectory(wpilibOldCommands)
|
||||
endif()
|
||||
if (WITH_EXAMPLES)
|
||||
add_subdirectory(wpilibcExamples)
|
||||
endif()
|
||||
add_subdirectory(myRobot)
|
||||
endif()
|
||||
|
||||
if (WITH_WPILIB)
|
||||
set(WPILIBC_DEP_REPLACE ${WPILIBC_DEP_REPLACE_IMPL})
|
||||
add_subdirectory(wpilibj)
|
||||
add_subdirectory(wpilibc)
|
||||
add_subdirectory(wpilibNewCommands)
|
||||
if (WITH_OLD_COMMANDS)
|
||||
add_subdirectory(wpilibOldCommands)
|
||||
endif()
|
||||
if (WITH_EXAMPLES)
|
||||
add_subdirectory(wpilibcExamples)
|
||||
endif()
|
||||
add_subdirectory(myRobot)
|
||||
endif()
|
||||
|
||||
if (WITH_SIMULATION_MODULES AND NOT WITH_EXTERNAL_HAL)
|
||||
|
||||
@@ -3,8 +3,6 @@ project(wpilibc)
|
||||
include(CompileWarnings)
|
||||
include(AddTest)
|
||||
|
||||
find_package( OpenCV REQUIRED )
|
||||
|
||||
configure_file(src/generate/WPILibVersion.cpp.in WPILibVersion.cpp)
|
||||
|
||||
file(GLOB_RECURSE
|
||||
@@ -17,7 +15,18 @@ target_include_directories(wpilibc PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/wpilibc>)
|
||||
wpilib_target_warnings(wpilibc)
|
||||
target_link_libraries(wpilibc PUBLIC cameraserver hal ntcore cscore wpimath wpiutil ${OpenCV_LIBS})
|
||||
|
||||
if (WITH_CSCORE)
|
||||
find_package( OpenCV )
|
||||
target_link_libraries(wpilibc PUBLIC cameraserver cscore ${OpenCV_LIBS})
|
||||
else()
|
||||
target_compile_definitions(wpilibc PRIVATE DYNAMIC_CAMERA_SERVER)
|
||||
# Add just the camera server include directory
|
||||
target_include_directories(wpilibc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../cameraserver/src/main/native/include)
|
||||
endif()
|
||||
|
||||
target_link_libraries(wpilibc PUBLIC hal ntcore wpimath wpiutil)
|
||||
|
||||
|
||||
set_property(TARGET wpilibc PROPERTY FOLDER "libraries")
|
||||
|
||||
@@ -43,4 +52,9 @@ if (WITH_TESTS)
|
||||
else()
|
||||
target_compile_options(wpilibc_test PRIVATE /WX-)
|
||||
endif()
|
||||
if (NOT WITH_CSCORE)
|
||||
target_compile_definitions(wpilibc_test PRIVATE DYNAMIC_CAMERA_SERVER)
|
||||
# Add just the camera server include directory
|
||||
target_include_directories(wpilibc_test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../cameraserver/src/main/native/include)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
project (wpilibj)
|
||||
|
||||
find_package( OpenCV REQUIRED )
|
||||
|
||||
# Java bindings
|
||||
if (WITH_JAVA)
|
||||
find_package( OpenCV REQUIRED )
|
||||
find_package(Java REQUIRED)
|
||||
include(UseJava)
|
||||
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked")
|
||||
|
||||
Reference in New Issue
Block a user