From 303c1340da24f18b079972b3bb2c35f8ef390280 Mon Sep 17 00:00:00 2001 From: Henry Fredrick Schreiner Date: Tue, 27 Nov 2018 21:55:39 +0100 Subject: [PATCH] Adding updates for CMake 3.13 --- .gitlab-ci.yml | 2 +- README.md | 2 +- chapters/basics.md | 8 ++++---- chapters/intro/dodonot.md | 4 ++-- chapters/intro/installing.md | 10 +++++----- chapters/intro/newcmake.md | 10 +++++----- chapters/packages/CUDA.md | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1736ffd..1c5a726 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ test_code: stage: test before_script: - mkdir -p $HOME/.local - - curl -s "https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/.local + - curl -s "https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C $HOME/.local - export PATH=$HOME/.local/bin:$PATH script: - mkdir -p build diff --git a/README.md b/README.md index f20def6..6aecb2a 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 2018, 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.12+! +I'm talking about Modern CMake. CMake 3.1+, maybe even CMake 3.13+! 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/basics.md b/chapters/basics.md index 68cce8d..76e98bf 100644 --- a/chapters/basics.md +++ b/chapters/basics.md @@ -19,7 +19,7 @@ usually have a very recent version of CMake. This is what new projects should do: ```cmake -cmake_minimum_required(VERSION 3.1...3.12) +cmake_minimum_required(VERSION 3.1...3.13) if(${CMAKE_VERSION} VERSION_LESS 3.12) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) @@ -28,15 +28,15 @@ endif() If CMake version is less than 3.12, the if block will be true, and the policy will be set to the current CMake version. If CMake is 3.12 or higher, the if block will be false, but the new syntax in `cmake_minimum_required` will be respected and this will continue to work properly! -WARNING: MSVC's CMake server mode [seems to have a bug](https://github.com/fmtlib/fmt/issues/809) in reading this format, so if you need to support non-command line Windows builds, you will want to do this instead: +WARNING: MSVC's CMake server mode [originally had a bug](https://github.com/fmtlib/fmt/issues/809) in reading this format, so if you need to support non-command line Windows builds for older MSVC versions, you will want to do this instead: ```cmake cmake_minimum_required(VERSION 3.1) -if(${CMAKE_VERSION} VERSION_LESS 3.12) +if(${CMAKE_VERSION} VERSION_LESS 3.13) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) else() - cmake_policy(VERSION 3.12) + cmake_policy(VERSION 3.13) endif() ``` diff --git a/chapters/intro/dodonot.md b/chapters/intro/dodonot.md index 142dd76..93b31dc 100644 --- a/chapters/intro/dodonot.md +++ b/chapters/intro/dodonot.md @@ -12,10 +12,10 @@ You'll need to pick a minimum required version of CMake. This will affect the CM | Ubuntu 16.04 LTS | 3.5.1 | | | Ubuntu 17.10 | 3.9.1 | | | Ubuntu 18.04 LTS | 3.10.2 | An LTS with a pretty decent minimum version! | -| Python PyPI | 3.10 | Just `pip install cmake` on many systems. Add `--user` for local installs. | +| [Python PyPI](https://pypi.org/project/cmake/) | 3.12.0 | Just `pip install cmake` on many systems. Add `--user` for local installs. | | Homebrew on macOS | latest | On macOS with Homebrew, this is only a few minutes behind cmake.org. | | Chocolaty on Windows | latest | Also up to date. The normal cmake.org installers are common on Windows, as well. | -| TravisCI | 3.9 | The December 2017 update added a recent version of clang and CMake! Finally! | +| TravisCI Trusty | 3.9 | The December 2017 update added a recent version of clang and CMake! Finally! | ## CMake Antipatterns diff --git a/chapters/intro/installing.md b/chapters/intro/installing.md index ba38f24..18d953f 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.12 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.13 support... ## Official package @@ -13,14 +13,14 @@ You can [download CMake from KitWare][cmake-download]. This is how you'll probab On Linux, there are 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.12/cmake-3.12.2-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C ~/.local +~ $ wget -qO- "https://cmake.org/files/v3.13/cmake-3.13.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.12 && wget -qO- "https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.12 -~ $ export PATH=`pwd`/cmake-3.12/bin:$PATH +~ $ mkdir -p cmake-3.13 && wget -qO- "https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C cmake-3.13 +~ $ export PATH=`pwd`/cmake-3.13/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. @@ -28,7 +28,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.12/cmake-3.12.2-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local +docker $ wget -qO- "https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local {% endterm %} diff --git a/chapters/intro/newcmake.md b/chapters/intro/newcmake.md index 3dc5d46..63e1ef0 100644 --- a/chapters/intro/newcmake.md +++ b/chapters/intro/newcmake.md @@ -160,13 +160,12 @@ shiny new Python find module (2 and 3 versions too), and many more. * Several new properties and property initializers * CPack finally reads `CMAKE_PROJECT_VERSION` variables -## [CMake 3.13 rc1] : Linking control +## [CMake 3.13] : Linking control You can now make symbolic links on Windows! Lots of new functions that fill out the popular requests for CMake, such as `add_link_options`, `target_link_directories`, and `target_link_options`. You can now do quite a bit more modification to targets outside -of the source directory, for better file separation. Generator expressions can be used in -more places. And, `target_sources` *finally* handles relative paths properly. +of the source directory, for better file separation. And, `target_sources` *finally* handles relative paths properly (policy 76). * New `ctest --progress` option for live output * `target_link_options` and `add_link_options` added @@ -176,7 +175,8 @@ more places. And, `target_sources` *finally* handles relative paths properly. * You can use `-S` and `-B` for source and build directories * `target_link_libraries` and `install` work outside the current target directory * `STATIC_LIBRARY_OPTIONS` property added -* `target_sources` is now relative to the current source directory +* `target_sources` is now relative to the current source directory (CMP0076) +* If you use Xcode, you now can experimentally set schema fields [Releases]: https://cmake.org/cmake/help/latest/release/index.html [CMake 3.0]: https://cmake.org/cmake/help/latest/release/3.0.html @@ -192,5 +192,5 @@ more places. And, `target_sources` *finally* handles relative paths properly. [CMake 3.10]: https://cmake.org/cmake/help/latest/release/3.10.html [CMake 3.11]: https://cmake.org/cmake/help/latest/release/3.11.html [CMake 3.12]: https://cmake.org/cmake/help/latest/release/3.12.html -[CMake 3.13 rc1]: https://blog.kitware.com/cmake-3-13-0-rc1-is-ready-for-testing/ +[CMake 3.13]: https://cmake.org/cmake/help/latest/release/3.13.html [fastercmake]: https://blog.kitware.com/improving-cmakes-runtime-performance/ diff --git a/chapters/packages/CUDA.md b/chapters/packages/CUDA.md index c78e744..0afdb9b 100644 --- a/chapters/packages/CUDA.md +++ b/chapters/packages/CUDA.md @@ -89,7 +89,7 @@ endfunction() > ### Note that FindCUDA is deprecated, but for now, the following functions require FindCUDA: > > * CUDA version checks / picking a version -> * Architecture detection (Note: 3.12 will fix this at least partially) +> * Architecture detection (Note: 3.12 fixes this partially) > * Linking to CUDA libraries from non-.cu files ## Method 2: FindCUDA