尝试使cmake add_compile_options工作
我正在尝试一个非常简单的示例与cmake使用add_compile_options
指示
cmakelists.txt:
add_compile_options(-Wall)
MESSAGE("COMPILE OPTIONS ${COMPILE_OPTIONS}")
add_executable(test main.cpp)
其中main.cpp是某个(空)主函数。我进行
rm -r CMakeFiles/ cmake_install.cmake Makefile test CMakeCache.txt
cmake CMakeLists.txt
make VERBOSE=1
cmake输出,例如:
<snip>
-- The C compiler identification is GNU 7.5.0
<snip>
-- Detecting CXX compile features - done
COMPILE OPTIONS
<snip>
-- Build files have been written to: /a_directory/test
注意行compile_options
显示一个空变量,我理解add_compile_options
指令应设置。回报
<snip>
[100%] Linking CXX executable test
/a_path/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
/usr/bin/c++ -L/a/libdir -L/another/libdir -rdynamic CMakeFiles/test.dir/main.o -o test
<snip>
,没有-wall
我在做什么错? NB:CMAKE版本3.15.3
I am trying a very simple example with cmake to use the add_compile_options
directive
CMakeLists.txt:
add_compile_options(-Wall)
MESSAGE("COMPILE OPTIONS ${COMPILE_OPTIONS}")
add_executable(test main.cpp)
where main.cpp is some (empty) main function. I do
rm -r CMakeFiles/ cmake_install.cmake Makefile test CMakeCache.txt
cmake CMakeLists.txt
make VERBOSE=1
cmake output like:
<snip>
-- The C compiler identification is GNU 7.5.0
<snip>
-- Detecting CXX compile features - done
COMPILE OPTIONS
<snip>
-- Build files have been written to: /a_directory/test
Note the line COMPILE_OPTIONS
shows an empty variable which I understand the add_compile_options
directive should set. make returns
<snip>
[100%] Linking CXX executable test
/a_path/cmake -E cmake_link_script CMakeFiles/test.dir/link.txt --verbose=1
/usr/bin/c++ -L/a/libdir -L/another/libdir -rdynamic CMakeFiles/test.dir/main.o -o test
<snip>
and there is no -Wall
what am I doing wrong? Nb: cmake version 3.15.3
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论