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

CMake support #44

Merged
merged 8 commits into from
Apr 1, 2021
Merged

CMake support #44

merged 8 commits into from
Apr 1, 2021

Conversation

friendlyanon
Copy link
Contributor

This PR enables clients using CMake to consume this library in a trivial manner.

For rationale behind the changes, please look at my recent PRs and discussions in FunctionalPlus, where I added similar support.

@rileylev
Copy link

Any updates?

@friendlyanon
Copy link
Contributor Author

I cleaned up things further.

Regarding the developer mode, you can just add a CMakeUserPresets.json file to the repo (but not checked in, so add it to gitignore) to have a convenient developer experience. Such a preset would allow you to trivially configure cmake:

{
  "version": 1,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 14,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "dev",
      "displayName": "Developer mode",
      "description": "Developer mode",
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/build",
      "cacheVariables": {
        "refl-cpp_DEVELOPER_MODE": "ON"
      }
    }
  ]
}

With that presets file in place, configuring is simply done with running cmake --preset=dev in the source dir.
Version 3 will make the generator field optional in 3.21, so it'll be much easier to reuse presets. Could check a CMakePresets.json in after that.

@veselink1
Copy link
Owner

Thank you for your work on this!

I am not very familiar with CMake, and I was hoping to have the time to become familiar enough to evaluate any tradeoffs. Months later, I still haven't done that.

Everything up to your latest changes is in the cmake-support branch (which is now several commits behind). I just forgot to follow up on that here. My intention was to bring that branch up to date and finally close this PR.

I'm not able to test the presets option, as my system (Ubuntu 20.04) only comes with CMake 3.16 and --preset was added in CMake 3.20, if not mistaken. Building with -Drefl-cpp_DEVELOPER_MODE=ON instead works fine, so I trust nothing has been broken.

I will now proceed to set up the CI to build with CMake and finally merge this PR sometime in the next day.

@veselink1 veselink1 merged commit 319ce85 into veselink1:master Apr 1, 2021
@veselink1
Copy link
Owner

Merged into master, everything looks good.
Thanks, @friendlyanon!

@friendlyanon
Copy link
Contributor Author

friendlyanon commented Apr 1, 2021

Presets were added in 3.19 and Kitware provides an APT repository for Debian based distros to always get the latest and greatest, so it's trivial to install new versions. I highly recommend always using the latest version, even if your CMLs don't require such high versions, purely because of all the QoL changes, like presets.

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

Successfully merging this pull request may close these issues.

None yet

3 participants