Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Studio interaction with CMake presets #569

Open
jcar87 opened this issue Oct 3, 2023 · 1 comment
Open

Visual Studio interaction with CMake presets #569

jcar87 opened this issue Oct 3, 2023 · 1 comment

Comments

@jcar87
Copy link
Contributor

jcar87 commented Oct 3, 2023

  • user's project already has a CMakePresets.json that specifies / defines the dependency provider as a cmake cache variable
  • Conan generates a CMakePresets that causes Visual Studio IDE to use that instead

cc: @Ahajha

@Ahajha
Copy link

Ahajha commented Oct 3, 2023

Specifically, I am using CMakePresets for the dependency provider preset. For reference, I have this:

{
  "version": 3,
  "configurePresets": [
    {
      "architecture": {
        "value": "x64",
        "strategy": "external"
      },
      "binaryDir": "${sourceDir}/out/build/${presetName}",
      "cacheVariables": {
        "CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "~/Documents/cmake-conan/conan_provider.cmake",
        "CMAKE_BUILD_TYPE": "Debug",
        "CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
      },
      "description": "Sets Ninja generator, compilers, x64 architecture, build and install directory, debug build type",
      "displayName": "CMake + Conan: Debug",
      "generator": "Ninja",
      "name": "windows-default",
      "vendor": {
        "microsoft.com/VisualStudioSettings/CMake/1.0": {
          "hostOS": [ "Windows" ]
        }
      }
    }
  ]
}

(I have the path to cmake-conan hardcoded to a known global location, adjust as needed)

What happens is:

  1. Configure CMake with the given preset
  2. CMake calls Conan
  3. Conan generates or writes to CMakeUserPresets.json
  4. Visual Studio detects the 'change', so it reconfigures CMake, restarting the loop

Workaround is to disable generating the presets file on a per-conanfile basis, but would be nice to be able to disable generation globally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants