blob: d44939f8748d3dc428c78c7ecf3c50ba81962387 [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001project(wpilibNewCommands)
2
3include(SubDirList)
4include(CompileWarnings)
5include(AddTest)
6
7if (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})
27endif()
28
29file(GLOB_RECURSE wpilibNewCommands_native_src src/main/native/cpp/*.cpp)
30add_library(wpilibNewCommands ${wpilibNewCommands_native_src})
31set_target_properties(wpilibNewCommands PROPERTIES DEBUG_POSTFIX "d")
32set_property(TARGET wpilibNewCommands PROPERTY FOLDER "libraries")
33
34target_compile_features(wpilibNewCommands PUBLIC cxx_std_17)
35wpilib_target_warnings(wpilibNewCommands)
36target_link_libraries(wpilibNewCommands wpilibc)
37
38target_include_directories(wpilibNewCommands PUBLIC
39 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
40 $<INSTALL_INTERFACE:${include_dest}/wpilibNewCommands>)
41
42install(TARGETS wpilibNewCommands EXPORT wpilibNewCommands DESTINATION "${main_lib_dest}")
43install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/wpilibNewCommands")
44
45if (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()