【发布时间】:2016-11-09 22:05:07
【问题描述】:
我试图通过 add_compile_options 将 cmake 与以下编译选项一起使用:add_compile_options(-pipe -O2 -std=c++98 -W -Wall -pedantic)
但是在编译的时候好像并没有实际使用。
make -n | grep pedantic 不返回任何内容
仅供参考,我的 cmake 命令及其返回的内容:
cmake -G"Unix Makefiles" -DARCH:STRING=x86 -Bosef -H. -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++
-- The C compiler identification is GNU 4.8.3
-- The CXX compiler identification is GNU 4.8.3
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++
-- Check for working CXX compiler: /usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- cmake run for linux x86
-- Configuring done
-- Generating done
-- Build files have been written to: /home/davidlevy/WS/LC4/main/osef
我该怎么做才能真正应用这些选项?
PS : 我注意到它们没有被应用,因为 make 没有输出一个警告
编辑:如果我使用
set (
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} "
"${CMAKE_CXX_FLAGS} -pipe -O2 -std=c++98 -W -Wall -pedantic"
)
Make /usr/bin/g++ ; -pipe -O2 -std=c++98 -W -Wall -pedantic -I ENDOFTHECOMMAND 我不知道这是在哪里做的;来自
【问题讨论】:
-
您需要什么零件的示例?并且 Verbose 证实了我的想法,没有给 g++ 提供编译选项
-
我们可以复制到我们的系统并试用的最小示例。您没有包含问题最可能所在的 CMake 代码,参见。 stackoverflow.com/help/mcve.