Skip to content

CMake support#44

Merged
veselink1 merged 8 commits into
veselink1:masterfrom
friendlyanon:cmake-support
Apr 1, 2021
Merged

CMake support#44
veselink1 merged 8 commits into
veselink1:masterfrom
friendlyanon:cmake-support

Conversation

@friendlyanon
Copy link
Copy Markdown
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
Copy Markdown

Any updates?

Developer mode allows proper separation of concerns by making targets
available only for the developer(s) of the library that are only
relevant to the developer(s) of the library.
@friendlyanon
Copy link
Copy Markdown
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:

Details
{
  "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
Copy Markdown
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
Copy Markdown
Owner

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

@friendlyanon
Copy link
Copy Markdown
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.

3 participants