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

Add CMakePresets.json #1380

Merged
merged 10 commits into from
Feb 20, 2024

Conversation

DownerCase
Copy link
Contributor

Description

Adds CMakePresets.json with the most common user-facing build profiles:

  • core: Minimal build. Focuses on building just the core libraries and nothing else.
  • wheel: Builds the Python wheel.
    • Simplifies building the wheel to: cmake --preset wheel && cmake --build --preset wheel
  • cli: Extends core to include the CLI/TUI applications
  • gui: Extends cli to include the QT GUI applications too
  • docs: Extends wheel to also build the Sphinx documentation

I did not include a "full" build, testing, or C# presets as I was focusing on the most common feature levels users (from my perspective) would want. These presets should evolve over time to meet end-user, contributor, and developer needs.

With this PR it is much easier to build the different feature levels; especially for users that may not want a complete build.

Additionally, users may write their own "CMakeUserPresets.json" to extend the set of presets with something tailored to their use and preference. ( I, personally, will be using this feature)

Lastly, IDEs, such as Visual Studio, understand CMakePresets and allow for quickly switching between the different presets, aiding development and checking the different feature levels.

Technical notes

The builds default the CMAKE_BUILD_TYPE to Release to prevent the combinatorial explosion of having explicit debug/release(/relwithdebinfo/minsizerel) presets.
This is only relevant for single-config generators (like "Unix Makefiles" or regular "Ninja") and does not affect "Visual Studio *" or "Ninja Multi-Config" generators.

This PR includes a CMake option to default BUILD_SHARED_LIBS to OFF only on "win32" builds. This setting is always required when building with MSVC due to the current DLL situation.
I do not define BUILD_SHARED_LIBS on non-win32 builds to match existing behaviour.

I bumped the minimum CMake version of CMakeFunctions solely because it was giving a deprecation message about support for CMake < 3.5.

CMake Preset documentation

Related issues

Cherry-pick to

  • Whatever the team is happy for, it would be nice to have for 5.13 but you will have to change HAS_QT back to HAS_QT5. I don't think any other changes would be needed.

@DownerCase DownerCase changed the title Feature/cmake presets Add CMakePresets.json Feb 17, 2024
@@ -121,12 +121,14 @@ if(WIN32)
option(ECAL_THIRDPARTY_BUILD_CURL "Build CURL with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_HDF5 "Build HDF5 with eCAL" ON)
cmake_dependent_option(ECAL_THIRDPARTY_BUILD_QWT "Build qwt::qwt with eCAL" ON "HAS_QT" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries; required off on MSVC" OFF)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it have to be set explicitly? BUILD_SHARD_LIBS is already a CMake option, defaulting to OFF on Windows platforms?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the cURL submodule was turning it on if it wasn't set causing problems for eCAL as curl goes first. This also matches what is done elsewhere in the project ([1], [2]) where BUILD_SHARED_LIBS is explicitly set OFF for Windows.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this isn't in the CMakePresets because then you'd need separate Windows and non-Windows presets to handle the mandatory platform-dependent setting. The presets themselves don't handle platform dependent things very well. Its best at setting high-level options which the build system understands and can do what you ask (like handling whether BUILD_SHARED_LIBS needs to be set on your platform or which thirdparty submodules to build from source)

@FlorianReimold FlorianReimold merged commit ebdb87b into eclipse-ecal:master Feb 20, 2024
7 checks passed
@FlorianReimold
Copy link
Member

Thanks for this PR! 👍

@DownerCase DownerCase deleted the feature/cmake_presets branch February 20, 2024 10:13
FlorianReimold pushed a commit that referenced this pull request Feb 26, 2024
Also silences CMake 3.27 deprecation message.
FlorianReimold pushed a commit that referenced this pull request Feb 27, 2024
Also silences CMake 3.27 deprecation message.
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.

CMake Presets
3 participants