[build] Clean up CMake files (#6802)

Explicitly list required components when using FindJava and FindJNI
Consolidate find_package calls for Java, JNI, and OpenCV into the root CMakeLists.txt file
Remove references to main_lib_dest
Install missing generated headers
Flatten some if statements
Use LinkMacOSGUI macro instead of hand rolling it
Stop installing OpenCV libraries and an extra ntcorejni library; OpenCV JAR will still be installed to make it easy to use
Only print platform version on Windows
Prevent GUI modules from being built when wpimath is off, which would otherwise cause a build failure
Simplify build configuration checks
Clean up fieldImages JAR creation
Place built JARs in the same subdir as installed JARs
Remove unnecessary JAR includes
Remove extra directories in target_include_directories
Improve CMake docs
This commit is contained in:
Gold856
2024-07-11 18:01:05 -04:00
committed by GitHub
parent 27a2e02b52
commit bf75c03218
21 changed files with 132 additions and 253 deletions

View File

@@ -5,7 +5,6 @@ include(CompileWarnings)
include(AddTest)
if(WITH_JAVA)
find_package(Java REQUIRED)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
@@ -24,6 +23,7 @@ if(WITH_JAVA)
wpiutil_jar
wpilibj_jar
OUTPUT_NAME wpilibNewCommands
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpilibNewCommands_jar PROPERTY FOLDER "java")
@@ -36,7 +36,6 @@ if(WITH_JAVA)
endif()
if(WITH_JAVA_SOURCE)
find_package(Java REQUIRED)
include(UseJava)
file(GLOB WPILIBNEWCOMMANDS_SOURCES src/main/java/edu/wpi/first/wpilibj2/command/*.java)
file(
@@ -50,6 +49,7 @@ if(WITH_JAVA_SOURCE)
NAMESPACE "edu/wpi/first/wpilibj2/command" ${WPILIBNEWCOMMANDS_SOURCES}
NAMESPACE "edu/wpi/first/wpilibj2/command/button" ${WPILIBNEWCOMMANDS_BUTTON_SOURCES}
OUTPUT_NAME wpilibNewCommands-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
get_property(WPILIBNEWCOMMANDS_SRC_JAR_FILE TARGET wpilibNewCommands_src_jar PROPERTY JAR_FILE)
@@ -82,6 +82,10 @@ 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")
install(
DIRECTORY src/generated/main/native/include/
DESTINATION "${include_dest}/wpilibNewCommands"
)
configure_file(
wpilibnewcommands-config.cmake.in