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) ```
123 lines
4.0 KiB
CMake
123 lines
4.0 KiB
CMake
project(hal)
|
|
|
|
include(CompileWarnings)
|
|
include(AddTest)
|
|
|
|
file(STRINGS src/generate/Instances.txt RAW_INSTANCES)
|
|
file(STRINGS src/generate/ResourceType.txt RAW_RESOURCE_TYPES)
|
|
|
|
SET(usage_reporting_types_cpp "")
|
|
SET(usage_reporting_instances_cpp "")
|
|
SET(usage_reporting_types "")
|
|
SET(usage_reporting_instances "")
|
|
|
|
foreach(ITEM ${RAW_INSTANCES})
|
|
list(APPEND usage_reporting_instances_cpp " ${ITEM},")
|
|
list(APPEND usage_reporting_instances "\n public static final int ${ITEM};")
|
|
endforeach()
|
|
|
|
foreach(ITEM ${RAW_RESOURCE_TYPES})
|
|
list(APPEND usage_reporting_types_cpp " ${ITEM},")
|
|
list(APPEND usage_reporting_types "\n public static final int ${ITEM};")
|
|
endforeach()
|
|
|
|
string(REPLACE ";" "\n" usage_reporting_types_cpp "${usage_reporting_types_cpp}")
|
|
string(REPLACE ";" "\n" usage_reporting_instances_cpp "${usage_reporting_instances_cpp}")
|
|
|
|
file(GLOB
|
|
hal_shared_native_src src/main/native/cpp/*.cpp
|
|
hal_shared_native_src src/main/native/cpp/cpp/*.cpp
|
|
hal_shared_native_src src/main/native/cpp/handles/*.cpp
|
|
hal_sim_native_src src/main/native/sim/*.cpp
|
|
hal_sim_native_src src/main/native/sim/mockdata/*.cpp)
|
|
add_library(hal ${hal_shared_native_src})
|
|
wpilib_target_warnings(hal)
|
|
set_target_properties(hal PROPERTIES DEBUG_POSTFIX "d")
|
|
|
|
if(USE_EXTERNAL_HAL)
|
|
include(${EXTERNAL_HAL_FILE})
|
|
else()
|
|
target_sources(hal PRIVATE ${hal_sim_native_src})
|
|
endif()
|
|
|
|
configure_file(src/generate/FRCUsageReporting.h.in gen/hal/FRCUsageReporting.h)
|
|
|
|
set_target_properties(hal PROPERTIES OUTPUT_NAME "wpiHal")
|
|
|
|
target_include_directories(hal PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
|
$<INSTALL_INTERFACE:${include_dest}/hal>)
|
|
|
|
target_include_directories(hal PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/gen>
|
|
$<INSTALL_INTERFACE:${include_dest}/hal>)
|
|
target_link_libraries(hal PUBLIC wpiutil)
|
|
|
|
set_property(TARGET hal PROPERTY FOLDER "libraries")
|
|
|
|
install(TARGETS hal EXPORT hal DESTINATION "${main_lib_dest}")
|
|
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/hal")
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen/ DESTINATION "${include_dest}/hal")
|
|
|
|
if (WITH_FLAT_INSTALL)
|
|
set (hal_config_dir ${wpilib_dest})
|
|
else()
|
|
set (hal_config_dir share/hal)
|
|
endif()
|
|
|
|
configure_file(hal-config.cmake.in ${WPILIB_BINARY_DIR}/hal-config.cmake )
|
|
install(FILES ${WPILIB_BINARY_DIR}/hal-config.cmake DESTINATION ${hal_config_dir})
|
|
install(EXPORT hal DESTINATION ${hal_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")
|
|
|
|
configure_file(src/generate/FRCNetComm.java.in FRCNetComm.java)
|
|
|
|
file(GLOB_RECURSE hal_shared_jni_src src/main/native/cpp/jni/*.cpp)
|
|
|
|
file(GLOB_RECURSE JAVA_SOURCES
|
|
${CMAKE_CURRENT_BINARY_DIR}/FRCNetComm.java
|
|
src/main/java/*.java)
|
|
set(CMAKE_JNI_TARGET true)
|
|
|
|
add_jar(hal_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME wpiHal GENERATE_NATIVE_HEADERS hal_jni_headers)
|
|
|
|
get_property(HAL_JAR_FILE TARGET hal_jar PROPERTY JAR_FILE)
|
|
install(FILES ${HAL_JAR_FILE} DESTINATION "${java_lib_dest}")
|
|
|
|
set_property(TARGET hal_jar PROPERTY FOLDER "java")
|
|
|
|
add_library(haljni ${hal_shared_jni_src})
|
|
|
|
if(USE_EXTERNAL_HAL)
|
|
include(${EXTERNAL_HAL_FILE})
|
|
endif()
|
|
|
|
set_target_properties(haljni PROPERTIES OUTPUT_NAME "wpiHaljni")
|
|
|
|
wpilib_target_warnings(haljni)
|
|
target_link_libraries(haljni PUBLIC hal wpiutil)
|
|
|
|
set_property(TARGET haljni PROPERTY FOLDER "libraries")
|
|
|
|
target_link_libraries(haljni PRIVATE hal_jni_headers)
|
|
add_dependencies(haljni hal_jar)
|
|
|
|
if (MSVC)
|
|
install(TARGETS haljni RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
|
|
endif()
|
|
|
|
install(TARGETS haljni EXPORT haljni DESTINATION "${main_lib_dest}")
|
|
|
|
endif()
|
|
|
|
if (WITH_TESTS)
|
|
wpilib_add_test(hal src/test/native/cpp)
|
|
target_link_libraries(hal_test hal gtest)
|
|
endif()
|