mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-28 02:11:43 +00:00
[build] Add CMake option to use system Sleipnir install (#9028)
This allows using an alternate version from FetchContent.
This commit is contained in:
@@ -84,9 +84,10 @@ option(WITH_SIMULATION_MODULES "Build simulation modules" ON)
|
||||
option(WITH_BENCHMARK "Build the benchmark project" ON)
|
||||
|
||||
# Options for using a package manager (e.g., vcpkg) for certain dependencies.
|
||||
option(USE_SYSTEM_EIGEN "Use system Eigen" OFF)
|
||||
option(USE_SYSTEM_FMTLIB "Use system fmtlib" OFF)
|
||||
option(USE_SYSTEM_LIBUV "Use system libuv" OFF)
|
||||
option(USE_SYSTEM_EIGEN "Use system eigen" OFF)
|
||||
option(USE_SYSTEM_SLEIPNIR "Use system Sleipnir" OFF)
|
||||
option(USE_LINKED_AVAHI "Use directly linked Avahi instead of loading at runtime" OFF)
|
||||
|
||||
# Options for compilation flags.
|
||||
|
||||
@@ -20,13 +20,11 @@ file(
|
||||
src/main/native/cpp/jni/optimization/ProblemJNI.cpp
|
||||
)
|
||||
|
||||
file(
|
||||
GLOB_RECURSE wpimath_native_src
|
||||
src/main/native/cpp/*.cpp
|
||||
src/main/native/thirdparty/sleipnir/src/*.cpp
|
||||
)
|
||||
file(GLOB_RECURSE wpimath_native_src src/main/native/cpp/*.cpp)
|
||||
list(REMOVE_ITEM wpimath_native_src ${wpimath_jni_src})
|
||||
|
||||
file(GLOB_RECURSE sleipnir_native_src src/main/native/thirdparty/sleipnir/src/*.cpp)
|
||||
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE)
|
||||
|
||||
file(GLOB_RECURSE wpimath_protobuf_native_src src/generated/main/native/cpp/wpimath/protobuf/*.cpp)
|
||||
@@ -86,19 +84,38 @@ else()
|
||||
target_link_libraries(wpimath Eigen3::Eigen)
|
||||
endif()
|
||||
|
||||
install(
|
||||
DIRECTORY src/main/native/thirdparty/gcem/include/ src/main/native/thirdparty/sleipnir/include/
|
||||
DESTINATION "${include_dest}/wpimath"
|
||||
)
|
||||
install(DIRECTORY src/main/native/thirdparty/gcem/include/ DESTINATION "${include_dest}/wpimath")
|
||||
target_include_directories(
|
||||
wpimath
|
||||
SYSTEM
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/gcem/include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/sleipnir/include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/sleipnir/src>
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/gcem/include>
|
||||
)
|
||||
|
||||
if(NOT USE_SYSTEM_SLEIPNIR)
|
||||
target_sources(wpimath PRIVATE ${sleipnir_native_src})
|
||||
install(
|
||||
DIRECTORY src/main/native/thirdparty/sleipnir/include/
|
||||
DESTINATION "${include_dest}/wpimath"
|
||||
)
|
||||
target_include_directories(
|
||||
wpimath
|
||||
SYSTEM
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/sleipnir/include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/sleipnir/src>
|
||||
)
|
||||
else()
|
||||
find_package(Sleipnir CONFIG REQUIRED)
|
||||
target_link_libraries(wpimath Sleipnir::Sleipnir)
|
||||
if(MSVC)
|
||||
get_target_property(Sleipnir_includes Sleipnir::Sleipnir INTERFACE_INCLUDE_DIRECTORIES)
|
||||
foreach(dir ${Sleipnir_includes})
|
||||
target_compile_options(wpimath PUBLIC /external:I "${dir}")
|
||||
endforeach()
|
||||
target_compile_options(wpimath PUBLIC /external:W0)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
install(
|
||||
DIRECTORY src/generated/main/native/cpp/
|
||||
DESTINATION "${include_dest}/wpimath"
|
||||
|
||||
@@ -6,5 +6,9 @@ if(@USE_SYSTEM_EIGEN@)
|
||||
find_dependency(Eigen3)
|
||||
endif()
|
||||
|
||||
if(@USE_SYSTEM_SLEIPNIR@)
|
||||
find_dependency(Sleipnir)
|
||||
endif()
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/wpimath.cmake)
|
||||
|
||||
Reference in New Issue
Block a user