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

查看:7315
本文介绍了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配置/生成解决方案文件。一切就OK了。

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

然而,当我打开解决方案文件并从菜单中选择build时,我得到以下错误。

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天全站免登陆