[CMake] Different behavior between building using "cmake --build" and building in Visual Studio

SergSuslenkov serg at suslenkov.com
Thu May 9 05:45:19 EDT 2019


Hi Nick,

Not sure if it is relevant for you, but for other who will search.

I have the same problem.
What I found:

1. When you issue "cmake --build", it runs following command line:
msbuild ALL_BUILD.vcxproj /p:Platform=Win32 ...

So it is not a solution file, that have rules to match configurations, but a
ALL_BUILD project file.

2. inside each *.vcxproj, there is a section(s)
    <ProjectReference Include="<path_to>\ZERO_CHECK.vcxproj">
      <Project>{979FF7F1-351C-30B2-9F05-100EBC38B87E}</Project>
      <Name>ZERO_CHECK</Name>
    </ProjectReference>

  There is reference for each dependent projects.

3. ms build is using this information to build project and all its
dependencies.

4. however, <ProjectReference ..> does not contain configuration matching
rules (set with MAP_IMPORTED_CONFIG_XXX)

5. there is a way to specify configuration in ProjectReference, but VS
generator in CMake does not have this ability.
5.1. Way to specify:
https://stackoverflow.com/questions/6624168/configuration-for-projectreference-in-msbuild
<ProjectReference Include="path to project.projext">
  <SetPlatform>Platform=x64</SetPlatform>
  <SetConfiguration>Configuration=Release</SetConfiguration>
</ProjectReference>

Conclusion: I don't think that CMake can do it right now.
I plan to add Debug/Release targets on my proprietary provided projects.
Probably this can be address in future version of CMake.

Regards,
Serg



--
Sent from: http://cmake.3232098.n2.nabble.com/


More information about the CMake mailing list