Skip to content
Snippets Groups Projects
Commit d7584936 authored by Jerome Hue's avatar Jerome Hue Committed by Maxence Naud
Browse files

chore: Use find_package in CMake, fallback to fetch_content

parent efc3c4b5
No related branches found
No related tags found
2 merge requests!279v0.4.0,!261chore: Use find_package in CMake, fallback to FetchContent
...@@ -5,7 +5,7 @@ file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version) ...@@ -5,7 +5,7 @@ file(STRINGS "${CMAKE_SOURCE_DIR}/version.txt" version)
project(aidge_core project(aidge_core
VERSION ${version} VERSION ${version}
DESCRIPTION "Core algorithms for operators and graph of the AIDGE framework" DESCRIPTION "Core algorithms for operators and graph of the AIDGE framework"
LANGUAGES CXX) LANGUAGES CXX)
message(STATUS "Project name: ${CMAKE_PROJECT_NAME}") message(STATUS "Project name: ${CMAKE_PROJECT_NAME}")
message(STATUS "Project version: ${version}") message(STATUS "Project version: ${version}")
...@@ -36,22 +36,28 @@ endif() ...@@ -36,22 +36,28 @@ endif()
############################################## ##############################################
# Find system dependencies # Find system dependencies
Include(FetchContent)
set(FMT_VERSION 10.2.1) set(FMT_VERSION 10.2.1)
message(STATUS "Retrieving fmt ${FMT_VERSION} from git")
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG ${FMT_VERSION} # or a later release
)
set(FMT_SYSTEM_HEADERS ON) find_package(fmt ${FMT_VERSION} QUIET)
FetchContent_MakeAvailable(fmt)
set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON)
find_package(Threads REQUIRED) if(NOT fmt_FOUND)
message(STATUS "fmt not found in system, retrieving from git")
Include(FetchContent)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG ${FMT_VERSION}
)
set(FMT_SYSTEM_HEADERS ON)
FetchContent_MakeAvailable(fmt)
set_property(TARGET fmt PROPERTY POSITION_INDEPENDENT_CODE ON)
else()
message(STATUS "Found system fmt version ${fmt_VERSION}")
endif()
find_package(Threads REQUIRED)
############################################## ##############################################
# Create target and set properties # Create target and set properties
......
Include(FetchContent) find_package(Catch2 3.0.1)
FetchContent_Declare( if(NOT Catch2_FOUND)
Catch2 message(STATUS "Catch2 not found in system, retrieving from git")
GIT_REPOSITORY https://github.com/catchorg/Catch2.git Include(FetchContent)
GIT_TAG v3.0.1 # or a later release
)
FetchContent_MakeAvailable(Catch2) FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.0.1 # or a later release
)
FetchContent_MakeAvailable(Catch2)
endif()
file(GLOB_RECURSE src_files "*.cpp") file(GLOB_RECURSE src_files "*.cpp")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment