From 6ee46829245fe4f7d204d0e181dbcffcf32a585c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Fri, 11 May 2018 16:58:08 +0200 Subject: [PATCH] Squashed 'cmake/cable/' changes from 5fd6d89..caeabb3 caeabb3 CableBuildInfo: Specify gitinfo.txt byproduct 69a5abc CableBuildInfo: Remove broken debug logs a5a1829 CableCompilerSettings: Enabled conversion warnings by default 0790aec README: Add section about git subtree 4056c71 Add the project name to every file 612d1b2 Add cxx11-c99 toolchain file git-subtree-dir: cmake/cable git-subtree-split: caeabb3a9f054f5c0b5076aa958968c42f7a5df4 --- CableBuildInfo.cmake | 3 ++- CableBuildType.cmake | 1 + CableCompilerSettings.cmake | 9 +++++-- CableToolchains.cmake | 1 + README.md | 28 ++++++++++++++++----- bootstrap.cmake | 2 +- buildinfo/buildinfo.cmake | 7 ------ defaults/HunterCacheServers-passwords.cmake | 1 + defaults/HunterCacheServers.cmake | 1 + toolchains/cxx11-32bit.cmake | 1 + toolchains/cxx11-c99.cmake | 10 ++++++++ toolchains/cxx11.cmake | 1 + toolchains/default.cmake | 1 + toolchains/mips64.cmake | 1 + 14 files changed, 50 insertions(+), 17 deletions(-) create mode 100644 toolchains/cxx11-c99.cmake diff --git a/CableBuildInfo.cmake b/CableBuildInfo.cmake index 1c77d58..bb55c04 100644 --- a/CableBuildInfo.cmake +++ b/CableBuildInfo.cmake @@ -1,3 +1,4 @@ +# Cable: CMake Bootstrap Library. # Copyright 2018 Pawel Bylica. # Licensed under the Apache License, Version 2.0. See the LICENSE file. @@ -45,6 +46,7 @@ function(cable_add_buildinfo_library) -DSOURCE_DIR=${PROJECT_SOURCE_DIR} -DBINARY_DIR=${binary_dir} -P ${cable_buildinfo_template_dir}/gitinfo.cmake + BYPRODUCTS ${binary_dir}/gitinfo.txt ) add_custom_command( @@ -60,7 +62,6 @@ function(cable_add_buildinfo_library) -DCOMPILER_ID=${CMAKE_CXX_COMPILER_ID} -DCOMPILER_VERSION=${CMAKE_CXX_COMPILER_VERSION} -DBUILD_TYPE=${build_type} - -DCABLE_DEBUG=${CABLE_DEBUG} -P ${cable_buildinfo_template_dir}/buildinfo.cmake DEPENDS ${cable_buildinfo_template_dir}/buildinfo.cmake diff --git a/CableBuildType.cmake b/CableBuildType.cmake index 56c5214..d1f84ae 100644 --- a/CableBuildType.cmake +++ b/CableBuildType.cmake @@ -1,3 +1,4 @@ +# Cable: CMake Bootstrap Library. # Copyright 2018 Pawel Bylica. # Licensed under the Apache License, Version 2.0. See the LICENSE file. diff --git a/CableCompilerSettings.cmake b/CableCompilerSettings.cmake index 357b9af..08dda33 100644 --- a/CableCompilerSettings.cmake +++ b/CableCompilerSettings.cmake @@ -32,7 +32,7 @@ macro(cable_configure_compiler) if(NOT PROJECT_IS_NESTED) # Do this configuration only in the top project. - cmake_parse_arguments(cable "NO_STACK_PROTECTION" "" "" ${ARGN}) + cmake_parse_arguments(cable "NO_CONVERSION_WARNINGS;NO_STACK_PROTECTION" "" "" ${ARGN}) if(cable_UNPARSED_ARGUMENTS) message(FATAL_ERROR "cable_configure_compiler: Uknown options: ${cable_UNPARSED_ARGUMENTS}") @@ -53,7 +53,12 @@ macro(cable_configure_compiler) if(CABLE_COMPILER_GNULIKE) # Enable basing warnings set and treat them as errors. - add_compile_options(-Wall -Wextra -Werror -pedantic) + add_compile_options(-pedantic -Werror -Wall -Wextra) + + if(NOT cable_NO_CONVERSION_WARNINGS) + # Enable conversion warnings if not explicitly disabled. + add_compile_options(-Wconversion -Wsign-conversion) + endif() # Allow unknown pragmas, we don't want to wrap them with #ifdefs. add_compile_options(-Wno-unknown-pragmas) diff --git a/CableToolchains.cmake b/CableToolchains.cmake index e5bad38..b881b35 100644 --- a/CableToolchains.cmake +++ b/CableToolchains.cmake @@ -1,3 +1,4 @@ +# Cable: CMake Bootstrap Library. # Copyright 2018 Pawel Bylica. # Licensed under the Apache License, Version 2.0. See the LICENSE file. diff --git a/README.md b/README.md index fc2653d..5c34b71 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Cable is a set of CMake modules and scripts containing common patterns used in CMake-based C++ projects. The design goal is to be pragmatic rather than generic so the number of provided options is minimal. The Cable modules are -independent so it is easy to use them individually. +independent and it is easy to use them individually. ## Table of Contents @@ -20,9 +20,22 @@ independent so it is easy to use them individually. ## Install +### As git subtree + +Adding a dependency project as a [git subtree] is just a copy of the source code +done in a bit more systematic way. + +If you are not familiar with managing dependencies with git subtree read the +[Git subtree: the alternative to Git submodule][git subtree tutorial]. + +```sh +git remote add cable https://github.com/ethereum/cable +git subtree add --prefix cmake/cable cable master --squash +``` + ### As git submodule -Include the Cable library as git submodule in your project. The suggested +Include the Cable library as [git submodule] in your project. The suggested submodule location is `cmake/cable` relative to your project root directory. ```sh @@ -32,9 +45,9 @@ git submodule add https://github.com/ethereum/cable cmake/cable ## Usage Cable contains the `bootstrap.cmake` file that initializes the library. -Start by including this file in your main `CMakeLists.txt` from Cable submodule -or any other location. The `bootstrap.cmake` must be included before -the `project()` command. After that, you can include and use other +Start by including this file in your main `CMakeLists.txt` from the Cable +submodule/subtree or any other location. The `bootstrap.cmake` must be included +before the `project()` command. After that, you can include and use other Cable modules. ### Example @@ -61,7 +74,10 @@ Licensed under the [Apache License, Version 2.0]. [@chfast]: https://github.com/chfast -[Apache License, Version 2.0]: https://www.apache.org/licenses/LICENSE-2.0 +[Apache License, Version 2.0]: LICENSE +[git submodule]: https://git-scm.com/book/en/v2/Git-Tools-Submodules +[git subtree]: https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt +[git subtree tutorial]: https://www.atlassian.com/blog/git/alternatives-to-git-submodule-git-subtree [standard readme]: https://github.com/RichardLitt/standard-readme [readme style standard badge]: https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square diff --git a/bootstrap.cmake b/bootstrap.cmake index 0c366c7..4255ae6 100644 --- a/bootstrap.cmake +++ b/bootstrap.cmake @@ -10,7 +10,7 @@ # # This is internal variable automaticaly updated with external tools. # Use CABLE_VERSION variable if you need this information. -set(version 0.1.7) +set(version 0.2.2) # For conveniance, add the project CMake module dir to module path. set(module_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake) diff --git a/buildinfo/buildinfo.cmake b/buildinfo/buildinfo.cmake index 8fe5f03..f54e0c6 100644 --- a/buildinfo/buildinfo.cmake +++ b/buildinfo/buildinfo.cmake @@ -29,13 +29,6 @@ else() set(GIT_DIRTY FALSE) endif() -cable_debug("gitinfo: parsing '${GIT_INFO}':") -cable_debug(" version: ${GIT_LATEST_PROJECT_VERSION}") -cable_debug(" distance: ${GIT_LATEST_PROJECT_VERSION_DISTANCE}") -cable_debug(" commit: ${GIT_COMMIT_HASH}") -cable_debug(" dirty: ${GIT_DIRTY}") - - if(GIT_COMMIT_HASH) string(SUBSTRING ${GIT_COMMIT_HASH} 0 8 abbrev) set(version_commit "+commit.${abbrev}") diff --git a/defaults/HunterCacheServers-passwords.cmake b/defaults/HunterCacheServers-passwords.cmake index 793df96..3019669 100644 --- a/defaults/HunterCacheServers-passwords.cmake +++ b/defaults/HunterCacheServers-passwords.cmake @@ -1,3 +1,4 @@ +# Cable: CMake Bootstrap Library. # Copyright 2018 Pawel Bylica. # Licensed under the Apache License, Version 2.0. See the LICENSE file. diff --git a/defaults/HunterCacheServers.cmake b/defaults/HunterCacheServers.cmake index 270f546..b6f8449 100644 --- a/defaults/HunterCacheServers.cmake +++ b/defaults/HunterCacheServers.cmake @@ -1,3 +1,4 @@ +# Cable: CMake Bootstrap Library. # Copyright 2018 Pawel Bylica. # Licensed under the Apache License, Version 2.0. See the LICENSE file. diff --git a/toolchains/cxx11-32bit.cmake b/toolchains/cxx11-32bit.cmake index c677457..7627441 100644 --- a/toolchains/cxx11-32bit.cmake +++ b/toolchains/cxx11-32bit.cmake @@ -1,3 +1,4 @@ +# Cable: CMake Bootstrap Library. # Copyright 2018 Pawel Bylica. # Licensed under the Apache License, Version 2.0. See the LICENSE file. diff --git a/toolchains/cxx11-c99.cmake b/toolchains/cxx11-c99.cmake new file mode 100644 index 0000000..91a93b3 --- /dev/null +++ b/toolchains/cxx11-c99.cmake @@ -0,0 +1,10 @@ +# Cable: CMake Bootstrap Library. +# Copyright 2018 Pawel Bylica. +# Licensed under the Apache License, Version 2.0. See the LICENSE file. + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(CMAKE_C_STANDARD 99) +set(CMAKE_C_EXTENSIONS OFF) diff --git a/toolchains/cxx11.cmake b/toolchains/cxx11.cmake index 4424186..cd6b82f 100644 --- a/toolchains/cxx11.cmake +++ b/toolchains/cxx11.cmake @@ -1,3 +1,4 @@ +# Cable: CMake Bootstrap Library. # Copyright 2018 Pawel Bylica. # Licensed under the Apache License, Version 2.0. See the LICENSE file. diff --git a/toolchains/default.cmake b/toolchains/default.cmake index 0761f2c..9869b6e 100644 --- a/toolchains/default.cmake +++ b/toolchains/default.cmake @@ -1,2 +1,3 @@ +# Cable: CMake Bootstrap Library. # Copyright 2018 Pawel Bylica. # Licensed under the Apache License, Version 2.0. See the LICENSE file. diff --git a/toolchains/mips64.cmake b/toolchains/mips64.cmake index 81362f1..e90d748 100644 --- a/toolchains/mips64.cmake +++ b/toolchains/mips64.cmake @@ -1,3 +1,4 @@ +# Cable: CMake Bootstrap Library. # Copyright 2018 Pawel Bylica. # Licensed under the Apache License, Version 2.0. See the LICENSE file.