Warning, /acts/Detray/extern/googletest/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 # This file is part of the ACTS project.
0002 #
0003 # Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 #
0005 # This Source Code Form is subject to the terms of the Mozilla Public
0006 # License, v. 2.0. If a copy of the MPL was not distributed with this
0007 # file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008
0009 # CMake include(s).
0010 cmake_minimum_required(VERSION 3.11)
0011 include(FetchContent)
0012
0013 # Silence FetchContent warnings with CMake >=3.24.
0014 if(POLICY CMP0135)
0015 cmake_policy(SET CMP0135 NEW)
0016 endif()
0017
0018 # Tell the user what's happening.
0019 message(STATUS "Building GoogleTest as part of the Detray project")
0020
0021 # Declare where to get GoogleTest from.
0022 set(DETRAY_GOOGLETEST_SOURCE
0023 "URL;https://github.com/google/googletest/archive/refs/tags/v${DETRAY_GOOGLETEST_VERSION}.tar.gz;URL_MD5;${DETRAY_GOOGLETEST_DIGEST}"
0024 CACHE STRING
0025 "Source for GoogleTest, when built as part of this project"
0026 )
0027 mark_as_advanced(DETRAY_GOOGLETEST_SOURCE)
0028
0029 # Mark the import as a system library on modern CMake versions
0030 if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.25.0)
0031 set(DETRAY_GOOGLETEST_SOURCE_FULL "${DETRAY_GOOGLETEST_SOURCE};SYSTEM")
0032 else()
0033 set(DETRAY_GOOGLETEST_SOURCE_FULL "${DETRAY_GOOGLETEST_SOURCE}")
0034 endif()
0035 mark_as_advanced(DETRAY_GOOGLETEST_SOURCE_FULL)
0036
0037 FetchContent_Declare(GoogleTest ${DETRAY_GOOGLETEST_SOURCE_FULL})
0038
0039 # Options used in the build of GoogleTest.
0040 set(BUILD_GMOCK TRUE CACHE BOOL "Turn off the build of GMock")
0041 set(INSTALL_GTEST FALSE CACHE BOOL "Turn off the installation of GoogleTest")
0042 if(WIN32)
0043 set(gtest_force_shared_crt
0044 TRUE
0045 CACHE BOOL
0046 "Use shared (DLL) run-time library, even with static libraries"
0047 )
0048 endif()
0049
0050 # Silence some warnings with modern versions of CMake on macOS.
0051 set(CMAKE_MACOSX_RPATH TRUE)
0052
0053 # Get it into the current directory.
0054 FetchContent_Populate(GoogleTest)
0055 add_subdirectory(
0056 "${googletest_SOURCE_DIR}"
0057 "${googletest_BINARY_DIR}"
0058 EXCLUDE_FROM_ALL
0059 )
0060
0061 # Set up aliases for the GTest targets with the same name that they have
0062 # when we find GTest pre-installed.
0063 add_library(GTest::gtest ALIAS gtest)
0064 add_library(GTest::gtest_main ALIAS gtest_main)