0

So I have built an open source project Using CMake and opened it in Visual Studio but I get this error:

Command line error D8021: invalid numeric argument '/Wl,--stack,4194304'

My CMakeLists.txt that has this:

if(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--stack,4194304 -fpermissive") endif()

I am not sure what is this or how it can be fixed. Any help is appreciated

Joe Robert
  • 79
  • 1
  • 7

1 Answers1

1

You are giving your Visual Studio compiler switches that are intended for GCC.

if (WIN32)
  if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--stack,4194304 -fpermissive")
  elseif(MSVC)
    # add options for Visual C/C++ Compiler here
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /F 4194304")
  endif()
endif()

See also In cmake, how can I test if the compiler is Clang? how to reliable identify your compiler.

For the permissive flag please see Visual Studio (2015) fpermissive equivalent flag .

Edit: Added more reliable compiler check for GCC according to discussion.

vre
  • 6,041
  • 1
  • 25
  • 39