cmake无效的数字参数'/Wextra' [英] cmake invalid numeric argument '/Wextra'

查看:34
本文介绍了cmake无效的数字参数'/Wextra'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows XP Pro 32 位

Windows XP Pro 32bit

Visual Studio 2008 VC Express 版.

Visual studio 2008 VC Express edition.

我已经安装了 cmake 并创建了 CMakeLists.txt,我想跨平台使用 Linux/windows.

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

在 linux 上运行一切正常.所以我将我的源目录复制到我的 windows xp 机器上.

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.

我使用 cmake-GUI 来配置/生成解决方案文件.那里一切正常.

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,

推荐答案

您的 CMakeLists.txt 为 GCC 定义了编译标志 -Wextra,然后 CMake 也尝试在 cl(Microsoft 编译器)上使用它.修复 CMakeLists.txt 以便在设置警告标志之前测试编译器,即

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)

这篇关于cmake无效的数字参数'/Wextra'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆