Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

cmake invalid numeric argument '/Wextra'

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,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...