-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: Remove remaining checks for CMAKE_VERSION #4293
Merged
copybara-service
merged 1 commit into
google:main
from
juan-lunarg:juan/fix_remaining_cmake_version
Jun 21, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,23 +188,14 @@ function(cxx_library_with_type name type cxx_flags) | |
set_target_properties(${name} | ||
PROPERTIES | ||
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1") | ||
if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11") | ||
target_compile_definitions(${name} INTERFACE | ||
$<INSTALL_INTERFACE:GTEST_LINKED_AS_SHARED_LIBRARY=1>) | ||
endif() | ||
endif() | ||
if (DEFINED GTEST_HAS_PTHREAD) | ||
if ("${CMAKE_VERSION}" VERSION_LESS "3.1.0") | ||
set(threads_spec ${CMAKE_THREAD_LIBS_INIT}) | ||
else() | ||
set(threads_spec Threads::Threads) | ||
endif() | ||
target_link_libraries(${name} PUBLIC ${threads_spec}) | ||
target_link_libraries(${name} PUBLIC Threads::Threads) | ||
endif() | ||
|
||
if (NOT "${CMAKE_VERSION}" VERSION_LESS "3.8") | ||
target_compile_features(${name} PUBLIC cxx_std_14) | ||
endif() | ||
target_compile_features(${name} PUBLIC cxx_std_14) | ||
endfunction() | ||
|
||
######################################################################## | ||
|
@@ -256,16 +247,7 @@ function(cxx_executable name dir libs) | |
${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN}) | ||
endfunction() | ||
|
||
# Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE. | ||
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() | ||
find_package(Python3) | ||
|
||
# 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 | ||
# test/name.py. It does nothing if Python is not installed. | ||
function(py_test name) | ||
if (PYTHONINTERP_FOUND) | ||
if ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" VERSION_GREATER 3.1) | ||
if (CMAKE_CONFIGURATION_TYPES) | ||
# Multi-configuration build generators as for Visual Studio save | ||
# output in a subdirectory of CMAKE_CURRENT_BINARY_DIR (Debug, | ||
# Release etc.), so we have to provide it here. | ||
add_test(NAME ${name} | ||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py | ||
--build_dir=${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> ${ARGN}) | ||
else (CMAKE_CONFIGURATION_TYPES) | ||
# Single-configuration build generators like Makefile generators | ||
# don't have subdirs below CMAKE_CURRENT_BINARY_DIR. | ||
add_test(NAME ${name} | ||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py | ||
--build_dir=${CMAKE_CURRENT_BINARY_DIR} ${ARGN}) | ||
endif (CMAKE_CONFIGURATION_TYPES) | ||
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) | ||
if (NOT Python3_Interpreter_FOUND) | ||
return() | ||
endif() | ||
|
||
get_cmake_property(is_multi "GENERATOR_IS_MULTI_CONFIG") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note https://cmake.org/cmake/help/latest/prop_gbl/GENERATOR_IS_MULTI_CONFIG.html |
||
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}") | ||
if (is_multi) | ||
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>") | ||
endif() | ||
|
||
add_test(NAME ${name} | ||
COMMAND Python3::Interpreter ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py | ||
--build_dir=${build_dir} ${ARGN}) | ||
|
||
# Make the Python import path consistent between Bazel and CMake. | ||
set_tests_properties(${name} PROPERTIES ENVIRONMENT PYTHONPATH=${CMAKE_SOURCE_DIR}) | ||
endfunction() | ||
|
||
# install_project(targets...) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add_definitions
is used to add defines to the code likeNOMINMAX
orWIN32_LEAN_AND_MEAN
using it for compiler options isn't correct.Also
add_definitions
isn't recommended for usage anymore:https://cmake.org/cmake/help/latest/command/add_definitions.html#command:add_definitions