Here is my code on windows OS:
cmake_minimum_required (VERSION 3.19)
set (CMAKE_CXX_FLAGS “”)
set (CMAKE_CXX_FLAGS_DEBUG “”)
hello.cpp got compiled in the following way:
CL.exe /c /nologo /W1 /WX- /diagnostics:classic /O2 /Oy- /D “CMAKE_INTDIR=“Debug”” /D _MBCS /Gm- /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"hello.dir\Debug\" /Fd"hello.dir\Debug\vc141.pdb" /Gd /TP /analyze- /errorReport:queue C:\Users\sayoun\work\tmp\hello.cpp
cmake is adding “/W1 /WX- /O2 /Oy- MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline” although those were specifically emptied.
- How do I reset completely the compilation flags - I do not want cmake to intervene and I would like to be able to do that for either debug or release configurations: complete control.
- I would like to do the same with the linker options: not having cmake doing wise but wrong decisions.
- Compilation / linking flags seem to be a complicated topic with add_options / target_add_option / CMAKE_FLAGS variable setting and also the COMPILE_OPTIONS property - all those are involved to set the final compilation command in some order and priorities. Is there a clear documentation that explains how is this done by cmake.