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 foundations for CMake support #254

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/bazel-*
cmake/build*
30 changes: 30 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2024 Aurora Operations, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# CMake should always be at least as new as your compiler[1]. Clang 14 was released on March 25,
# 2022, and is our newest officially supported compiler. The next CMake release was v3.23.0, on
# March 29, 2022. Therefore, our minimum version must be at least CMake 3.23.
#
# The maximum version should be the latest version we've tested the project with.
#
# [1]: https://cliutils.gitlab.io/modern-cmake/chapters/intro/dodonot.html
cmake_minimum_required(VERSION 3.23...3.29)
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason that you chose cmake 3.23? Ubuntu 22.04.4 LTS packages cmake 3.22.1 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, the comment above explains the reasoning.

CMake is in some ways counter-intuitive, at least to me. There's a strong expectation that it will be very easy for users to get the latest version, and thus there are community norms around aggressively updating the minimum version. I will say, I was pleased to see how easy it was to grab 3.29 on Ubuntu, simply by adding the official PPA.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. I followed this SO post and the code below worked.


project(
Au
VERSION 0.3.4
DESCRIPTION "A C++ quantities and units library, by Aurora Innovation"
HOMEPAGE_URL "https://aurora-opensource.github.io/au/0.3.4/"
LANGUAGES CXX
)
15 changes: 14 additions & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ Any empty section can be omitted.
We try to follow [semantic versioning](https://semver.org/). Since we are currently in major
version zero (0.y.z), incompatible changes don't force a major version upgrade.

### Update the CMake version number

Edit the `CMakeLists.txt` file in the root folder, updating the version number in the `project`
command to the number chosen above.

Also update the version number in the `HOMEPAGE_URL` parameter, because we link to the docs for the
latest release in our CMake project definition. (True, this URL won't exist until you complete the
remaining steps in this guide, but the danger of getting it wrong is pretty small.)

Make a PR with these changes and land it before creating the tag.

### Fill out release notes template

The first line should be the tag name.
Expand Down Expand Up @@ -102,7 +113,9 @@ Issues! Alphabetically:

### Create the tag

Use the command below, replacing `0.3.1` with the version to create.
First, make sure the "final commit" (which updates the CMake variables) has already landed.

Then, use the command below, replacing `0.3.1` with the version to create.

```sh
# Remember to update the tag number!
Expand Down
16 changes: 16 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,22 @@ attribute, and include the appropriate files.
| `@au//au:io` | `"au/io.hh"` | `operator<<` support |
| `@au//au:testing` | `"au/testing.hh"` | Utilities for testing<br>_Note:_ `testonly = True` |

#### CMake

CMake support is still experimental and in-progress. We are building it up starting from "root"
targets (that is, targets without dependencies), and expanding support to the rest of the library.

To build the library using this experimental CMake support, follow these steps:

```sh
# CMake is a "meta build system", not a build system.
# This first command generates the actual build files.
cmake -B cmake/build -S .

# This command builds the library.
cmake --build cmake/build
```

#### Other build systems (CMake / conan / vcpkg / ...)

We would like to support all these build and packaging systems, and perhaps others! But the initial
Expand Down
Loading