diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-07-23 16:54:12 +0200 |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-09-06 10:52:25 +0200 |
commit | eb583b0a660ba68e8e3b5f820301fde333619283 (patch) | |
tree | d88a52fdc1af9843ee4adceb1a37c66148d48c2e /Source/Checks | |
parent | 212e953d352c2ca20cf6280492633d21fbacdbc9 (diff) | |
download | cmake-eb583b0a660ba68e8e3b5f820301fde333619283.tar.gz |
cmake_path command: path management
Fixes: #19568, #20922
Diffstat (limited to 'Source/Checks')
-rw-r--r-- | Source/Checks/cm_cxx_features.cmake | 29 | ||||
-rw-r--r-- | Source/Checks/cm_cxx_filesystem.cxx | 19 |
2 files changed, 40 insertions, 8 deletions
diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index e726fc72b4..5c1593db40 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -1,6 +1,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/cm_message_checks_compat.cmake) function(cm_check_cxx_feature name) + set(TRY_RUN_FEATURE "${ARGN}") string(TOUPPER ${name} FEATURE) if(NOT DEFINED CMake_HAVE_CXX_${FEATURE}) cm_message_checks_compat( @@ -12,12 +13,26 @@ function(cm_check_cxx_feature name) else() set(maybe_cxx_standard "") endif() - try_compile(CMake_HAVE_CXX_${FEATURE} - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_LIST_DIR}/cm_cxx_${name}.cxx - CMAKE_FLAGS ${maybe_cxx_standard} - OUTPUT_VARIABLE OUTPUT - ) + if (TRY_RUN_FEATURE) + try_run(CMake_RUN_CXX_${FEATURE} CMake_COMPILE_CXX_${FEATURE} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_LIST_DIR}/cm_cxx_${name}.cxx + CMAKE_FLAGS ${maybe_cxx_standard} + OUTPUT_VARIABLE OUTPUT + ) + if (CMake_RUN_CXX_${FEATURE} EQUAL "0" AND CMake_COMPILE_CXX_${FEATURE}) + set(CMake_HAVE_CXX_${FEATURE} ON CACHE INTERNAL "TRY_RUN" FORCE) + else() + set(CMake_HAVE_CXX_${FEATURE} OFF CACHE INTERNAL "TRY_RUN" FORCE) + endif() + else() + try_compile(CMake_HAVE_CXX_${FEATURE} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_LIST_DIR}/cm_cxx_${name}.cxx + CMAKE_FLAGS ${maybe_cxx_standard} + OUTPUT_VARIABLE OUTPUT + ) + endif() set(check_output "${OUTPUT}") # Filter out MSBuild output that looks like a warning. string(REGEX REPLACE " +0 Warning\\(s\\)" "" check_output "${check_output}") @@ -64,7 +79,7 @@ if(CMake_HAVE_CXX_MAKE_UNIQUE) endif() cm_check_cxx_feature(unique_ptr) if (NOT CMAKE_CXX_STANDARD LESS "17") - cm_check_cxx_feature(filesystem) + cm_check_cxx_feature(filesystem TRY_RUN) else() set(CMake_HAVE_CXX_FILESYSTEM FALSE) endif() diff --git a/Source/Checks/cm_cxx_filesystem.cxx b/Source/Checks/cm_cxx_filesystem.cxx index e508d1c969..ae8acc56a6 100644 --- a/Source/Checks/cm_cxx_filesystem.cxx +++ b/Source/Checks/cm_cxx_filesystem.cxx @@ -3,8 +3,25 @@ int main() { + std::filesystem::path p0(L"/a/b/c"); + std::filesystem::path p1("/a/b/c"); std::filesystem::path p2("/a/b/c"); + if (p1 != p2) { + return 1; + } + +#if defined(_WIN32) + std::filesystem::path p3("//host/a/b/../c"); + if (p3.lexically_normal().generic_string() != "//host/a/c") { + return 1; + } + + std::filesystem::path p4("c://a/.///b/../"); + if (p4.lexically_normal().generic_string() != "c:/a/") { + return 1; + } +#endif - return p1 == p2 ? 0 : 1; + return 0; } |