mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[build] Fix CMake system library opt-ins (#4487)
-DUSE_SYSTEM_EIGEN now only removes include paths for Eigen instead of drake as well. The USE_VCPKG flags were renamed to USE_SYSTEM since they seem general enough for that to work (the find_package() commands work the same way on Arch). The system libuv CMake build now works with Linux libuv as well.
This commit is contained in:
@@ -64,10 +64,10 @@ option(WITH_SIMULATION_MODULES "Build simulation modules" ON)
|
||||
option(WITH_EXTERNAL_HAL "Use a separately built HAL" OFF)
|
||||
set(EXTERNAL_HAL_FILE "" CACHE FILEPATH "Location to look for an external HAL CMake File")
|
||||
|
||||
# Options for using a package manager (vcpkg) for certain dependencies.
|
||||
option(USE_VCPKG_FMTLIB "Use vcpkg fmtlib" OFF)
|
||||
option(USE_VCPKG_LIBUV "Use vcpkg libuv" OFF)
|
||||
option(USE_VCPKG_EIGEN "Use vcpkg eigen" OFF)
|
||||
# Options for using a package manager (e.g., vcpkg) for certain dependencies.
|
||||
option(USE_SYSTEM_FMTLIB "Use system fmtlib" OFF)
|
||||
option(USE_SYSTEM_LIBUV "Use system libuv" OFF)
|
||||
option(USE_SYSTEM_EIGEN "Use system eigen" OFF)
|
||||
|
||||
# Options for installation.
|
||||
option(WITH_FLAT_INSTALL "Use a flat install directory" OFF)
|
||||
@@ -165,12 +165,15 @@ else()
|
||||
set (wpilib_config_dir share/wpilib)
|
||||
endif()
|
||||
|
||||
if (USE_VCPKG_LIBUV)
|
||||
set (LIBUV_VCPKG_REPLACE "find_package(unofficial-libuv CONFIG)")
|
||||
if (USE_SYSTEM_LIBUV)
|
||||
set (LIBUV_SYSTEM_REPLACE "
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(libuv REQUIRED IMPORTED_TARGET libuv)
|
||||
")
|
||||
endif()
|
||||
|
||||
if (USE_VCPKG_EIGEN)
|
||||
set (EIGEN_VCPKG_REPLACE "find_package(Eigen3 CONFIG)")
|
||||
if (USE_SYSTEM_EIGEN)
|
||||
set (EIGEN_SYSTEM_REPLACE "find_package(Eigen3 CONFIG)")
|
||||
endif()
|
||||
|
||||
find_package(LIBSSH 0.7.1)
|
||||
|
||||
@@ -2,8 +2,8 @@ include(CMakeFindDependencyMacro)
|
||||
@FILENAME_DEP_REPLACE@
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_dependency(Threads)
|
||||
@LIBUV_VCPKG_REPLACE@
|
||||
@EIGEN_VCPKG_REPLACE@
|
||||
@LIBUV_SYSTEM_REPLACE@
|
||||
@EIGEN_SYSTEM_REPLACE@
|
||||
@WPIUTIL_DEP_REPLACE@
|
||||
@NTCORE_DEP_REPLACE@
|
||||
@CSCORE_DEP_REPLACE@
|
||||
|
||||
@@ -108,18 +108,20 @@ endif()
|
||||
wpilib_target_warnings(wpimath)
|
||||
target_link_libraries(wpimath wpiutil)
|
||||
|
||||
if (NOT USE_VCPKG_EIGEN)
|
||||
install(DIRECTORY src/main/native/thirdparty/drake/include/ DESTINATION "${include_dest}/wpimath")
|
||||
if (NOT USE_SYSTEM_EIGEN)
|
||||
install(DIRECTORY src/main/native/thirdparty/eigen/include/ DESTINATION "${include_dest}/wpimath")
|
||||
target_include_directories(wpimath SYSTEM PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/drake/include>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/eigen/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/wpimath>)
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/eigen/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/wpimath>)
|
||||
else()
|
||||
find_package(Eigen3 CONFIG REQUIRED)
|
||||
target_link_libraries (wpimath Eigen3::Eigen)
|
||||
endif()
|
||||
|
||||
install(DIRECTORY src/main/native/thirdparty/drake/include/ DESTINATION "${include_dest}/wpimath")
|
||||
target_include_directories(wpimath SYSTEM PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/drake/include>)
|
||||
|
||||
target_include_directories(wpimath PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
|
||||
$<INSTALL_INTERFACE:${include_dest}/wpimath>)
|
||||
|
||||
@@ -126,7 +126,7 @@ target_compile_features(wpinet PUBLIC cxx_std_20)
|
||||
wpilib_target_warnings(wpinet)
|
||||
target_link_libraries(wpinet PUBLIC wpiutil)
|
||||
|
||||
if (NOT USE_VCPKG_LIBUV)
|
||||
if (NOT USE_SYSTEM_LIBUV)
|
||||
target_sources(wpinet PRIVATE ${uv_native_src})
|
||||
install(DIRECTORY src/main/native/thirdparty/libuv/include/ DESTINATION "${include_dest}/wpinet")
|
||||
target_include_directories(wpinet PRIVATE
|
||||
@@ -149,8 +149,9 @@ if (NOT USE_VCPKG_LIBUV)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
find_package(unofficial-libuv CONFIG REQUIRED)
|
||||
target_link_libraries(wpinet unofficial::libuv::libuv)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(libuv REQUIRED IMPORTED_TARGET libuv)
|
||||
target_link_libraries(wpinet PUBLIC PkgConfig::libuv)
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
include(CMakeFindDependencyMacro)
|
||||
@FILENAME_DEP_REPLACE@
|
||||
@LIBUV_VCPKG_REPLACE@
|
||||
@LIBUV_SYSTEM_REPLACE@
|
||||
@WPIUTIL_DEP_REPLACE@
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
|
||||
@@ -118,7 +118,7 @@ if (ATOMIC)
|
||||
endif()
|
||||
|
||||
|
||||
if (NOT USE_VCPKG_FMTLIB)
|
||||
if (NOT USE_SYSTEM_FMTLIB)
|
||||
target_sources(wpiutil PRIVATE ${fmtlib_native_src})
|
||||
install(DIRECTORY src/main/native/thirdparty/fmtlib/include/ DESTINATION "${include_dest}/wpiutil")
|
||||
target_include_directories(wpiutil PUBLIC
|
||||
|
||||
@@ -2,7 +2,7 @@ include(CMakeFindDependencyMacro)
|
||||
@FILENAME_DEP_REPLACE@
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_dependency(Threads)
|
||||
@FMTLIB_VCPKG_REPLACE@
|
||||
@FMTLIB_SYSTEM_REPLACE@
|
||||
|
||||
@FILENAME_DEP_REPLACE@
|
||||
include(${SELF_DIR}/wpiutil.cmake)
|
||||
|
||||
Reference in New Issue
Block a user