Knitschi / CPFCMake

A component of the CMakeProjectFramework. It provides the CMake code that implements a CI-pipeline.
MIT License
2 stars 2 forks source link

Consider using a CMakeSettings.json file like it is used in VS2017 instead of using our own cpfCIBuildConfigurations.json and <config>.cmake files. #45

Closed Knitschi closed 5 years ago

Knitschi commented 5 years ago

VS2017 in CMake mode allows keeping multiple configurations in a CMakeSettings.json file. It more or less holds the information that we now keep in our .cmake file + cmake command line arguments.

If we could use that format we would support Visual Studio out of the box. Our .json file however also contains information about on which system the build should happen. Can this information be added to the CMakeSettings.json file without breaking it?

Knitschi commented 5 years ago

Currently only VS2017 supports this.

Knitschi commented 5 years ago
Knitschi commented 5 years ago

Result

Advantages of CMake mode

Problems

Other findings

Manual implementation

In order to test the cmake mode of Visual Studio I added the following CMakeSettings.json file to ACPFTestProject.

{
  "configurations": [
    {
      "name": "VS2017-shared",
      "generator": "Ninja",
      "configurationType": "Debug",
      "inheritEnvironments": [ "msvc_x64_x64" ],
      "buildRoot": "C:/dev/ACPFTestProject/Generated/Ninja",
      "installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
      "cmakeCommandArgs": "-C\"../../Configuration/VS2017-shared.config.cmake\" --graphviz=\"CPFDependencies.dot\"",
      "buildCommandArgs": "-j 32",
      "ctestCommandArgs": "",
      "ConfigName": "Clang-shared-debug",
      "BuildSlaveLabel": "Debian-8.9-0.0.0"
    }
  ]
}

I also changed the value of the CMAKE_GENERATOR variable in the config file to Ninja.

Conclusion

Currently I don't think that the benefits are worth the required efford and ugliness of a generated file in the source tree. Currently I am happy with using the traditional solution xml files while working on windows. As it is possible to add custom variables to the CMakeSettings.json it could possibly replace the cpfCIBuildConfigurations.json file.