cmake invalid numeric argument '/Wextra'

2020-02-12 02:52发布

Windows XP Pro 32bit

Visual studio 2008 VC Express edition.

I have installed cmake and created the CMakeLists.txt and I want to cross-platform for Linux/windows.

Everything works ok for running on linux. So I copied my source directory as I am doing out of source building to my windows xp machine.

I used the cmake-GUI to configure/generate the solution files. Everything ok there.

However, when I opened the solution file and selected build from menu I got the following error.

cl : Command line error D8021 : invalid numeric argument '/Wextra'

Not sure really where to start looking to solve this error. If any one can point me in the right direction.

Many thanks for any suggestions,

标签: cmake
1条回答
Melony?
2楼-- · 2020-02-12 03:01

Your CMakeLists.txt defines compile flag -Wextra for GCC and then CMake tried to use that on cl (the Microsoft compiler) too. Fix the CMakeLists.txt so that it tests for compiler before setting warning flags, i.e.

# Set default compile flags for GCC
if(CMAKE_COMPILER_IS_GNUCXX)
    message(STATUS "GCC detected, adding compile flags")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98 -pedantic -Wall -Wextra")
endif(CMAKE_COMPILER_IS_GNUCXX)
查看更多
登录 后发表回答