diff --git a/CMakeLists.txt b/CMakeLists.txt index f0130a9..b14a724 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ # v. 2.0. If a copy of the MPL was not distributed with this file, You can # obtain one at http://mozilla.org/MPL/2.0/. -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.21) project("covfie" VERSION 0.10.0) @@ -41,16 +41,37 @@ add_subdirectory(lib) # The benchmarks should be build only if requested... if(COVFIE_BUILD_BENCHMARKS) + if(NOT PROJECT_IS_TOP_LEVEL) + message( + FATAL_ERROR + "Build of benchmarks was requested, but covfie is not the top level project." + ) + endif() + add_subdirectory(benchmarks) endif() # ...the same goes for the tests... if(COVFIE_BUILD_TESTS) + if(NOT PROJECT_IS_TOP_LEVEL) + message( + FATAL_ERROR + "Build of tests was requested, but covfie is not the top level project." + ) + endif() + add_subdirectory(tests) endif() # ...and the examples. if(COVFIE_BUILD_EXAMPLES) + if(NOT PROJECT_IS_TOP_LEVEL) + message( + FATAL_ERROR + "Build of examples was requested, but covfie is not the top level project." + ) + endif() + add_subdirectory(examples) endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 1aec043..e1de7f3 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,20 +8,7 @@ # All the tests here will require Google Test, so we will go ahead and set it # up. -# Set up GoogleTest. -option(COVFIE_SETUP_GOOGLETEST "Set up the GoogleTest targets explicitly" TRUE) -option( - COVFIE_USE_SYSTEM_GOOGLETEST - "Pick up an existing installation of GoogleTest from the build environment" - TRUE -) -if(COVFIE_SETUP_GOOGLETEST) - if(COVFIE_USE_SYSTEM_GOOGLETEST) - find_package(GTest CONFIG REQUIRED) - else() - add_subdirectory(googletest) - endif() -endif() +find_package(GTest CONFIG REQUIRED) # Set up the C++ compiler flags for the tests. include(covfie-compiler-options-cpp) diff --git a/tests/googletest/CMakeLists.txt b/tests/googletest/CMakeLists.txt deleted file mode 100644 index 413f046..0000000 --- a/tests/googletest/CMakeLists.txt +++ /dev/null @@ -1,54 +0,0 @@ -# This file is part of covfie, a part of the ACTS project -# -# Copyright (c) 2022 CERN -# -# This Source Code Form is subject to the terms of the Mozilla Public License, -# v. 2.0. If a copy of the MPL was not distributed with this file, You can -# obtain one at http://mozilla.org/MPL/2.0/. - -# CMake include(s). -cmake_minimum_required(VERSION 3.11) -include(FetchContent) - -# Silence FetchContent warnings with CMake >=3.24. -if(POLICY CMP0135) - cmake_policy(SET CMP0135 NEW) -endif() - -# Tell the user what's happening. -message(STATUS "Building GoogleTest as part of the Covfie project") - -# Declare where to get GoogleTest from. -FetchContent_Declare( - GoogleTest - URL - "https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz" - URL_MD5 "c8340a482851ef6a3fe618a082304cfc" -) - -# Options used in the build of GoogleTest. -set(BUILD_GMOCK FALSE CACHE BOOL "Turn off the build of GMock") -set(INSTALL_GTEST FALSE CACHE BOOL "Turn off the installation of GoogleTest") -if(WIN32) - set(gtest_force_shared_crt - TRUE - CACHE BOOL - "Use shared (DLL) run-time library, even with static libraries" - ) -endif() - -# Silence some warnings with modern versions of CMake on macOS. -set(CMAKE_MACOSX_RPATH TRUE) - -# Get it into the current directory. -FetchContent_Populate(GoogleTest) -add_subdirectory( - "${googletest_SOURCE_DIR}" - "${googletest_BINARY_DIR}" - EXCLUDE_FROM_ALL -) - -# Set up aliases for the GTest targets with the same name that they have -# when we find GTest pre-installed. -add_library(GTest::gtest ALIAS gtest) -add_library(GTest::gtest_main ALIAS gtest_main) diff --git a/tests/googletest/README.md b/tests/googletest/README.md deleted file mode 100644 index 87c642c..0000000 --- a/tests/googletest/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# GoogleTest Build Instructions - -This subdirectory holds instructions for building -[GoogleTest](https://github.com/google/googletest) as part of this project. -This is meant to come in handy for building the project's tests in environments -which do not provide GoogleTest themselves. - -Note that since GoogleTest is only needed for the unit tests of this project, -which are not installed together with the project, GoogleTest is not installed -together with the project either.