According to the documents for MP in the MSVC website MP takes an optional digit to limit the number of parallel compilation units a single target will generate at a time. I wanted to always turn on MP for my users, but allow them to optionally limit the number of threads by using a variable in the cache. So in my bigger libraries we automatically include the following.
target_compile_options(libbiogears_cdm PRIVATE $<$<PLATFORM_ID:Windows>:/bigobj> PRIVATE $<$<PLATFORM_ID:Windows>:/MP${Biogears_BUILD_PARALLEL_LEVEL}>)
The problem I have is that while hard coding a number like /MP5 seems to work the following code seems to just ignore the limiter when it is present and just use all available threading. The second thing I don’t understand is where to look up in the MSVC UI if the correct flag is being sent. When I run the following code. The Properties page C++ -> Multi-processor Compilation
has a value of yes, but there is no place for the GUI to report the value of the limiter and when I look at the compiler flags C++->Command Line
MP is the first option but has no parameter
/MP /GS /W3 /Zc:wchar_t /I"D:\remotes\sed-stash\core\worktrees\libpy\projects\biogears\libBiogears\include" /I"D:\remotes\sed-stash\core\worktrees\libpy\projects\biogears\libBiogears\src" /I"D:\remotes\sed-stash\core\worktrees\libpy\build-msvc16\projects\biogears" /I"D:\remotes\sed-stash\core\worktrees\libpy\build-msvc16\projects\biogears-common" /I"D:\remotes\sed-stash\core\worktrees\libpy\projects\biogears-common\include" /I"D:\remotes\sed-stash\core\worktrees\libpy\projects\biogears\libCDM\include" /I"D:\remotes\sed-stash\external\windows-vc16-amd64\include\eigen3" /I"D:\remotes\sed-stash\external\windows-vc16-amd64\include" /Gm- /O2 /Ob2 /Fd"D:\remotes\sed-stash\core\worktrees\libpy\build-msvc16\outputs\Release\bin\libbiogears.pdb" /Zc:inline /fp:precise /D "WIN32" /D "_WINDOWS" /D "NDEBUG" /D "_SCL_SECURE_NO_WARNINGS" /D "_CRT_SECURE_NO_WARNINGS" /D "NOMINMAX" /D "BIOGEARS_THROW_READONLY_EXCEPTIONS" /D "BIOGEARS_THROW_NAN_EXCEPTIONS" /D "LOG4CPP_HAS_DLL" /D "BIOGEARS_COMMON_BUILD_STATIC" /D "CMAKE_INTDIR=\"Release\"" /D "biogears_EXPORTS" /D "_WINDLL" /D "_MBCS" /errorReport:prompt /WX- /Zc:forScope /GR /Gd /MD /std:c++14 /Fa"libbiogears.dir\Release\" /EHsc /nologo /Fo"libbiogears.dir\Release\" /Fp"libbiogears.dir\Release\libbiogears.pch" /diagnostics:column
To further complicate this if I replace ${Biogears_BUILD_PARALLEL_LEVEL} with 5 then after a regeneration step the UI looks the same but the task manager clearly shows only 5 files being compiled at a time. So, I have two questions.
- Should the variable expansion in a generator expression work as in the above code?
- Does anyone know what file or where in the UI can confirm the MP limit if one is given to speed up debugging of the issue?