mirror of
https://github.com/google/googletest.git
synced 2024-12-26 17:41:03 +08:00
cmake: Remove remaining checks for CMAKE_VERSION
Remove conditional code that doesn't need to exist anymore.
This commit is contained in:
parent
fb11778f43
commit
812f35b26b
@ -100,18 +100,14 @@ else()
|
|||||||
target_link_libraries(gmock_main PUBLIC gmock)
|
target_link_libraries(gmock_main PUBLIC gmock)
|
||||||
set_target_properties(gmock_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
set_target_properties(gmock_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
||||||
endif()
|
endif()
|
||||||
# If the CMake version supports it, attach header directory information
|
|
||||||
# to the targets for when we are part of a parent build (ie being pulled
|
string(REPLACE ";" "$<SEMICOLON>" dirs "${gmock_build_include_dirs}")
|
||||||
# in via add_subdirectory() rather than being a standalone build).
|
target_include_directories(gmock SYSTEM INTERFACE
|
||||||
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
"$<BUILD_INTERFACE:${dirs}>"
|
||||||
string(REPLACE ";" "$<SEMICOLON>" dirs "${gmock_build_include_dirs}")
|
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
target_include_directories(gmock SYSTEM INTERFACE
|
target_include_directories(gmock_main SYSTEM INTERFACE
|
||||||
"$<BUILD_INTERFACE:${dirs}>"
|
"$<BUILD_INTERFACE:${dirs}>"
|
||||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
target_include_directories(gmock_main SYSTEM INTERFACE
|
|
||||||
"$<BUILD_INTERFACE:${dirs}>"
|
|
||||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
#
|
#
|
||||||
@ -135,11 +131,7 @@ if (gmock_build_tests)
|
|||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
if (MINGW OR CYGWIN)
|
if (MINGW OR CYGWIN)
|
||||||
if (CMAKE_VERSION VERSION_LESS "2.8.12")
|
add_compile_options("-Wa,-mbig-obj")
|
||||||
add_compile_options("-Wa,-mbig-obj")
|
|
||||||
else()
|
|
||||||
add_definitions("-Wa,-mbig-obj")
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
@ -140,18 +140,13 @@ if(GTEST_HAS_ABSL)
|
|||||||
endif()
|
endif()
|
||||||
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
|
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
|
||||||
set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
|
||||||
# If the CMake version supports it, attach header directory information
|
string(REPLACE ";" "$<SEMICOLON>" dirs "${gtest_build_include_dirs}")
|
||||||
# to the targets for when we are part of a parent build (ie being pulled
|
target_include_directories(gtest SYSTEM INTERFACE
|
||||||
# in via add_subdirectory() rather than being a standalone build).
|
"$<BUILD_INTERFACE:${dirs}>"
|
||||||
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
string(REPLACE ";" "$<SEMICOLON>" dirs "${gtest_build_include_dirs}")
|
target_include_directories(gtest_main SYSTEM INTERFACE
|
||||||
target_include_directories(gtest SYSTEM INTERFACE
|
"$<BUILD_INTERFACE:${dirs}>"
|
||||||
"$<BUILD_INTERFACE:${dirs}>"
|
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
|
||||||
target_include_directories(gtest_main SYSTEM INTERFACE
|
|
||||||
"$<BUILD_INTERFACE:${dirs}>"
|
|
||||||
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
|
|
||||||
endif()
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES "QNX")
|
if(CMAKE_SYSTEM_NAME MATCHES "QNX")
|
||||||
target_link_libraries(gtest PUBLIC regex)
|
target_link_libraries(gtest PUBLIC regex)
|
||||||
endif()
|
endif()
|
||||||
|
@ -188,23 +188,14 @@ function(cxx_library_with_type name type cxx_flags)
|
|||||||
set_target_properties(${name}
|
set_target_properties(${name}
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
|
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
|
||||||
if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
|
|
||||||
target_compile_definitions(${name} INTERFACE
|
target_compile_definitions(${name} INTERFACE
|
||||||
$<INSTALL_INTERFACE:GTEST_LINKED_AS_SHARED_LIBRARY=1>)
|
$<INSTALL_INTERFACE:GTEST_LINKED_AS_SHARED_LIBRARY=1>)
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
if (DEFINED GTEST_HAS_PTHREAD)
|
if (DEFINED GTEST_HAS_PTHREAD)
|
||||||
if ("${CMAKE_VERSION}" VERSION_LESS "3.1.0")
|
target_link_libraries(${name} PUBLIC Threads::Threads)
|
||||||
set(threads_spec ${CMAKE_THREAD_LIBS_INIT})
|
|
||||||
else()
|
|
||||||
set(threads_spec Threads::Threads)
|
|
||||||
endif()
|
|
||||||
target_link_libraries(${name} PUBLIC ${threads_spec})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT "${CMAKE_VERSION}" VERSION_LESS "3.8")
|
target_compile_features(${name} PUBLIC cxx_std_14)
|
||||||
target_compile_features(${name} PUBLIC cxx_std_14)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
@ -256,16 +247,7 @@ function(cxx_executable name dir libs)
|
|||||||
${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
|
${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN})
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE.
|
find_package(Python3)
|
||||||
if ("${CMAKE_VERSION}" VERSION_LESS "3.12.0")
|
|
||||||
find_package(PythonInterp)
|
|
||||||
set(PYTHONINTERP_FOUND ${PYTHONINTERP_FOUND} CACHE INTERNAL "")
|
|
||||||
set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} CACHE INTERNAL "")
|
|
||||||
else()
|
|
||||||
find_package(Python COMPONENTS Interpreter)
|
|
||||||
set(PYTHONINTERP_FOUND ${Python_Interpreter_FOUND} CACHE INTERNAL "")
|
|
||||||
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE} CACHE INTERNAL "")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# cxx_test_with_flags(name cxx_flags libs srcs...)
|
# cxx_test_with_flags(name cxx_flags libs srcs...)
|
||||||
#
|
#
|
||||||
@ -291,34 +273,22 @@ endfunction()
|
|||||||
# creates a Python test with the given name whose main module is in
|
# creates a Python test with the given name whose main module is in
|
||||||
# test/name.py. It does nothing if Python is not installed.
|
# test/name.py. It does nothing if Python is not installed.
|
||||||
function(py_test name)
|
function(py_test name)
|
||||||
if (PYTHONINTERP_FOUND)
|
if (NOT Python3_Interpreter_FOUND)
|
||||||
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 3.1)
|
return()
|
||||||
if (CMAKE_CONFIGURATION_TYPES)
|
endif()
|
||||||
# Multi-configuration build generators as for Visual Studio save
|
|
||||||
# output in a subdirectory of CMAKE_CURRENT_BINARY_DIR (Debug,
|
get_cmake_property(is_multi "GENERATOR_IS_MULTI_CONFIG")
|
||||||
# Release etc.), so we have to provide it here.
|
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}")
|
||||||
add_test(NAME ${name}
|
if (is_multi)
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>")
|
||||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> ${ARGN})
|
endif()
|
||||||
else (CMAKE_CONFIGURATION_TYPES)
|
|
||||||
# Single-configuration build generators like Makefile generators
|
add_test(NAME ${name}
|
||||||
# don't have subdirs below CMAKE_CURRENT_BINARY_DIR.
|
COMMAND Python3::Interpreter ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
||||||
add_test(NAME ${name}
|
--build_dir=${build_dir} ${ARGN})
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
|
||||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR} ${ARGN})
|
# Make the Python import path consistent between Bazel and CMake.
|
||||||
endif (CMAKE_CONFIGURATION_TYPES)
|
set_tests_properties(${name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR})
|
||||||
else()
|
|
||||||
# ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can
|
|
||||||
# directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
|
|
||||||
# only at ctest runtime (by calling ctest -c <Configuration>), so
|
|
||||||
# we have to escape $ to delay variable substitution here.
|
|
||||||
add_test(NAME ${name}
|
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py
|
|
||||||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE} ${ARGN})
|
|
||||||
endif()
|
|
||||||
# Make the Python import path consistent between Bazel and CMake.
|
|
||||||
set_tests_properties(${name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR})
|
|
||||||
endif(PYTHONINTERP_FOUND)
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# install_project(targets...)
|
# install_project(targets...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user