mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
FetchContent requires CMake 3.11 (released Mar 28, 2018). Fixed this warning: ``` CMake Warning (dev) at /usr/share/cmake/Modules/FetchContent.cmake:1316 (message): The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is not set. The policy's OLD behavior will be used. When using a URL download, the timestamps of extracted files should preferably be that of the time of extraction, otherwise code that depends on the extracted contents might not be rebuilt if the URL changes. The OLD behavior preserves the timestamps from the archive instead, but this is usually not what you want. Update your project to the NEW behavior or specify the DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this robustness issue. Call Stack (most recent call first): imgui/CMakeLists.txt:23 (FetchContent_Declare) ```
96 lines
3.6 KiB
CMake
96 lines
3.6 KiB
CMake
project(ntcore)
|
|
|
|
include(CompileWarnings)
|
|
include(AddTest)
|
|
|
|
execute_process(COMMAND python3 ${CMAKE_CURRENT_SOURCE_DIR}/generate_topics.py ${WPILIB_BINARY_DIR}/ntcore RESULT_VARIABLE generateResult)
|
|
if(NOT (generateResult EQUAL "0"))
|
|
# Try python
|
|
execute_process(COMMAND python ${CMAKE_CURRENT_SOURCE_DIR}/generate_topics.py ${WPILIB_BINARY_DIR}/ntcore RESULT_VARIABLE generateResult)
|
|
if(NOT (generateResult EQUAL "0"))
|
|
message(FATAL_ERROR "python and python3 generate_topics.py failed")
|
|
endif()
|
|
endif()
|
|
|
|
file(GLOB ntcore_native_src
|
|
src/main/native/cpp/*.cpp
|
|
${WPILIB_BINARY_DIR}/ntcore/generated/main/native/cpp/*.cpp
|
|
src/main/native/cpp/net/*.cpp
|
|
src/main/native/cpp/net3/*.cpp
|
|
src/main/native/cpp/networktables/*.cpp
|
|
src/main/native/cpp/tables/*.cpp)
|
|
add_library(ntcore ${ntcore_native_src})
|
|
set_target_properties(ntcore PROPERTIES DEBUG_POSTFIX "d")
|
|
target_include_directories(ntcore
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/cpp
|
|
PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
|
$<BUILD_INTERFACE:${WPILIB_BINARY_DIR}/ntcore/generated/main/native/include>
|
|
$<INSTALL_INTERFACE:${include_dest}/ntcore>)
|
|
wpilib_target_warnings(ntcore)
|
|
target_compile_features(ntcore PUBLIC cxx_std_20)
|
|
target_link_libraries(ntcore PUBLIC wpinet wpiutil)
|
|
|
|
set_property(TARGET ntcore PROPERTY FOLDER "libraries")
|
|
|
|
install(TARGETS ntcore EXPORT ntcore DESTINATION "${main_lib_dest}")
|
|
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/ntcore")
|
|
install(DIRECTORY ${WPILIB_BINARY_DIR}/ntcore/generated/main/native/include/ DESTINATION "${include_dest}/ntcore")
|
|
|
|
if (WITH_FLAT_INSTALL)
|
|
set (ntcore_config_dir ${wpilib_dest})
|
|
else()
|
|
set (ntcore_config_dir share/ntcore)
|
|
endif()
|
|
|
|
configure_file(ntcore-config.cmake.in ${WPILIB_BINARY_DIR}/ntcore-config.cmake )
|
|
install(FILES ${WPILIB_BINARY_DIR}/ntcore-config.cmake DESTINATION ${ntcore_config_dir})
|
|
install(EXPORT ntcore DESTINATION ${ntcore_config_dir})
|
|
|
|
# Java bindings
|
|
if (WITH_JAVA)
|
|
find_package(Java REQUIRED)
|
|
find_package(JNI REQUIRED)
|
|
include(UseJava)
|
|
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked")
|
|
|
|
file(GLOB ntcore_jni_src
|
|
src/main/native/cpp/jni/*.cpp
|
|
${WPILIB_BINARY_DIR}/ntcore/generated/main/native/cpp/jni/*.cpp)
|
|
|
|
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java ${WPILIB_BINARY_DIR}/ntcore/generated/*.java)
|
|
set(CMAKE_JNI_TARGET true)
|
|
|
|
add_jar(ntcore_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME ntcore GENERATE_NATIVE_HEADERS ntcore_jni_headers)
|
|
|
|
get_property(NTCORE_JAR_FILE TARGET ntcore_jar PROPERTY JAR_FILE)
|
|
install(FILES ${NTCORE_JAR_FILE} DESTINATION "${java_lib_dest}")
|
|
|
|
set_property(TARGET ntcore_jar PROPERTY FOLDER "java")
|
|
|
|
add_library(ntcorejni ${ntcore_jni_src})
|
|
wpilib_target_warnings(ntcorejni)
|
|
target_link_libraries(ntcorejni PUBLIC ntcore wpiutil)
|
|
|
|
set_property(TARGET ntcorejni PROPERTY FOLDER "libraries")
|
|
|
|
if (MSVC)
|
|
install(TARGETS ntcorejni RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
|
|
endif()
|
|
|
|
target_link_libraries(ntcorejni PRIVATE ntcore_jni_headers)
|
|
add_dependencies(ntcorejni ntcore_jar)
|
|
|
|
install(TARGETS ntcorejni EXPORT ntcorejni DESTINATION "${main_lib_dest}")
|
|
|
|
endif()
|
|
|
|
add_executable(ntcoredev src/dev/native/cpp/main.cpp)
|
|
target_link_libraries(ntcoredev ntcore)
|
|
|
|
if (WITH_TESTS)
|
|
wpilib_add_test(ntcore src/test/native/cpp)
|
|
target_include_directories(ntcore_test PRIVATE src/main/native/cpp)
|
|
target_link_libraries(ntcore_test ntcore gmock_main)
|
|
endif()
|