c3c icon indicating copy to clipboard operation
c3c copied to clipboard

CMakeSettings.json in repository may conflict with user settings

Open Andersama opened this issue 3 years ago • 6 comments

In order to compile on my windows system I had to regenerate the CMakeSettings.json file, in my case the path to llvm libraries was wrong. I don't think you need to provide it, it seems the commit to add MSVC compatibility doesn't need the cmakeCommandArgs line to be filled. I could be wrong.

{
  "configurations": [
    {
      "name": "x64-Debug",
      "generator": "Ninja",
      "configurationType": "Debug",
      "inheritEnvironments": [ "msvc_x64_x64" ],
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "-v",
      "ctestCommandArgs": ""
    },
    {
      "name": "x64-Release",
      "generator": "Ninja",
      "configurationType": "RelWithDebInfo",
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "-v",
      "ctestCommandArgs": "",
      "inheritEnvironments": [ "msvc_x64_x64" ],
      "variables": []
    }
  ]
}

Here for example is how my settings file looks after MSVC recreated it. I added the "-v", not sure that it makes much difference, but it might be a step to note for people opening the project directly in MSVC.

Andersama avatar Jul 09 '22 21:07 Andersama

I didn't commit this one actually and I don't know if it's necessary. What happens if you remove it entirely?

lerno avatar Jul 10 '22 21:07 lerno

I'm not sure that MSVC lets you do anything without the CMakeSettings.json file, deleting it and trying to manage anything related to cmake has it generate:

{
  "configurations": [
    {
      "name": "x64-Debug",
      "generator": "Ninja",
      "configurationType": "Debug",
      "inheritEnvironments": [ "msvc_x64_x64" ],
      "buildRoot": "${projectDir}\\out\\build\\${name}",
      "installRoot": "${projectDir}\\out\\install\\${name}",
      "cmakeCommandArgs": "",
      "buildCommandArgs": "",
      "ctestCommandArgs": ""
    }
  ]
}

It seems functional, I'm not familiar with what "-v" does still. It looks like so long as LLVM and LLD libraries can be found with find_library in cmake it should just work?

Andersama avatar Jul 14 '22 20:07 Andersama

The thing is that "Ninja" as a generator isn't even the one used with the recommended MSVC build, so it seems like this one is completely wrong?

lerno avatar Jul 15 '22 23:07 lerno

I'm not exactly an expert in cmake config files, at least on my end opening the directory in MSVC (without the .json file) works. At this point I'm struggling with c3c's default project from c3c init which seemingly has some wildcard folder for libraries, but does not appear to handle wildcards.

Error reading project.c3p: invalid library target 'lib/**'.

Andersama avatar Jul 18 '22 22:07 Andersama

Change it to "libs": [], this issue was fixed recently and creating a project with c3c init with the latest version of the compiler should be correct.

lerno avatar Jul 19 '22 09:07 lerno

Tried a few more configurations, it seems when I switched to x64-clang-release cmake complained about the missing setting. The same cmake code which finds the llvm libraries for msvc might work when using clang specifically instead.

Andersama avatar Jul 20 '22 20:07 Andersama

I'll accept pull requests to improve this if needed.

lerno avatar Sep 21 '22 16:09 lerno