Skip to content

Commit 6974ccd

Browse files
authored
cmake: Simplify FetchContent builds (#114)
1 parent 0ce3af3 commit 6974ccd

File tree

10 files changed

+29
-71
lines changed

10 files changed

+29
-71
lines changed

.github/workflows/build_packages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
env:
1919
MACOSX_DEPLOYMENT_TARGET: "14.5"
2020
QT_VERSION: "6.7.2"
21-
EXTRA_CMAKE_FLAGS: "-DCMAKE_BUILD_TYPE=Release -DVC_PREBUILT_LIBS=ON -DVC_BUILD_ACVD=ON -DCMAKE_OSX_ARCHITECTURES:STRING='x86_64;arm64'"
21+
EXTRA_CMAKE_FLAGS: "-DCMAKE_BUILD_TYPE=Release -DVC_PREBUILT_LIBS=ON -DVC_BUILD_ACVD=ON -DVC_BUILD_JSON=OFF -DCMAKE_OSX_ARCHITECTURES:STRING='x86_64;arm64'"
2222
steps:
2323
- name: Checkout code
2424
uses: actions/checkout@v4

.github/workflows/unit_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jobs:
5959
if: ${{ github.event_name }} == "merge_request_event" || !(${{ github.ref }} && $CI_OPEN_MERGE_REQUESTS) || ${{ github.ref }}
6060
timeout-minutes: 180
6161
env:
62-
EXTRA_CMAKE_FLAGS: "-DVC_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVC_BUILD_TESTS=ON"
62+
EXTRA_CMAKE_FLAGS: "-DVC_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVC_BUILD_TESTS=ON -DVC_BUILD_JSON=OFF"
6363
steps:
6464
- name: Checkout code
6565
uses: actions/checkout@v4
@@ -87,7 +87,7 @@ jobs:
8787
if: ${{ github.event_name }} == "merge_request_event" || !(${{ github.ref }} && $CI_OPEN_MERGE_REQUESTS) || ${{ github.ref }}
8888
timeout-minutes: 180
8989
env:
90-
EXTRA_CMAKE_FLAGS: "-DVC_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVC_BUILD_TESTS=ON"
90+
EXTRA_CMAKE_FLAGS: "-DVC_BUILD_EXAMPLES=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo -DVC_BUILD_TESTS=ON -DVC_BUILD_JSON=OFF"
9191
steps:
9292
- name: Checkout code
9393
uses: actions/checkout@v4

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.24..3.27 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.28..3.31 FATAL_ERROR)
22
include(FetchContent)
33
include(CMakeDependentOption)
44

@@ -104,4 +104,4 @@ endif()
104104
# Setup the config files #
105105
include(VCPackageConfig)
106106
# Install to system directories
107-
include(VCInstall)
107+
include(VCInstall)

cmake/BuildACVD.cmake

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
option(VC_BUILD_ACVD "Build in-source ACVD" ON)
22
if(VC_BUILD_ACVD)
3-
# Declare the project
43
FetchContent_Declare(
54
acvd
65
GIT_REPOSITORY https://gitlab.com/educelab/acvd.git
76
GIT_TAG v1.2.1
7+
EXCLUDE_FROM_ALL
88
)
9-
10-
# Populate the project but exclude from all
11-
FetchContent_GetProperties(acvd)
12-
if(NOT acvd_POPULATED)
13-
FetchContent_Populate(acvd)
14-
add_subdirectory(${acvd_SOURCE_DIR} ${acvd_BINARY_DIR} EXCLUDE_FROM_ALL)
15-
endif()
9+
FetchContent_MakeAvailable(acvd)
1610
else()
1711
find_package(ACVD 1.2 REQUIRED)
1812
endif()

cmake/BuildIndicators.cmake

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
# Declare the project
21
FetchContent_Declare(
32
indicators
43
GIT_REPOSITORY https://github.com/p-ranav/indicators.git
54
GIT_TAG 222382c
5+
EXCLUDE_FROM_ALL
66
)
7-
8-
# Populate the project but exclude from all
9-
FetchContent_GetProperties(indicators)
10-
if(NOT indicators_POPULATED)
11-
FetchContent_Populate(indicators)
12-
add_subdirectory(${indicators_SOURCE_DIR} ${indicators_BINARY_DIR} EXCLUDE_FROM_ALL)
13-
endif()
7+
FetchContent_MakeAvailable(indicators)

cmake/BuildJSON.cmake

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ if(VC_BUILD_JSON)
44
json
55
URL https://github.com/nlohmann/json/archive/v3.11.3.tar.gz
66
DOWNLOAD_EXTRACT_TIMESTAMP ON
7+
EXCLUDE_FROM_ALL
78
)
8-
9-
FetchContent_GetProperties(json)
10-
if(NOT json_POPULATED)
11-
set(JSON_BuildTests OFF CACHE INTERNAL "")
12-
set(JSON_Install ON CACHE INTERNAL "")
13-
FetchContent_Populate(json)
14-
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
15-
endif()
9+
set(JSON_BuildTests OFF CACHE INTERNAL "")
10+
set(JSON_Install ON CACHE INTERNAL "")
11+
FetchContent_MakeAvailable(json)
1612
else()
1713
find_package(nlohmann_json 3.9.1 REQUIRED)
1814
endif()

cmake/BuildOpenABF.cmake

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
# Declare the project
21
FetchContent_Declare(
32
openabf
43
GIT_REPOSITORY https://gitlab.com/educelab/OpenABF.git
54
GIT_TAG 63afa9e3
5+
EXCLUDE_FROM_ALL
66
)
7-
8-
# Populate the project but exclude from all
9-
FetchContent_GetProperties(openabf)
10-
if(NOT openabf_POPULATED)
11-
FetchContent_Populate(openabf)
12-
add_subdirectory(${openabf_SOURCE_DIR} ${openabf_BINARY_DIR} EXCLUDE_FROM_ALL)
13-
endif()
7+
FetchContent_MakeAvailable(openabf)

cmake/Buildbvh.cmake

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
# Declare the project
21
FetchContent_Declare(
32
bvh
43
GIT_REPOSITORY https://github.com/madmann91/bvh.git
54
GIT_TAG 2fd0db6
5+
EXCLUDE_FROM_ALL
66
)
7-
8-
# Populate the project but exclude from all
9-
FetchContent_GetProperties(bvh)
10-
if(NOT bvh_POPULATED)
11-
FetchContent_Populate(bvh)
12-
add_subdirectory(${bvh_SOURCE_DIR} ${bvh_BINARY_DIR} EXCLUDE_FROM_ALL)
13-
endif()
7+
FetchContent_MakeAvailable(bvh)

cmake/Buildsmgl.cmake

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,10 @@ FetchContent_Declare(
22
smgl
33
GIT_REPOSITORY https://gitlab.com/educelab/smgl.git
44
GIT_TAG v0.10.1
5-
CMAKE_CACHE_ARGS
6-
-DSMGL_BUILD_JSON:BOOL=ON
7-
-DSMGL_USE_BOOSTFS:BOOL=ON
8-
-DSMGL_BUILD_TESTS:BOOL=OFF
9-
-DSMGL_BUILD_DOCS:BOOL=OFF
5+
EXCLUDE_FROM_ALL
106
)
11-
12-
FetchContent_GetProperties(smgl)
13-
if(NOT smgl_POPULATED)
14-
set(SMGL_BUILD_JSON ON CACHE INTERNAL "")
15-
set(SMGL_USE_BOOSTFS ${VC_USE_BOOSTFS} CACHE INTERNAL "")
16-
set(SMGL_BUILD_TESTS OFF CACHE INTERNAL "")
17-
set(SMGL_BUILD_DOCS OFF CACHE INTERNAL "")
18-
FetchContent_Populate(smgl)
19-
add_subdirectory(${smgl_SOURCE_DIR} ${smgl_BINARY_DIR} EXCLUDE_FROM_ALL)
20-
endif()
7+
set(SMGL_BUILD_JSON ${VC_BUILD_JSON} CACHE INTERNAL "")
8+
set(SMGL_USE_BOOSTFS ${VC_USE_BOOSTFS} CACHE INTERNAL "")
9+
set(SMGL_BUILD_TESTS OFF CACHE INTERNAL "")
10+
set(SMGL_BUILD_DOCS OFF CACHE INTERNAL "")
11+
FetchContent_MakeAvailable(smgl)

cmake/VCFindDependencies.cmake

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ include(BuildACVD)
5353
### Eigen ###
5454
find_package(Eigen3 3.3 REQUIRED)
5555
if(CMAKE_GENERATOR MATCHES "Ninja|.*Makefiles.*" AND "${CMAKE_BUILD_TYPE}" MATCHES "^$|Debug")
56-
message(AUTHOR_WARNING "Configuring a Debug build. Eigen performance will be degraded. If you need debug symbols, \
57-
consider setting CMAKE_BUILD_TYPE to RelWithDebInfo. Otherwise, set to Release to maximize performance.")
56+
message(AUTHOR_WARNING "Configuring a Debug build. Eigen performance will \
57+
be degraded. If you need debug symbols, consider setting CMAKE_BUILD_TYPE \
58+
to RelWithDebInfo. Otherwise, set to Release to maximize performance.")
5859
endif()
5960

6061
### OpenCV ###
@@ -101,16 +102,10 @@ if(VC_BUILD_TESTS)
101102
googletest
102103
GIT_REPOSITORY https://github.com/google/googletest.git
103104
GIT_TAG v1.14.0
104-
CMAKE_CACHE_ARGS
105-
-DINSTALL_GTEST:BOOL=OFF
105+
EXCLUDE_FROM_ALL
106106
)
107-
108-
FetchContent_GetProperties(googletest)
109-
if(NOT googletest_POPULATED)
110-
set(INSTALL_GTEST OFF CACHE BOOL OFF FORCE)
111-
FetchContent_Populate(googletest)
112-
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
113-
endif()
107+
set(INSTALL_GTEST OFF CACHE INTERNAL "")
108+
FetchContent_MakeAvailable(googletest)
114109
endif()
115110

116111
# Python bindings

0 commit comments

Comments
 (0)