Files
allwpilib/wpilibNewCommands/CMakeLists.txt
Gold856 bf75c03218 [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
2024-07-11 16:01:05 -06:00

105 lines
3.6 KiB
CMake

project(wpilibNewCommands)
include(SubDirList)
include(CompileWarnings)
include(AddTest)
if(WITH_JAVA)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java src/generated/main/java/*.java)
file(GLOB JACKSON_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/jackson/*.jar")
add_jar(
wpilibNewCommands_jar
${JAVA_SOURCES}
INCLUDE_JARS
hal_jar
ntcore_jar
${JACKSON_JARS}
cscore_jar
cameraserver_jar
wpimath_jar
wpiunits_jar
wpiutil_jar
wpilibj_jar
OUTPUT_NAME wpilibNewCommands
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET wpilibNewCommands_jar PROPERTY FOLDER "java")
install_jar(wpilibNewCommands_jar DESTINATION ${java_lib_dest})
install_jar_exports(
TARGETS wpilibNewCommands_jar
FILE wpilibNewCommands_jar.cmake
DESTINATION share/wpilibNewCommands
)
endif()
if(WITH_JAVA_SOURCE)
include(UseJava)
file(GLOB WPILIBNEWCOMMANDS_SOURCES src/main/java/edu/wpi/first/wpilibj2/command/*.java)
file(
GLOB WPILIBNEWCOMMANDS_BUTTON_SOURCES
src/main/java/edu/wpi/first/wpilibj2/command/button/*.java
src/generated/main/java/edu/wpi/first/wpilibj2/command/button/*.java
)
add_jar(
wpilibNewCommands_src_jar
RESOURCES
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)
install(FILES ${WPILIBNEWCOMMANDS_SRC_JAR_FILE} DESTINATION "${java_lib_dest}")
set_property(TARGET wpilibNewCommands_src_jar PROPERTY FOLDER "java")
endif()
file(
GLOB_RECURSE wpilibNewCommands_native_src
src/main/native/cpp/*.cpp
src/generated/main/native/cpp/*.cpp
)
add_library(wpilibNewCommands ${wpilibNewCommands_native_src})
set_target_properties(wpilibNewCommands PROPERTIES DEBUG_POSTFIX "d")
set_property(TARGET wpilibNewCommands PROPERTY FOLDER "libraries")
target_compile_features(wpilibNewCommands PUBLIC cxx_std_20)
wpilib_target_warnings(wpilibNewCommands)
target_link_libraries(wpilibNewCommands wpilibc)
target_include_directories(
wpilibNewCommands
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/generated/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/wpilibNewCommands>
)
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
${WPILIB_BINARY_DIR}/wpilibnewcommands-config.cmake
)
install(
FILES ${WPILIB_BINARY_DIR}/wpilibnewcommands-config.cmake
DESTINATION share/wpilibNewCommands
)
install(EXPORT wpilibnewcommands DESTINATION share/wpilibNewCommands)
if(WITH_TESTS)
wpilib_add_test(wpilibNewCommands src/test/native/cpp)
target_include_directories(wpilibNewCommands_test PRIVATE src/test/native/include)
target_link_libraries(wpilibNewCommands_test wpilibNewCommands gmock_main)
endif()