[CMake] 'NMake Makefiles' generate does not support parallel builds (/MP)?

Loaden loaden at gmail.com
Sat Sep 22 00:58:13 EDT 2012


Because I want share the MSVC's PCH files, so I have to set the compile PDB
name:

>     get_filename_component(pdbpath ${${targetBinary}_PCH_BINARY_FILE} PATH)
>     get_target_property(targetCompileFlags ${targetSelf} COMPILE_FLAGS)
>     if (targetCompileFlags)
>         set(origCompileFlags ${targetCompileFlags})
>     endif()
>     set_target_properties(${targetSelf} PROPERTIES
>         COMPILE_FLAGS "${origCompileFlags}
> /Fd\"${pdbpath}/${targetBinary}.pdb\""
>     )
>

For NMake Makefiles generator, it works after change:

>     string(REGEX REPLACE " /Fd<TARGET_PDB>" "" temp
> "${CMAKE_${${targetBinary}_PCH_LANGUAGE}_COMPILE_OBJECT}")
>     set(CMAKE_${${targetBinary}_PCH_LANGUAGE}_COMPILE_OBJECT ${temp}
> PARENT_SCOPE)
>

It mean I can change the PDB file name using a hacking way:

> *string(REGEX REPLACE " /Fd<TARGET_PDB>" "" CMAKE_CXX_COMPILE_OBJECT
> "${CMAKE_CXX_COMPILE_OBJECT}")*
>
But it does not work with Ninja generator.

FAILED: "D:/qpSOFT/MyDEV/tool/cmake/cmcldeps.exe" CXX
> ..\src\libs\languageutils\fakemetaobject.cpp
> "src/libs/languageutils/CMakeFiles/LanguageUtils.dir/fakemetaobject.cpp.obj.d"
> src\libs\languageutils\CMakeFiles\LanguageUtils.dir\fakemetaobject.cpp.obj
> "Note: including file: " "D:/qpSOFT/MyDEV/bin/amd64/cl.exe"
> D:\qpSOFT\MyDEV\bin\amd64\cl.exe   /nologo /DWIN32 /D_WINDOWS /W3 /Zm1000
> /EHsc /GR /D_DEBUG /MDd /Zi /Ob0 /Od /RTC1
> -ID:\qpSOFT\MyDEV\sdk\qt\lib\amd64\..\..\include\
> -ID:\qpSOFT\MyDEV\sdk\qt\lib\amd64\..\..\include\QtCore
> -ID:\qpSOFT\MyDEV\sdk\qt\lib\amd64\..\..\mkspecs\amd64\win32-msvc2010
> */Fd"D:/qpSOFT/Projects/QtCreator/a/src/qtcreator_pch_helper.pdb" */Yu"D:/qpSOFT/Projects/QtCreator/a/src/qtcreator_pch_helper_pch.pch"
> /FI"D:/qpSOFT/Projects/QtCreator/a/src/qtcreator_pch_helper_pch.pch"
> /Fp"D:/qpSOFT/Projects/QtCreator/a/src/qtcreator_pch_helper_pch.pch"
> -DLanguageUtils_EXPORTS -DUNICODE -D_CRT_SECURE_NO_WARNINGS
> -DQT_DISABLE_DEPRECATED_BEFORE=0x040900 -DQT_CREATOR
> -DLANGUAGEUTILS_BUILD_DIR -DQT_CORE_LIB /TP
> /Fosrc\libs\languageutils\CMakeFiles\LanguageUtils.dir\fakemetaobject.cpp.obj
> */Fdbin\LanguageUtils.pdb* -c ..\src\libs\languageutils\fakemetaobject.cpp
> cl : Command line warning D9025 : overriding
> '/FdD:/qpSOFT/Projects/QtCreator/a/src/qtcreator_pch_helper.pdb' with
> '/Fdbin\LanguageUtils.pdb'
> ..\src\libs\languageutils\fakemetaobject.cpp : error C2858: command-line
> option 'program database name
> (/Fdd:\qpsoft\projects\qtcreator\a\bin\languageutils.pdb)' inconsistent
> with precompiled header, which used
> '/Fdd:\qpsoft\projects\qtcreator\a\src\qtcreator_pch_helper.pdb'
> ..\src\libs\languageutils\fakemetaobject.cpp : error C2859:
> d:\qpsoft\projects\qtcreator\a\bin\languageutils.pdb is not the pdb file
> that was used when this precompiled header was created, recreate the
> precompiled header.
>
> ninja: build stopped: subcommand failed.
>

Could you please give me any tips?
I look into the build.ninja file, and see there are many "TARGET_PDB =
XXX.pdb" lines.
The PDB file is hard code  to target name.

So, the question may be changed to: How to change the PDB file name of
Ninja generator?

I read the rules.ninja file too, there seems exist a rules for compilation.
But I don't know how to change the rules.

#############################################
> # Rule for compiling CXX files.
>
> rule CXX_COMPILER
>   depfile = $DEP_FILE
>   command = "D:/qpSOFT/MyDEV/tool/cmake/cmcldeps.exe" CXX $in "$DEP_FILE"
> $out "Note: including file: " "D:/qpSOFT/MyDEV/bin/amd64/cl.exe"
> D:\qpSOFT\MyDEV\bin\amd64\cl.exe   /nologo $FLAGS  $DEFINES /TP /Fo$out *
> /Fd$TARGET_PDB* -c $in
>   description = Building CXX object $out
>

Thanks for any comments / helps.
*
*
2012/9/22 Loaden <loaden at gmail.com>

> It's works great on Linux, but has some issue for MSVC about share the
> precompiled header files.
> NMake works well with that.
>



-- 
Best Regards
Yuchen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120922/d7ce6b07/attachment.htm>


More information about the CMake mailing list