Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 1 | project(wpilibNewCommands) |
| 2 | |
| 3 | include(SubDirList) |
| 4 | include(CompileWarnings) |
| 5 | include(AddTest) |
| 6 | |
| 7 | if (WITH_JAVA) |
| 8 | find_package(Java REQUIRED) |
| 9 | include(UseJava) |
| 10 | set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked") |
| 11 | |
| 12 | file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java) |
| 13 | add_jar(wpilibNewCommands_jar ${JAVA_SOURCES} INCLUDE_JARS hal_jar ntcore_jar cscore_jar cameraserver_jar wpimath_jar wpiutil_jar wpilibj_jar OUTPUT_NAME wpilibNewCommands) |
| 14 | |
| 15 | get_property(WPILIBNEWCOMMANDS_JAR_FILE TARGET wpilibNewCommands_jar PROPERTY JAR_FILE) |
| 16 | install(FILES ${WPILIBNEWCOMMANDS_JAR_FILE} DESTINATION "${java_lib_dest}") |
| 17 | |
| 18 | set_property(TARGET wpilibNewCommands_jar PROPERTY FOLDER "java") |
| 19 | |
| 20 | if (WITH_FLAT_INSTALL) |
| 21 | set (wpilibNewCommands_config_dir ${wpilib_dest}) |
| 22 | else() |
| 23 | set (wpilibNewCommands_config_dir share/wpilibNewCommands) |
| 24 | endif() |
| 25 | |
| 26 | install(FILES wpilibNewCommands-config.cmake DESTINATION ${wpilibNewCommands_config_dir}) |
| 27 | endif() |
| 28 | |
| 29 | file(GLOB_RECURSE wpilibNewCommands_native_src src/main/native/cpp/*.cpp) |
| 30 | add_library(wpilibNewCommands ${wpilibNewCommands_native_src}) |
| 31 | set_target_properties(wpilibNewCommands PROPERTIES DEBUG_POSTFIX "d") |
| 32 | set_property(TARGET wpilibNewCommands PROPERTY FOLDER "libraries") |
| 33 | |
| 34 | target_compile_features(wpilibNewCommands PUBLIC cxx_std_17) |
| 35 | wpilib_target_warnings(wpilibNewCommands) |
| 36 | target_link_libraries(wpilibNewCommands wpilibc) |
| 37 | |
| 38 | target_include_directories(wpilibNewCommands PUBLIC |
| 39 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include> |
| 40 | $<INSTALL_INTERFACE:${include_dest}/wpilibNewCommands>) |
| 41 | |
| 42 | install(TARGETS wpilibNewCommands EXPORT wpilibNewCommands DESTINATION "${main_lib_dest}") |
| 43 | install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/wpilibNewCommands") |
| 44 | |
| 45 | if (MSVC OR FLAT_INSTALL_WPILIB) |
| 46 | set(wpilibNewCommands_config_dir ${wpilib_dest}) |
| 47 | else() |
| 48 | set(wpilibNewCommands_config_dir share/wpilibNewCommands) |
| 49 | endif() |
| 50 | |
| 51 | configure_file(wpilibNewCommands-config.cmake.in ${WPILIB_BINARY_DIR}/wpilibNewCommands-config.cmake) |
| 52 | install(FILES ${WPILIB_BINARY_DIR}/wpilibNewCommands-config.cmake DESTINATION ${wpilibNewCommands_config_dir}) |
| 53 | install(EXPORT wpilibNewCommands DESTINATION ${wpilibNewCommands_config_dir}) |
| 54 | |
| 55 | if (WITH_TESTS) |
| 56 | wpilib_add_test(wpilibNewCommands src/test/native/cpp) |
| 57 | target_include_directories(wpilibNewCommands_test PRIVATE src/test/native/include) |
| 58 | target_link_libraries(wpilibNewCommands_test wpilibNewCommands gmock_main) |
| 59 | endif() |