From 8a0afc23a578ee19b470c2c14072582194d05a22 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Mon, 20 Jul 2020 16:39:04 -0400 Subject: [PATCH] update: 3.18 is out --- .gitlab-ci.yml | 2 +- README.md | 2 +- chapters/intro/installing.md | 14 +++++++------- chapters/intro/newcmake.md | 26 ++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d5300ca..596908b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ test_code: - yum install -y make cmake boost-devel git # will install latest CMake, even though Fedora has a recent one - mkdir -p $HOME/.local - - curl -s "https://cmake.org/files/v3.17/cmake-3.17.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/.local + - curl -s "https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/.local - export PATH=$HOME/.local/bin:$PATH script: - cmake -S examples -B build diff --git a/README.md b/README.md index 329143a..8496841 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Certainly there are no shortage of problems when building. But I think that, in 2020, we have a very good solution to quite a few of those problems. It's CMake. Not CMake 2.8 though; that was released before C++11 even existed! Nor the horrible examples out there for CMake (even those posted on KitWare's own tutorials list). -I'm talking about Modern CMake. CMake 3.1+, maybe even CMake 3.17+! +I'm talking about Modern CMake. CMake 3.1+, maybe even CMake 3.18+! It's clean, powerful, and elegant, so you can spend most of your time coding, not adding lines to an unreadable, unmaintainable Make (Or CMake 2) file. And CMake 3.11+ is supposed to be significantly faster, as well! diff --git a/chapters/intro/installing.md b/chapters/intro/installing.md index 4def4fa..b576399 100644 --- a/chapters/intro/installing.md +++ b/chapters/intro/installing.md @@ -4,7 +4,7 @@ Your CMake version should be newer than your compiler. It should be newer than the libraries you are using (especially Boost). New versions work better for everyone. {% endhint %} -If you have a built in copy of CMake, it isn't special or customized for your system. You can easily install a new one instead, either on the system level or the user level. Feel free to instruct your users here if they complain about a CMake requirement being set too high. Especially if they want < 3.1 support. Maybe even if they want CMake < 3.17 support... +If you have a built in copy of CMake, it isn't special or customized for your system. You can easily install a new one instead, either on the system level or the user level. Feel free to instruct your users here if they complain about a CMake requirement being set too high. Especially if they want < 3.1 support. Maybe even if they want CMake < 3.18 support... #### Quick list (more info on each method below) @@ -34,14 +34,14 @@ You can [download CMake from KitWare][download]. This is how you will probably g On Linux, there are several options. Kitware provides a [Debian/Ubunutu apt repository][apt], as well as [snap packages][snap]. There are universal Linux binaries provided, but you'll need to pick an install location. If you already use `~/.local` for user-space packages, the following single line command[^1] will get CMake for you [^2]: {% term %} -~ $ wget -qO- "https://cmake.org/files/v3.17/cmake-3.17.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C ~/.local +~ $ wget -qO- "https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C ~/.local {% endterm %} If you just want a local folder with CMake only: {% term %} -~ $ mkdir -p cmake-3.17 && wget -qO- "https://cmake.org/files/v3.17/cmake-3.17.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.17 -~ $ export PATH=`pwd`/cmake-3.17/bin:$PATH +~ $ mkdir -p cmake-3.18 && wget -qO- "https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.18 +~ $ export PATH=`pwd`/cmake-3.18/bin:$PATH {% endterm %} You'll obviously want to append to the PATH every time you start a new terminal, or add it to your `.bashrc` or to an [LMod] system. @@ -49,7 +49,7 @@ You'll obviously want to append to the PATH every time you start a new terminal, And, if you want a system install, install to `/usr/local`; this is an excellent choice in a Docker container, for example on GitLab CI. Do not try it on a non-containerized system. {% term %} -docker $ wget -qO- "https://cmake.org/files/v3.17/cmake-3.17.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local +docker $ wget -qO- "https://cmake.org/files/v3.18/cmake-3.18.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local {% endterm %} @@ -140,7 +140,7 @@ Also see [pkgs.org/download/cmake](https://pkgs.org/download/cmake). ## Pip -[This][PyPI] is also provided as an official package, maintained by the authors of CMake at KitWare. It's a rather new method, and might fail on some systems (Alpine isn't supported last I checked, but that has CMake 3.8), but works really well when it works (like on Travis CI). If you have pip (Python's package installer), you can do: +[This][PyPI] is also provided as an official package, maintained by the authors of CMake at KitWare. It's a rather new method, and might fail on some systems (Alpine isn't supported last I checked, but that has a recent CMake), but works really well when it works (like on Travis CI). If you have pip (Python's package installer), you can do: ```term gitbook $ pip install cmake @@ -148,7 +148,7 @@ gitbook $ pip install cmake And as long as a binary exists for your system, you'll be up-and-running almost immediately. If a binary doesn't exist, it will try to use KitWare's `scikit-build` package to build, which currently can't be listed as a dependency in the packaging system, and might even require (an older) copy of CMake to build. So only use this system if binaries exist, which is most of the time. -This has the benefit of respecting your current virtual environment, as well. +This has the benefit of respecting your current virtual environment, as well. It really shines when placed in a `pyproject.toml` file, however - it will only be installed to build your package, and will not remain afterwords! Fantastic. {% hint style='info' %} Personally, on Linux, I put versions of CMake in folders, like `/opt/cmake312` or `~/opt/cmake312`, and then add them to [LMod]. See [`envmodule_setup`][envmodule_setup] for help setting up an LMod system on macOS or Linux. It takes a bit to learn, but is a great way to manage package and compiler versions. diff --git a/chapters/intro/newcmake.md b/chapters/intro/newcmake.md index 9928be7..d2cc89d 100644 --- a/chapters/intro/newcmake.md +++ b/chapters/intro/newcmake.md @@ -257,6 +257,31 @@ as well, like FindPython. Finally, you can now iterate over multiple lists at a * Several new environment variables * foreach can now do `ZIP_LISTS` (multiple lists at a time) +## [CMake 3.18][] : CUDA with Clang + +CUDA now supports Clang (without separable compilation). A new +`CUDA_ARCHITECTURES` property was implemented to better support targeting CUDA +hardware. A new `cmake_language` command supports calling cmake commands and +expressions from strings. Lots of other meta changes that could make new +designs available; calling functions by variable, evaluating arbitrary CMake by +string, and configure files directly from strings. Many other nice tiny +features and papercut fixes are sprinkled throughout, a small selection is below. + +* `cmake` can `cat` files together now now +* New profiling mode for `cmake` +* `cmake_language` with `CALL` and `EVAL` +* `export` requires `APPEND` if used multiple times (in CMake language level 3.18+) +* You can archive directly from `file()` +* `file(CONFIGURE` is a nicer from of `configure_file` if you already have a string to produce +* Other `find_*` commands gain `find_package`'s `REQUIRED` flag +* `NATURAL` sorting in `list(SORT` added +* More options for handling properties with DIRECTORY scope +* `CUDA_ARCHITECTURES` was added +* New `LINK_LANGUAGE` generator expressions (`DEVICE`/`HOST` versions too) +* Source can be a subdirectory for `FetchContent` + + + [Releases]: https://cmake.org/cmake/help/latest/release/index.html [CMake 3.0]: https://cmake.org/cmake/help/latest/release/3.0.html [CMake 3.1]: https://cmake.org/cmake/help/latest/release/3.1.html @@ -276,5 +301,6 @@ as well, like FindPython. Finally, you can now iterate over multiple lists at a [CMake 3.15]: https://cmake.org/cmake/help/latest/release/3.15.html [CMake 3.16]: https://cmake.org/cmake/help/latest/release/3.16.html [CMake 3.17]: https://cmake.org/cmake/help/latest/release/3.17.html +[CMake 3.18]: https://cmake.org/cmake/help/latest/release/3.18.html [CMake master]: https://cmake.org/cmake/help/git-master/release/index.html [fastercmake]: https://blog.kitware.com/improving-cmakes-runtime-performance/