Cmake改变堆栈大小 |
您所在的位置:网站首页 › vs设置堆栈大小 › Cmake改变堆栈大小 |
百度翻译此文
有道翻译此文
问题描述
Is there a way to change stack size from the Cmake ? I only found one forum thread mentioning CMAKE_CXX_STACK_SIZE but I couldn't find the documentation for this command. Ideally the command should work for both Visual Studio C++ and gcc. 推荐答案I don't have VS at the moment, but the following three CMake commands all work for me on MinGW/GCC (replace with what you entered into add_executable()): target_link_libraries( PRIVATE "-Wl,--stack,10000000")OR set_target_properties( PROPERTIES LINK_FLAGS -Wl,--stack,10000000)OR set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,10000000")Note that according to the CMake documentation, each of these should just add linker flags, not replace any that are already set. In VS, it looks like you should replace -Wl,--stack, with /STACK: (more on this below) and use an if/else to have different commands for each compiler. Regarding CMAKE_CXX_STACK_SIZE, this thread, which is worth a read, says the command is in the implementation of the VS generator for historical reasons but is not intended as a first-class way to set the stack size. Instead just pass /STACK:... as a linker flag using target_link_libraries, or the LINK_FLAGS target property, or in CMAKE_EXE_LINKER_FLAGS... Such a command can actually be seen on the page linked in your post (not sure if you saw it) as well as in this one: set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10000000") |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |