Adds CMake Builds (#1015)

This commit is contained in:
Thad House
2018-05-02 21:15:30 -07:00
committed by Peter Johnson
parent 6a49173cea
commit 954f8c40f5
17 changed files with 540 additions and 0 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@
dependency-reduced-pom.xml
doxygen.log
buildcmake/
# Created by the jenkins test script
test-reports

91
CMakeLists.txt Normal file
View File

@@ -0,0 +1,91 @@
# Disable in-source builds to prevent source tree corruption.
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "
FATAL: In-source builds are not allowed.
You should create a separate directory for build files.
")
endif()
project(allwpilib)
cmake_minimum_required(VERSION 3.3.0)
INCLUDE(CPack)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND MSVC)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Default install dir on windows" FORCE)
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${CMAKE_BINARY_DIR}/jar)
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/wpilib/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/wpilib/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/wpilib/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
option(WITHOUT_JAVA "don't include java and JNI in the build" OFF)
option(BUILD_SHARED_LIBS "build with shared libs (needed for JNI)" ON)
option(WITHOUT_CSCORE "Don't build cscore (removes OpenCV requirement)" OFF)
option(WITHOUT_ALLWPILIB "Don't build allwpilib (removes OpenCV requirement)" ON)
option(USE_EXTERNAL_HAL "Use a separately built HAL" OFF)
set(EXTERNAL_HAL_FILE "" CACHE FILEPATH "Location to look for an external HAL CMake File")
if (NOT WITHOUT_JAVA AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "
FATAL: Cannot build static libs with Java enabled.
Static libs requires both BUILD_SHARED_LIBS=OFF and
WITHOUT_JAVA=ON
")
endif()
set( wpilib_dest wpilib)
set( include_dest wpilib/include )
set( main_lib_dest wpilib/lib )
set( java_lib_dest wpilib/java )
set( jni_lib_dest wpilib/jni )
if (MSVC)
set (wpilib_config_dir ${wpilib_dest})
else()
set (wpilib_config_dir share/wpilib)
endif()
add_subdirectory(wpiutil)
add_subdirectory(ntcore)
if (NOT WITHOUT_CSCORE)
add_subdirectory(cscore)
add_subdirectory(cameraserver)
set (CSCORE_DEP_REPLACE "find_dependency(cscore)")
set (CAMERASERVER_DEP_REPLACE "find_dependency(cameraserver)")
if (NOT WITHOUT_ALLWPILIB)
add_subdirectory(hal)
add_subdirectory(wpilibj)
add_subdirectory(wpilibc)
set (HAL_DEP_REPLACE "find_dependency(hal)")
set (WPILIBC_DEP_REPLACE "find_dependency(wpilibc)")
endif()
endif()
configure_file(wpilib-config.cmake.in ${CMAKE_BINARY_DIR}/wpilib-config.cmake )
install(FILES ${CMAKE_BINARY_DIR}/wpilib-config.cmake DESTINATION ${wpilib_config_dir})

View File

@@ -0,0 +1,52 @@
project(cameraserver)
find_package( OpenCV REQUIRED )
# Java bindings
if (NOT WITHOUT_JAVA)
find_package(Java REQUIRED)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint:unchecked")
#find java files, copy them locally
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/OpenCV/java/)
find_file(OPENCV_JAR_FILE NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar PATHS ${OPENCV_JAVA_INSTALL_DIR} ${OpenCV_INSTALL_PATH}/bin NO_DEFAULT_PATH)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(cameraserver_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar cscore_jar ntcore_jar ${OPENCV_JAR_FILE} OUTPUT_NAME cameraserver)
get_property(CAMERASERVER_JAR_FILE TARGET cameraserver_jar PROPERTY JAR_FILE)
install(FILES ${CAMERASERVER_JAR_FILE} DESTINATION "${java_lib_dest}")
set_property(TARGET cameraserver_jar PROPERTY FOLDER "java")
endif()
file(GLOB
cameraserver_native_src src/main/native/cpp/*.cpp)
add_library(cameraserver ${cameraserver_native_src})
target_include_directories(cameraserver PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/cameraserver>)
target_link_libraries(cameraserver PUBLIC ntcore cscore wpiutil ${OpenCV_LIBS})
set_property(TARGET cameraserver PROPERTY FOLDER "libraries")
install(TARGETS cameraserver EXPORT cameraserver DESTINATION "${main_lib_dest}")
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cameraserver")
if (NOT WITHOUT_JAVA AND MSVC)
install(TARGETS cameraserver RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
if (MSVC)
set (cameraserver_config_dir ${wpilib_dest})
else()
set (cameraserver_config_dir share/cameraserver)
endif()
install(FILES cameraserver-config.cmake DESTINATION ${cameraserver_config_dir})
install(EXPORT cameraserver DESTINATION ${cameraserver_config_dir})

View File

@@ -0,0 +1,8 @@
include(CMakeFindDependencyMacro)
find_dependency(wpiutil)
find_dependency(ntcore)
find_dependency(cscore)
find_dependency(OpenCV)
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/cameraserver.cmake)

87
cscore/CMakeLists.txt Normal file
View File

@@ -0,0 +1,87 @@
project(cscore)
find_package( OpenCV REQUIRED )
# Java bindings
if (NOT WITHOUT_JAVA)
find_package(Java REQUIRED)
find_package(JNI REQUIRED)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint:unchecked")
#find java files, copy them locally
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/OpenCV/java/)
find_file(OPENCV_JAR_FILE NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar PATHS ${OPENCV_JAVA_INSTALL_DIR} ${OpenCV_INSTALL_PATH}/bin NO_DEFAULT_PATH)
find_file(OPENCV_JNI_FILE NAMES libopencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.so
libopencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dylib
opencv_java${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll
PATHS ${OPENCV_JAVA_INSTALL_DIR} ${OpenCV_INSTALL_PATH}/bin ${OpenCV_INSTALL_PATH}/bin/Release ${OpenCV_INSTALL_PATH}/bin/Debug ${OpenCV_INSTALL_PATH}/lib NO_DEFAULT_PATH)
file(GLOB
cscore_jni_src src/main/native/cpp/jni/CameraServerJNI.cpp)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
set(CMAKE_JNI_TARGET true)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
set(CMAKE_JAVA_COMPILE_FLAGS "-h" "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
add_jar(cscore_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar ${OPENCV_JAR_FILE} OUTPUT_NAME cscore)
else()
add_jar(cscore_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar ${OPENCV_JAR_FILE} OUTPUT_NAME cscore GENERATE_NATIVE_HEADERS cscore_jni_headers)
endif()
get_property(CSCORE_JAR_FILE TARGET cscore_jar PROPERTY JAR_FILE)
install(FILES ${CSCORE_JAR_FILE} DESTINATION "${java_lib_dest}")
install(FILES ${OPENCV_JAR_FILE} DESTINATION "${java_lib_dest}")
if (MSVC)
install(FILES ${OPENCV_JNI_FILE} DESTINATION "${jni_lib_dest}")
foreach(cvFile ${OpenCV_LIBS})
find_file(${cvFile}Loc NAMES ${cvFile}${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.dll
PATHS ${OPENCV_JAVA_INSTALL_DIR} ${OpenCV_INSTALL_PATH}/bin ${OpenCV_INSTALL_PATH}/bin/Release ${OpenCV_INSTALL_PATH}/bin/Debug ${OpenCV_INSTALL_PATH}/lib NO_DEFAULT_PATH)
install(FILES ${${cvFile}Loc} DESTINATION "${jni_lib_dest}")
endforeach()
endif()
set_property(TARGET cscore_jar PROPERTY FOLDER "java")
endif()
file(GLOB
cscore_native_src src/main/native/cpp/*.cpp)
add_library(cscore ${cscore_native_src} ${cscore_jni_src})
target_include_directories(cscore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/cscore>)
target_link_libraries(cscore PUBLIC wpiutil ${OpenCV_LIBS})
set_property(TARGET cscore PROPERTY FOLDER "libraries")
if (NOT WITHOUT_JAVA)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
target_include_directories(cscore PRIVATE ${JNI_INCLUDE_DIRS})
target_include_directories(cscore PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
else()
target_link_libraries(cscore PRIVATE cscore_jni_headers)
endif()
add_dependencies(cscore cscore_jar)
endif()
install(TARGETS cscore EXPORT cscore DESTINATION "${main_lib_dest}")
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cscore")
if (NOT WITHOUT_JAVA AND MSVC)
install(TARGETS cscore RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
if (MSVC)
set (cscore_config_dir ${wpilib_dest})
else()
set (cscore_config_dir share/cscore)
endif()
install(FILES cscore-config.cmake DESTINATION ${cscore_config_dir})
install(EXPORT cscore DESTINATION ${cscore_config_dir})

View File

@@ -0,0 +1,6 @@
include(CMakeFindDependencyMacro)
find_dependency(wpiutil)
find_dependency(OpenCV)
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/cscore.cmake)

78
hal/CMakeLists.txt Normal file
View File

@@ -0,0 +1,78 @@
project(hal)
# Java bindings
if (NOT WITHOUT_JAVA)
find_package(Java REQUIRED)
find_package(JNI REQUIRED)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint:unchecked")
file(GLOB
hal_shared_jni_src src/main/native/cpp/jni/*.cpp
hal_sim_jni_src src/main/native/sim/jni/*.cpp)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
set(CMAKE_JNI_TARGET true)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
set(CMAKE_JAVA_COMPILE_FLAGS "-h" "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
add_jar(hal_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME wpiHal)
else()
add_jar(hal_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME wpiHal GENERATE_NATIVE_HEADERS hal_jni_headers)
endif()
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")
endif()
file(GLOB
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} ${hal_shared_jni_src})
if(USE_EXTERNAL_HAL)
include(${EXTERNAL_HAL_FILE})
else()
target_sources(hal PRIVATE ${hal_sim_native_src} ${hal_sim_jni_src})
endif()
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_link_libraries(hal PUBLIC wpiutil)
set_property(TARGET hal PROPERTY FOLDER "libraries")
if (NOT WITHOUT_JAVA)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
target_include_directories(hal PRIVATE ${JNI_INCLUDE_DIRS})
target_include_directories(hal PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
else()
target_link_libraries(hal PRIVATE hal_jni_headers)
endif()
add_dependencies(hal hal_jar)
endif()
install(TARGETS hal EXPORT hal DESTINATION "${main_lib_dest}")
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/hal")
if (NOT WITHOUT_JAVA AND MSVC)
install(TARGETS hal RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
if (MSVC)
set (hal_config_dir ${wpilib_dest})
else()
set (hal_config_dir share/hal)
endif()
install(FILES hal-config.cmake DESTINATION ${hal_config_dir})
install(EXPORT hal DESTINATION ${hal_config_dir})

5
hal/hal-config.cmake Normal file
View File

@@ -0,0 +1,5 @@
include(CMakeFindDependencyMacro)
find_dependency(wpiutil)
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/hal.cmake)

67
ntcore/CMakeLists.txt Normal file
View File

@@ -0,0 +1,67 @@
project(ntcore)
# Java bindings
if (NOT WITHOUT_JAVA)
find_package(Java REQUIRED)
find_package(JNI REQUIRED)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint:unchecked")
file(GLOB
ntcore_jni_src src/main/native/cpp/jni/NetworkTablesJNI.cpp)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
set(CMAKE_JNI_TARGET true)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
set(CMAKE_JAVA_COMPILE_FLAGS "-h" "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
add_jar(ntcore_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME ntcore)
else()
add_jar(ntcore_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME ntcore GENERATE_NATIVE_HEADERS ntcore_jni_headers)
endif()
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")
endif()
file(GLOB
ntcore_native_src src/main/native/cpp/*.cpp
ntcore_native_src src/main/native/cpp/networktables/*.cpp
ntcore_native_src src/main/native/cpp/tables/*.cpp)
add_library(ntcore ${ntcore_native_src} ${ntcore_jni_src})
target_include_directories(ntcore PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/ntcore>)
target_link_libraries(ntcore PUBLIC wpiutil)
set_property(TARGET ntcore PROPERTY FOLDER "libraries")
if (NOT WITHOUT_JAVA)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
target_include_directories(ntcore PRIVATE ${JNI_INCLUDE_DIRS})
target_include_directories(ntcore PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
else()
target_link_libraries(ntcore PRIVATE ntcore_jni_headers)
endif()
add_dependencies(ntcore ntcore_jar)
endif()
install(TARGETS ntcore EXPORT ntcore DESTINATION "${main_lib_dest}")
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/ntcore")
if (NOT WITHOUT_JAVA AND MSVC)
install(TARGETS ntcore RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
if (MSVC)
set (ntcore_config_dir ${wpilib_dest})
else()
set (ntcore_config_dir share/ntcore)
endif()
install(FILES ntcore-config.cmake DESTINATION ${ntcore_config_dir})
install(EXPORT ntcore DESTINATION ${ntcore_config_dir})

View File

@@ -0,0 +1,5 @@
include(CMakeFindDependencyMacro)
find_dependency(wpiutil)
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/ntcore.cmake)

9
wpilib-config.cmake.in Normal file
View File

@@ -0,0 +1,9 @@
include(CMakeFindDependencyMacro)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_dependency(Threads)
find_dependency(wpiutil)
find_dependency(ntcore)
@CSCORE_DEP_REPLACE@
@CAMERASERVER_DEP_REPLACE@
@HAL_DEP_REPLACE@
@WPILIBC_DEP_REPLACE@

29
wpilibc/CMakeLists.txt Normal file
View File

@@ -0,0 +1,29 @@
project(wpilibc)
find_package( OpenCV REQUIRED )
configure_file(src/generate/WPILibVersion.cpp.in WPILibVersion.cpp)
file(GLOB_RECURSE
wpilibc_native_src src/main/native/cpp/*.cpp)
add_library(wpilibc ${wpilibc_native_src} ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp)
target_include_directories(wpilibc PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/wpilibc>)
target_link_libraries(wpilibc PUBLIC cameraserver hal ntcore cscore wpiutil ${OpenCV_LIBS})
set_property(TARGET wpilibc PROPERTY FOLDER "libraries")
install(TARGETS wpilibc EXPORT wpilibc DESTINATION "${main_lib_dest}")
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/wpilibc")
if (MSVC)
set (wpilibc_config_dir ${wpilib_dest})
else()
set (wpilibc_config_dir share/wpilibc)
endif()
install(FILES wpilibc-config.cmake DESTINATION ${wpilibc_config_dir})
install(EXPORT wpilibc DESTINATION ${wpilibc_config_dir})

View File

@@ -0,0 +1,10 @@
include(CMakeFindDependencyMacro)
find_dependency(wpiutil)
find_dependency(ntcore)
find_dependency(cscore)
find_dependency(cameraserver)
find_dependency(hal)
find_dependency(OpenCV)
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/wpilibc.cmake)

33
wpilibj/CMakeLists.txt Normal file
View File

@@ -0,0 +1,33 @@
project (wpilibj)
find_package( OpenCV REQUIRED )
# Java bindings
if (NOT WITHOUT_JAVA)
find_package(Java REQUIRED)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint:unchecked")
set(OPENCV_JAVA_INSTALL_DIR ${OpenCV_INSTALL_PATH}/share/OpenCV/java/)
find_file(OPENCV_JAR_FILE NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar PATHS ${OPENCV_JAVA_INSTALL_DIR} ${OpenCV_INSTALL_PATH}/bin NO_DEFAULT_PATH)
configure_file(src/generate/WPILibVersion.java.in WPILibVersion.java)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(wpilibj_jar ${JAVA_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.java INCLUDE_JARS hal_jar ntcore_jar ${OPENCV_JAR_FILE} cscore_jar cameraserver_jar wpiutil_jar OUTPUT_NAME wpilibj)
get_property(WPILIBJ_JAR_FILE TARGET wpilibj_jar PROPERTY JAR_FILE)
install(FILES ${WPILIBJ_JAR_FILE} DESTINATION "${java_lib_dest}")
set_property(TARGET wpilibj_jar PROPERTY FOLDER "java")
if (MSVC)
set (wpilibj_config_dir ${wpilib_dest})
else()
set (wpilibj_config_dir share/wpilibj)
endif()
install(FILES wpilibj-config.cmake DESTINATION ${wpilibj_config_dir})
endif()

View File

@@ -0,0 +1,2 @@
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/wpilibj.cmake)

55
wpiutil/CMakeLists.txt Normal file
View File

@@ -0,0 +1,55 @@
project(wpiutil)
# Java bindings
if (NOT WITHOUT_JAVA)
find_package(Java)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-Xlint:unchecked")
set(CMAKE_JAVA_INCLUDE_PATH wpiutil.jar)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(wpiutil_jar ${JAVA_SOURCES} OUTPUT_NAME wpiutil)
get_property(WPIUTIL_JAR_FILE TARGET wpiutil_jar PROPERTY JAR_FILE)
install(FILES ${WPIUTIL_JAR_FILE} DESTINATION "${java_lib_dest}")
set_property(TARGET wpiutil_jar PROPERTY FOLDER "java")
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
file(GLOB_RECURSE wpiutil_native_src src/main/native/cpp/*.cpp)
add_library(wpiutil ${wpiutil_native_src})
set_property(TARGET wpiutil PROPERTY FOLDER "libraries")
if(NOT MSVC)
target_compile_options(wpiutil PUBLIC -std=c++14 -Wall -pedantic -Wextra -Wno-unused-parameter)
else()
target_compile_options(wpiutil PUBLIC -DNOMINMAX)
endif()
target_link_libraries(wpiutil Threads::Threads)
target_include_directories(wpiutil PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/wpiutil>)
install(TARGETS wpiutil EXPORT wpiutil DESTINATION "${main_lib_dest}")
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/wpiutil")
if (NOT WITHOUT_JAVA AND MSVC)
install(TARGETS wpiutil RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
if (MSVC)
set (wpiutil_config_dir ${wpilib_dest})
else()
set (wpiutil_config_dir share/wpiutil)
endif()
install(FILES wpiutil-config.cmake DESTINATION ${wpiutil_config_dir})
install(EXPORT wpiutil DESTINATION ${wpiutil_config_dir})

View File

@@ -0,0 +1,2 @@
get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${SELF_DIR}/wpiutil.cmake)