summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CompileFlags.cmake15
-rw-r--r--Source/CMakeLists.txt12
-rw-r--r--Source/cmConfigure.cmake.h.in2
-rw-r--r--Source/cmMakefile.cxx18
4 files changed, 27 insertions, 20 deletions
diff --git a/CompileFlags.cmake b/CompileFlags.cmake
index 6331af1..f94e079 100644
--- a/CompileFlags.cmake
+++ b/CompileFlags.cmake
@@ -8,7 +8,7 @@ if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")
set(_INTEL_WINDOWS 1)
endif()
-if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Clang"
+if(WIN32 AND CMAKE_C_COMPILER_ID MATCHES "^(Clang|IntelLLVM)$"
AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
set(_CLANG_MSVC_WINDOWS 1)
endif()
@@ -22,18 +22,19 @@ if(MSVC OR _INTEL_WINDOWS OR _CLANG_MSVC_WINDOWS)
else()
endif()
-if(MSVC)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_CXX_LINKER_WRAPPER_FLAG}-stack:10000000")
-endif()
-
# MSVC 14.28 enables C5105, but the Windows SDK 10.0.18362.0 triggers it.
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 19.28)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -wd5105")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd5105")
endif()
-if(_CLANG_MSVC_WINDOWS AND "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker -stack:20000000")
+# Use a stack size large enough for CMake_DEFAULT_RECURSION_LIMIT.
+if(MSVC)
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " ${CMAKE_CXX_LINKER_WRAPPER_FLAG}-stack:10000000")
+elseif(MINGW OR MSYS OR CYGWIN)
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " -Wl,--stack,10000000")
+elseif(_CLANG_MSVC_WINDOWS AND "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
+ string(APPEND CMAKE_EXE_LINKER_FLAGS " -Xlinker -stack:20000000")
endif()
#silence duplicate symbol warnings on AIX
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index a25329c..33514ba 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -11,18 +11,6 @@ endif()
include(CheckIncludeFile)
-if(NOT CMake_DEFAULT_RECURSION_LIMIT)
- if(MINGW OR MSYS)
- set(CMake_DEFAULT_RECURSION_LIMIT 400)
- elseif(WIN32 AND CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64")
- set(CMake_DEFAULT_RECURSION_LIMIT 400)
- elseif(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
- set(CMake_DEFAULT_RECURSION_LIMIT 600)
- else()
- set(CMake_DEFAULT_RECURSION_LIMIT 1000)
- endif()
-endif()
-
if(APPLE)
set(CMake_USE_MACH_PARSER 1)
endif()
diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in
index 90f3de0..3f19a11 100644
--- a/Source/cmConfigure.cmake.h.in
+++ b/Source/cmConfigure.cmake.h.in
@@ -23,7 +23,7 @@
#cmakedefine CMake_USE_MACH_PARSER
#cmakedefine CMake_USE_XCOFF_PARSER
#cmakedefine CMAKE_USE_WMAKE
-#define CMake_DEFAULT_RECURSION_LIMIT @CMake_DEFAULT_RECURSION_LIMIT@
+#cmakedefine CMake_DEFAULT_RECURSION_LIMIT @CMake_DEFAULT_RECURSION_LIMIT@
#define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@"
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
#define CMAKE_DOC_DIR "/@CMAKE_DOC_DIR@"
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 638da06..f37268d 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -67,6 +67,24 @@
# include "cmVariableWatch.h"
#endif
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+
+// Select a recursion limit that fits within the stack size.
+// See stack size flags in '../CompileFlags.cmake'.
+#ifndef CMake_DEFAULT_RECURSION_LIMIT
+# if __has_feature(address_sanitizer)
+# define CMake_DEFAULT_RECURSION_LIMIT 400
+# elif defined(_MSC_VER) && defined(_DEBUG)
+# define CMake_DEFAULT_RECURSION_LIMIT 600
+# elif defined(__ibmxl__) && defined(__linux)
+# define CMake_DEFAULT_RECURSION_LIMIT 600
+# else
+# define CMake_DEFAULT_RECURSION_LIMIT 1000
+# endif
+#endif
+
class cmMessenger;
cmDirectoryId::cmDirectoryId(std::string s)