1
0
mirror of synced 2024-12-22 20:50:00 +01:00

Adding updates for CMake 3.13

This commit is contained in:
Henry Fredrick Schreiner 2018-11-27 21:55:39 +01:00
parent d90c50dc08
commit 303c1340da
7 changed files with 19 additions and 19 deletions

View File

@ -4,7 +4,7 @@ test_code:
stage: test stage: test
before_script: before_script:
- mkdir -p $HOME/.local - 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 - export PATH=$HOME/.local/bin:$PATH
script: script:
- mkdir -p build - mkdir -p build

View File

@ -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. 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! 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). 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. 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! And CMake 3.11+ is supposed to be significantly faster, as well!

View File

@ -19,7 +19,7 @@ usually have a very recent version of CMake.
This is what new projects should do: This is what new projects should do:
```cmake ```cmake
cmake_minimum_required(VERSION 3.1...3.12) cmake_minimum_required(VERSION 3.1...3.13)
if(${CMAKE_VERSION} VERSION_LESS 3.12) if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) 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! 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
cmake_minimum_required(VERSION 3.1) 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}) cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else() else()
cmake_policy(VERSION 3.12) cmake_policy(VERSION 3.13)
endif() endif()
``` ```

View File

@ -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 16.04 LTS | 3.5.1 | |
| Ubuntu 17.10 | 3.9.1 | | | Ubuntu 17.10 | 3.9.1 | |
| Ubuntu 18.04 LTS | 3.10.2 | An LTS with a pretty decent minimum version! | | 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. | | 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. | | 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 ## CMake Antipatterns

View File

@ -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. 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 %} {% 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 ## 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]: 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 %} {% 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 %} {% endterm %}
If you just want a local folder with CMake only: If you just want a local folder with CMake only:
{% term %} {% 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 ~ $ 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.12/bin:$PATH ~ $ export PATH=`pwd`/cmake-3.13/bin:$PATH
{% endterm %} {% 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. 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. 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 %} {% 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 %} {% endterm %}

View File

@ -160,13 +160,12 @@ shiny new Python find module (2 and 3 versions too), and many more.
* Several new properties and property initializers * Several new properties and property initializers
* CPack finally reads `CMAKE_PROJECT_VERSION` variables * 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 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 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 `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 of the source directory, for better file separation. And, `target_sources` *finally* handles relative paths properly (policy 76).
more places. And, `target_sources` *finally* handles relative paths properly.
* New `ctest --progress` option for live output * New `ctest --progress` option for live output
* `target_link_options` and `add_link_options` added * `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 * You can use `-S` and `-B` for source and build directories
* `target_link_libraries` and `install` work outside the current target directory * `target_link_libraries` and `install` work outside the current target directory
* `STATIC_LIBRARY_OPTIONS` property added * `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 [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.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.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.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.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/ [fastercmake]: https://blog.kitware.com/improving-cmakes-runtime-performance/

View File

@ -89,7 +89,7 @@ endfunction()
> ### Note that FindCUDA is deprecated, but for now, the following functions require FindCUDA: > ### Note that FindCUDA is deprecated, but for now, the following functions require FindCUDA:
> >
> * CUDA version checks / picking a version > * 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 > * Linking to CUDA libraries from non-.cu files
## Method 2: FindCUDA ## Method 2: FindCUDA