diff --git a/CMakeLists.txt b/CMakeLists.txt index 4357e5f66c..4a80d36153 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/wpilibc/CMakeLists.txt b/wpilibc/CMakeLists.txt index d5a0102117..4c8dfde5fb 100644 --- a/wpilibc/CMakeLists.txt +++ b/wpilibc/CMakeLists.txt @@ -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 $ $) 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() diff --git a/wpilibj/CMakeLists.txt b/wpilibj/CMakeLists.txt index 5d4e4edee3..cff7f22b2e 100644 --- a/wpilibj/CMakeLists.txt +++ b/wpilibj/CMakeLists.txt @@ -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")