Adding code
This commit is contained in:
24
cmake/CPM.cmake
Normal file
24
cmake/CPM.cmake
Normal file
@@ -0,0 +1,24 @@
|
||||
# SPDX-License-Identifier: MIT
|
||||
#
|
||||
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
|
||||
|
||||
set(CPM_DOWNLOAD_VERSION 0.38.7)
|
||||
set(CPM_HASH_SUM "83e5eb71b2bbb8b1f2ad38f1950287a057624e385c238f6087f94cdfc44af9c5")
|
||||
|
||||
if(CPM_SOURCE_CACHE)
|
||||
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
|
||||
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
else()
|
||||
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
|
||||
endif()
|
||||
|
||||
# Expand relative path. This is important if the provided path contains a tilde (~)
|
||||
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
|
||||
|
||||
file(DOWNLOAD
|
||||
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
|
||||
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
|
||||
)
|
||||
|
||||
include(${CPM_DOWNLOAD_LOCATION})
|
68
cmake/gtest.cmake
Normal file
68
cmake/gtest.cmake
Normal file
@@ -0,0 +1,68 @@
|
||||
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# CPM configuration
|
||||
#-----------------------------------------------------------------------
|
||||
set(CPM_MODULE_NAME google_test)
|
||||
set(CPM_LIB_TARGET_NAME ${CPM_MODULE_NAME})
|
||||
|
||||
if ((DEFINED CPM_DIR) AND (DEFINED CPM_UNIQUE_ID) AND (DEFINED CPM_TARGET_NAME))
|
||||
set(CPM_LIB_TARGET_NAME ${CPM_TARGET_NAME})
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CPM_DIR})
|
||||
include(CPM)
|
||||
else()
|
||||
set(CPM_DIR "${CMAKE_CURRENT_BINARY_DIR}/cpm-packages" CACHE TYPE STRING)
|
||||
find_package(Git)
|
||||
if(NOT GIT_FOUND)
|
||||
message(FATAL_ERROR "CPM requires Git.")
|
||||
endif()
|
||||
if (NOT EXISTS ${CPM_DIR}/CPM.cmake)
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" clone https://github.com/iauns/cpm ${CPM_DIR}
|
||||
RESULT_VARIABLE error_code
|
||||
OUTPUT_VARIABLE head_sha)
|
||||
if(error_code)
|
||||
message(FATAL_ERROR "CPM failed to get the hash for HEAD")
|
||||
endif()
|
||||
endif()
|
||||
include(${CPM_DIR}/CPM.cmake)
|
||||
endif()
|
||||
|
||||
# All externals *must* define this.
|
||||
CPM_ForceOnlyOneModuleVersion()
|
||||
|
||||
CPM_InitModule(${CPM_MODULE_NAME})
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Google Test
|
||||
#------------------------------------------------------------------------------
|
||||
# Google test as an external project is a bad idea! You really should add it
|
||||
# as a subdirectory so that it can capture your compiler flags
|
||||
set(GOOGLE_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/3rdParty/gtest)
|
||||
CPM_EnsureRepoIsCurrent(
|
||||
TARGET_DIR ${GOOGLE_TEST_DIR}
|
||||
SVN_REPOSITORY "http://googletest.googlecode.com/svn/trunk"
|
||||
SVN_REVISION "664"
|
||||
USE_CACHING TRUE
|
||||
)
|
||||
|
||||
# Compiler flags for MSVC 2010
|
||||
if (MSVC_VERSION EQUAL 1600)
|
||||
add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=0)
|
||||
CPM_ExportAdditionalDefinition("-DGTEST_USE_OWN_TR1_TUPLE=0")
|
||||
endif()
|
||||
|
||||
# Compiler flags for MSVC 2012
|
||||
if(MSVC_VERSION EQUAL 1700)
|
||||
add_definitions(-D_VARIADIC_MAX=10)
|
||||
endif()
|
||||
|
||||
# For All versions of gtest, we force shared CRT.
|
||||
set(gtest_force_shared_crt ON)
|
||||
set(gtest_force_shared_crt ON)
|
||||
|
||||
# Add gtest now that we have the appropriate flags set.
|
||||
add_subdirectory(${GOOGLE_TEST_DIR})
|
||||
|
||||
CPM_ExportAdditionalIncludeDir("${GOOGLE_TEST_DIR}/include")
|
||||
CPM_ExportAdditionalLibraryTarget("gtest")
|
Reference in New Issue
Block a user