Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Simplify FetchContent builds #114

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.24..3.27 FATAL_ERROR)
cmake_minimum_required(VERSION 3.28..3.31 FATAL_ERROR)
include(FetchContent)
include(CMakeDependentOption)

Expand Down Expand Up @@ -104,4 +104,4 @@ endif()
# Setup the config files #
include(VCPackageConfig)
# Install to system directories
include(VCInstall)
include(VCInstall)
10 changes: 2 additions & 8 deletions cmake/BuildACVD.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
option(VC_BUILD_ACVD "Build in-source ACVD" ON)
if(VC_BUILD_ACVD)
# Declare the project
FetchContent_Declare(
acvd
GIT_REPOSITORY https://gitlab.com/educelab/acvd.git
GIT_TAG v1.2.1
EXCLUDE_FROM_ALL
)

# Populate the project but exclude from all
FetchContent_GetProperties(acvd)
if(NOT acvd_POPULATED)
FetchContent_Populate(acvd)
add_subdirectory(${acvd_SOURCE_DIR} ${acvd_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
FetchContent_MakeAvailable(acvd)
else()
find_package(ACVD 1.2 REQUIRED)
endif()
10 changes: 2 additions & 8 deletions cmake/BuildIndicators.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Declare the project
FetchContent_Declare(
indicators
GIT_REPOSITORY https://github.com/p-ranav/indicators.git
GIT_TAG 222382c
EXCLUDE_FROM_ALL
)

# Populate the project but exclude from all
FetchContent_GetProperties(indicators)
if(NOT indicators_POPULATED)
FetchContent_Populate(indicators)
add_subdirectory(${indicators_SOURCE_DIR} ${indicators_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
FetchContent_MakeAvailable(indicators)
14 changes: 5 additions & 9 deletions cmake/BuildJSON.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
option(VC_BUILD_JSON "Build in-source JSON library" on)
option(VC_BUILD_JSON "Build in-source JSON library" off)
if(VC_BUILD_JSON)
FetchContent_Declare(
json
URL https://github.com/nlohmann/json/archive/v3.11.3.tar.gz
DOWNLOAD_EXTRACT_TIMESTAMP ON
EXCLUDE_FROM_ALL
)

FetchContent_GetProperties(json)
if(NOT json_POPULATED)
set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_Install ON CACHE INTERNAL "")
FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
set(JSON_BuildTests OFF CACHE INTERNAL "")
set(JSON_Install ON CACHE INTERNAL "")
FetchContent_MakeAvailable(json)
else()
find_package(nlohmann_json 3.9.1 REQUIRED)
endif()
10 changes: 2 additions & 8 deletions cmake/BuildOpenABF.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Declare the project
FetchContent_Declare(
openabf
GIT_REPOSITORY https://gitlab.com/educelab/OpenABF.git
GIT_TAG 63afa9e3
EXCLUDE_FROM_ALL
)

# Populate the project but exclude from all
FetchContent_GetProperties(openabf)
if(NOT openabf_POPULATED)
FetchContent_Populate(openabf)
add_subdirectory(${openabf_SOURCE_DIR} ${openabf_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
FetchContent_MakeAvailable(openabf)
10 changes: 2 additions & 8 deletions cmake/Buildbvh.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Declare the project
FetchContent_Declare(
bvh
GIT_REPOSITORY https://github.com/madmann91/bvh.git
GIT_TAG 2fd0db6
EXCLUDE_FROM_ALL
)

# Populate the project but exclude from all
FetchContent_GetProperties(bvh)
if(NOT bvh_POPULATED)
FetchContent_Populate(bvh)
add_subdirectory(${bvh_SOURCE_DIR} ${bvh_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
FetchContent_MakeAvailable(bvh)
16 changes: 6 additions & 10 deletions cmake/Buildsmgl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ FetchContent_Declare(
-DSMGL_USE_BOOSTFS:BOOL=ON
-DSMGL_BUILD_TESTS:BOOL=OFF
-DSMGL_BUILD_DOCS:BOOL=OFF
EXCLUDE_FROM_ALL
)

FetchContent_GetProperties(smgl)
if(NOT smgl_POPULATED)
set(SMGL_BUILD_JSON ON CACHE INTERNAL "")
set(SMGL_USE_BOOSTFS ${VC_USE_BOOSTFS} CACHE INTERNAL "")
set(SMGL_BUILD_TESTS OFF CACHE INTERNAL "")
set(SMGL_BUILD_DOCS OFF CACHE INTERNAL "")
FetchContent_Populate(smgl)
add_subdirectory(${smgl_SOURCE_DIR} ${smgl_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
set(SMGL_BUILD_JSON ${VC_BUILD_JSON} CACHE INTERNAL "")
set(SMGL_USE_BOOSTFS ${VC_USE_BOOSTFS} CACHE INTERNAL "")
set(SMGL_BUILD_TESTS OFF CACHE INTERNAL "")
set(SMGL_BUILD_DOCS OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(smgl)
17 changes: 6 additions & 11 deletions cmake/VCFindDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ include(BuildACVD)
### Eigen ###
find_package(Eigen3 3.3 REQUIRED)
if(CMAKE_GENERATOR MATCHES "Ninja|.*Makefiles.*" AND "${CMAKE_BUILD_TYPE}" MATCHES "^$|Debug")
message(AUTHOR_WARNING "Configuring a Debug build. Eigen performance will be degraded. If you need debug symbols, \
consider setting CMAKE_BUILD_TYPE to RelWithDebInfo. Otherwise, set to Release to maximize performance.")
message(AUTHOR_WARNING "Configuring a Debug build. Eigen performance will \
be degraded. If you need debug symbols, consider setting CMAKE_BUILD_TYPE \
to RelWithDebInfo. Otherwise, set to Release to maximize performance.")
endif()

### OpenCV ###
Expand Down Expand Up @@ -101,16 +102,10 @@ if(VC_BUILD_TESTS)
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.14.0
CMAKE_CACHE_ARGS
-DINSTALL_GTEST:BOOL=OFF
EXCLUDE_FROM_ALL
)

FetchContent_GetProperties(googletest)
if(NOT googletest_POPULATED)
set(INSTALL_GTEST OFF CACHE BOOL OFF FORCE)
FetchContent_Populate(googletest)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
set(INSTALL_GTEST OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(googletest)
endif()

# Python bindings
Expand Down
Loading