Skip to content

Commit 968d5e8

Browse files
committed
Fix macos build without Eigen tests
1 parent 8e78fbf commit 968d5e8

File tree

2 files changed

+31
-15
lines changed

2 files changed

+31
-15
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ jobs:
5151
uses: actions/checkout@v4
5252
- name: Install dependencies
5353
run: |-
54-
brew install eigen catch2
54+
brew install cmake eigen catch2
5555
- name: Configure Cmake
5656
run: |-
57-
cmake ./ -B build -DCMAKE_BUILD_TYPE=Debug -DTINYOPT_BUILD_TESTS=ON -DTINYOPT_BUILD_DOCS=OFF
57+
cmake ./ -B build -DCMAKE_BUILD_TYPE=Debug \
58+
-DTINYOPT_BUILD_TESTS=ON \
59+
-DTINYOPT_BUILD_DOCS=OFF \
60+
-DCMAKE_PREFIX_PATH=$(brew --prefix) \
61+
-DEigen3_DIR=$(brew --prefix eigen)/share/eigen3/cmake
5862
- name: Build Tinyopt
5963
working-directory: build
6064
run: |-

cmake/ThirdParties.cmake

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@ set(THIRDPARTY_INCLUDE_DIRS "")
33

44
include(FetchContent)
55

6+
set(BUILD_TESTING_OLD ${BUILD_TESTING}) # Save your setting
7+
set(BUILD_TESTING OFF CACHE BOOL "" FORCE) # Disbale third party tests
8+
69
# For now, Eigen is mandatory
710
find_package(Eigen3 QUIET)
11+
812
if (EIGEN3_FOUND)
913
message("Eigen3 found at ${EIGEN3_INCLUDE_DIR}")
1014
else()
@@ -18,11 +22,11 @@ else()
1822
)
1923
block (SCOPE_FOR VARIABLES) # requires cmake 3.25+
2024
set(BUILD_TESTING OFF)
21-
set(EIGEN_BUILD_TESTING OFF)
22-
set(EIGEN_TEST_CXX11 OFF)
23-
set(EIGEN_HAS_CXX11_MATH ON)
25+
set(EIGEN_BUILD_TESTS OFF)
2426
set(EIGEN_BUILD_DOC OFF)
27+
set(EIGEN_BUILD_DEMOS OFF)
2528
set(EIGEN_BUILD_PKGCONFIG OFF)
29+
set(EIGEN_TEST_CXX11 OFF)
2630
FetchContent_MakeAvailable(Eigen)
2731
endblock ()
2832
set(EIGEN3_INCLUDE_DIR "${eigen3_SOURCE_DIR}" CACHE PATH "Eigen3 include directory" FORCE)
@@ -47,11 +51,13 @@ if (TINYOPT_BUILD_CERES)
4751
GIT_TAG 2.2.0
4852
GIT_SHALLOW TRUE
4953
GIT_PROGRESS TRUE)
50-
set(BUILD_TESTING OFF)
51-
set(BUILD_EXAMPLES OFF)
52-
set(BUILD_BENCHMARKS OFF)
53-
set(MINIGLOG ON)
54-
FetchContent_MakeAvailable(Ceres)
54+
block (SCOPE_FOR VARIABLES) # requires cmake 3.25+
55+
set(BUILD_TESTING OFF)
56+
set(BUILD_EXAMPLES OFF)
57+
set(BUILD_BENCHMARKS OFF)
58+
set(MINIGLOG ON)
59+
FetchContent_MakeAvailable(Ceres)
60+
endblock ()
5561
set(CERES_LIBRARIES Ceres::ceres)
5662
target_compile_options(ceres PUBLIC "-Wno-reorder" "-Wno-maybe-uninitialized")
5763
endif ()
@@ -74,8 +80,10 @@ if (TINYOPT_BUILD_SOPHUS_TEST)
7480
PATCH_COMMAND ${SOPHUS_FIX_CMAKE_VER}
7581
UPDATE_DISCONNECTED 1
7682
)
77-
set(BUILD_SOPHUS_TESTS OFF)
78-
FetchContent_MakeAvailable(Sophus)
83+
block (SCOPE_FOR VARIABLES) # requires cmake 3.25+
84+
set(BUILD_SOPHUS_TESTS OFF)
85+
FetchContent_MakeAvailable(Sophus)
86+
endblock ()
7987
endif ()
8088
add_definitions(-DHAS_SOPHUS)
8189
#include_directories(${Sophus_SOURCE_DIR}/sophus)
@@ -96,8 +104,10 @@ if (TINYOPT_BUILD_LIEPLUSPLUS_TEST)
96104
GIT_SHALLOW TRUE
97105
GIT_PROGRESS TRUE
98106
)
99-
set(LIEPLUSPLUS_TESTS OFF)
100-
FetchContent_MakeAvailable(LiePlusPlus)
107+
block (SCOPE_FOR VARIABLES) # requires cmake 3.25+
108+
set(LIEPLUSPLUS_TESTS OFF)
109+
FetchContent_MakeAvailable(LiePlusPlus)
110+
endblock ()
101111
endif ()
102112
add_definitions(-DHAS_LIEPLUSPLUS)
103113
#include_directories(${LiePlusPlus_SOURCE_DIR}/include)
@@ -132,4 +142,6 @@ if (TINYOPT_BUILD_TESTS OR TINYOPT_BUILD_BENCHMARKS)
132142
else ()
133143
add_definitions(-DCATCH2_VERSION=2)
134144
endif ()
135-
endif()
145+
endif()
146+
147+
set(BUILD_TESTING ${BUILD_TESTING_OLD} CACHE BOOL "" FORCE) # Restore testing config

0 commit comments

Comments
 (0)