<div dir="ltr">Hi,<div><br></div><div>I had a quick check to see if CMake 3.10 for which compilers it has support for <a href="https://cmake.org/cmake/help/v3.10/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.html#prop_tgt:INTERPROCEDURAL_OPTIMIZATION">Interprocedural Optimization</a> (IPO, or LTCG as known on Visual C++).</div><div><br></div><div>Modules/Compiler had only for <b>GNU</b>, <b>Clang</b> and <b>PGI</b> the following:</div><div><font face="monospace, monospace">set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES)</font><br></div><div><br></div><div>QNX with QCC didn't have it set to YES even though nowdays QNX comes with GCC 5.4.0 on QNX 7.0, which should be just fine.</div><div><br></div><div>It would be nice if CMake would have support for IPO on Visual C++.</div><div><br></div><div>The steps would be to set the right variables into Modules/Compiler/MSVC-CXX.cmake, change the <a href="https://cmake.org/cmake/help/v3.10/module/CheckIPOSupported.html?#module:CheckIPOSupported">CheckIPOSupported</a> module, change some flags in some places,update tests, documentation, and so on.</div><div><br></div><div>Shouldn't be hard to add this feature.</div><div><br></div><div>Cheers,</div><div>Cristian.</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 24, 2018 at 9:06 PM, Niels Dekker <span dir="ltr"><<a href="mailto:niels_dekker_address_until_2024@xs4all.nl" target="_blank">niels_dekker_address_until_2024@xs4all.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">When a Visual C++ project is created within Visual Studio (by File menu, New, Project...), it has Link Time Code Generation (LTGC) by default, for its Release configurations: Compiler option /GL and linker option /LTCG. However, when the Visual C++ project is generated by CMake, it does not have LTGC, by default. LTCG looks like a very useful feature to me. I think it's worth enabling the feature by default, for Release configurations. What do you think?<br>
<br>
<br>
Some details:<br>
<br>
I created a "dummy" Visual C++ project in Visual Studio 2017 (Version 15.5.4), by File menu, New, Project..., and I also generated one by CMake (version 3.10.2), using a very minimal CMakeLists.txt<br>
<br>
The Visual C++ project created by Visual Studio 2017 has the following compile options, by default, for Release (x64):<br>
<br>
/permissive- /GS /GL /W3 /Gy /Zc:wchar_t /Zi /Gm- /O2 /sdl /Fd"x64\Release\vc141.pdb" /Zc:inline /fp:precise /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /Gd /Oi /MD /Fa"x64\Release\" /EHsc /nologo /Fo"x64\Release\" /Fp"x64\Release\MyVS2015Projec<wbr>t.pch" /diagnostics:classic<br>
<br>
And the following linker options:<br>
<br>
/OUT:"F:\X\Src\MyProject\MyVS2<wbr>015Project\x64\Release\MyVS201<wbr>5Project.exe" /MANIFEST /LTCG:incremental /NXCOMPAT /PDB:"F:\X\Src\MyProject\MyVS2<wbr>015Project\x64\Release\MyVS201<wbr>5Project.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" /DEBUG:FULL /MACHINE:X64 /OPT:REF /PGD:"F:\X\Src\MyProject\MyVS2<wbr>015Project\x64\Release\MyVS201<wbr>5Project.pgd" /MANIFESTUAC:"level='asInvoker<wbr>' uiAccess='false'" /ManifestFile:"x64\Release\MyV<wbr>S2015Project.exe.intermediate.<wbr>manifest" /OPT:ICF /ERRORREPORT:PROMPT /NOLOGO /TLBID:1<br>
<br>
The vcxproj file created by Visual Studio has "<WholeProgramOptimization>tru<wbr>e</WholeProgramOptimization>" for its Release configurations.<br>
<br>
<br>
The Visual C++ project generated by CMake (Generator: Visual Studio 15 2017 Win64) has the following compile options, for its Release configuration:<br>
<br>
/GS /TP /W3 /Zc:wchar_t /Gm- /O2 /Ob2 /Fd"MyExecutable.dir\Release\v<wbr>c141.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "CMAKE_INTDIR=\"Release\"" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD /Fa"Release/" /EHsc /nologo /Fo"MyExecutable.dir\Release\" /Fp"MyExecutable.dir\Release\M<wbr>yExecutable.pch" /diagnostics:classic<br>
<br>
And the following linker options:<br>
<br>
/OUT:"F:\X\Bin\vc141-64\MyProj<wbr>ect\Release\MyExecutable.exe" /MANIFEST /NXCOMPAT /PDB:"F:/X/Bin/vc141-64/MyProj<wbr>ect/Release/MyExecutable.pdb" /DYNAMICBASE "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "comdlg32.lib" "advapi32.lib" /IMPLIB:"F:/X/Bin/vc141-64/MyP<wbr>roject/Release/MyExecutable.<wbr>lib" /MACHINE:X64 /INCREMENTAL:NO /PGD:"F:\X\Bin\vc141-64\MyProj<wbr>ect\Release\MyExecutable.pgd" /SUBSYSTEM:CONSOLE /MANIFESTUAC:"level='asInvoker<wbr>' uiAccess='false'" /ManifestFile:"MyExecutable.di<wbr>r\Release\<a href="http://MyExecutable.exe.int">MyExecutable.exe.int</a><wbr>ermediate.manifest" /ERRORREPORT:PROMPT /NOLOGO /TLBID:1<br>
<br>
The vcxproj file generated by CMake does not have a "<WholeProgramOptimization>" tag.<br>
<br>
<br>
I hope you can consider adding LTCG to Release configurations of Visual C++ projects generated by CMake, by default.<br>
<br>
<br>
Kind regards, Niels<br>
-- <br>
Niels Dekker<br>
Scientific programmer<br>
LKEB, Leiden University Medical Center<br>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMak<wbr>e_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/su<wbr>pport.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/co<wbr>nsulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/tr<wbr>aining.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensou<wbr>rce/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/list<wbr>info/cmake</a><br>
</blockquote></div><br></div>