From f3919ac8e87a4848e86a84fdebfda3611b02d140 Mon Sep 17 00:00:00 2001 From: Joao Carreira Date: Sat, 27 Nov 2021 22:51:58 +0000 Subject: [PATCH] Change cmake fetch content --- CMakeLists.txt | 55 ++++++++++++++++++------------------ lib/catch2/CMakeLists.txt | 3 ++ modules/tests/CMakeLists.txt | 3 ++ 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index acae397..5a3daad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,8 @@ SET(UPDATE_CHANNEL # #################################################################################################################################################### INCLUDE(FetchContent) -# #################################################################################################################################################### +SET(FETCHCONTENT_BASE_DIR "${CMAKE_SOURCE_DIR}/deps") + # Doxygen IF(BUILD_DOC) FIND_PACKAGE(Doxygen) @@ -117,7 +118,23 @@ SET_PACKAGE_PROPERTIES( TYPE OPTIONAL ) -# #################################################################################################################################################### +# Type safe +FETCHCONTENT_DECLARE( + type_safe + GIT_REPOSITORY https://github.com/foonathan/type_safe + GIT_TAG v0.2.2 + SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/type_safe" +) + +SET_PACKAGE_PROPERTIES( + type_safe PROPERTIES + URL "https://github.com/foonathan/type_safe" + DESCRIPTION "Zero overhead abstractions that use the C++ type system to prevent bugs." + TYPE REQUIRED +) +FETCHCONTENT_MAKEAVAILABLE(type_safe) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/deps/type_safe/include/ ${CMAKE_SOURCE_DIR}/deps/type_safe/external/debug_assert/) + # Catch2 and Google Tests IF(BUILD_TESTS) FETCHCONTENT_DECLARE(googletest URL https://github.com/google/googletest/archive/609281088cfefc76f9d0ce82e1ff6c30cc3591e5.zip) @@ -126,7 +143,12 @@ IF(BUILD_TESTS) ON CACHE BOOL "" FORCE ) - FETCHCONTENT_MAKEAVAILABLE(googletest) + FETCHCONTENT_DECLARE( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v2.13.1 + ) + SET_PACKAGE_PROPERTIES( googletest PROPERTIES URL "https://github.com/google/googletest" @@ -134,19 +156,13 @@ IF(BUILD_TESTS) TYPE OPTIONAL ) - FETCHCONTENT_DECLARE( - Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v2.13.1 - ) - FETCHCONTENT_MAKEAVAILABLE(Catch2) SET_PACKAGE_PROPERTIES( Catch2 PROPERTIES URL "https://github.com/catchorg/Catch2" DESCRIPTION "Catch2 unit tests" TYPE OPTIONAL ) - INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/_deps/catch2-src/contrib/Catch.cmake) + INCLUDE(${CMAKE_SOURCE_DIR}/deps/catch2-src/contrib/Catch.cmake) INCLUDE(CTest) ENABLE_TESTING() @@ -156,23 +172,9 @@ IF(BUILD_TESTS) ) ENDIF() -# #################################################################################################################################################### -# Type safe -FETCHCONTENT_DECLARE( - type_safe - GIT_REPOSITORY https://github.com/foonathan/type_safe - GIT_TAG v0.2.2 -) -FETCHCONTENT_MAKEAVAILABLE(type_safe) -SET_PACKAGE_PROPERTIES( - type_safe PROPERTIES - URL "https://github.com/foonathan/type_safe" - DESCRIPTION "Zero overhead abstractions that use the C++ type system to prevent bugs." - TYPE REQUIRED -) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/_deps/type_safe-src/include/ ${CMAKE_CURRENT_BINARY_DIR}/_deps/type_safe-src/external/debug_assert/) -# #################################################################################################################################################### + + # OpenCV OPTION(USE_OPENCV "Add OpenCV support" ON) IF(USE_OPENCV) @@ -199,7 +201,6 @@ SET_PACKAGE_PROPERTIES( TYPE OPTIONAL ) -# #################################################################################################################################################### # FFmpeg OPTION(USE_FFMPEG "Add FFMPEG support" ON) IF(USE_FFMPEG) diff --git a/lib/catch2/CMakeLists.txt b/lib/catch2/CMakeLists.txt index 6216870..de2a779 100644 --- a/lib/catch2/CMakeLists.txt +++ b/lib/catch2/CMakeLists.txt @@ -2,6 +2,9 @@ # CMakeLists for Calyp lis tests using catch2 # +FETCHCONTENT_MAKEAVAILABLE(Catch2) + + SET(Calyp_Lib_Catch2_Tests_SRCS CalypLibTests.cpp CalypStreamTests.cpp diff --git a/modules/tests/CMakeLists.txt b/modules/tests/CMakeLists.txt index 1c4d5af..9920e7e 100644 --- a/modules/tests/CMakeLists.txt +++ b/modules/tests/CMakeLists.txt @@ -3,6 +3,9 @@ # OPTION(BUILD_MODULES_TESTS "Build unit tests of modules" ON) IF(BUILD_MODULES_TESTS) + + FETCHCONTENT_MAKEAVAILABLE(googletest Catch2) + INCLUDE_DIRECTORIES(${GTEST_INCLUDE_DIRS}) ADD_DEFINITIONS(-DCALYP_TEST_DATA_DIR=\"${CALYP_TEST_DATA_DIR}\")