From 2b7fb78c758734f7dbc5721416f2bf89ac7e4925 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 15 Mar 2010 15:01:21 +0000 Subject: [PATCH] From Farshid Lashkari, "I noticed that CMake forces a high stack size by default for all MSVC projects. This can cause problems for applications that use a lot of threads. I've added a new option MSVC_USE_DEFAULT_STACK_SIZE that will remove the explicit stack size and use the default MSVC size. Apparently this was only necessary for very old versions of MSVC but it's still around. I would argue that this option should be on by default, but I've left it off for now. " --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00f6ea1e2..4df175ed4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,6 +206,15 @@ IF(WIN32) IF(MSVC_DISABLE_CHECKED_ITERATORS) ADD_DEFINITIONS(-D_SECURE_SCL=0) ENDIF(MSVC_DISABLE_CHECKED_ITERATORS) + + OPTION(MSVC_USE_DEFAULT_STACK_SIZE "Set to ON to use the default Visual C++ stack size. CMake forces a high stack size by default, which can cause problems for applications with large number of threads." OFF) + MARK_AS_ADVANCED(MSVC_USE_DEFAULT_STACK_SIZE) + IF(MSVC_USE_DEFAULT_STACK_SIZE) + STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + STRING(REGEX REPLACE "/STACK:[0-9]+" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}") + ENDIF(MSVC_USE_DEFAULT_STACK_SIZE) + ENDIF() #needed for net plugin