From 384993348d2f7ef1ecf8557cfa8e6a24a189fb20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 12 Aug 2019 11:22:04 +0200 Subject: [PATCH 1/2] Squashed 'cmake/cable/' changes from cea3a65..945b7e5 945b7e5 Cable 0.4.3 1885e7e CablePackage: Add support for source packages 3fc90c6 Cable 0.4.2 9b84efe buildinfo: Generate version.h header with project version string 93a47b2 Cable 0.4.1 f3e0f53 Add CablePackage for building archive packages 9708939 Use -Wpedantic instead of -pedantic 7e0e2b6 Add 32-bit toolchains git-subtree-dir: cmake/cable git-subtree-split: 945b7e5e3ca2f888c6e62747f82e2aad413b823c --- CableBuildInfo.cmake | 1 + CableCompilerSettings.cmake | 2 +- CablePackage.cmake | 28 ++++++++++++++++++++++++++++ bootstrap.cmake | 2 +- buildinfo/buildinfo.cmake | 7 +++++-- buildinfo/version.h.in | 14 ++++++++++++++ toolchains/cxx11-32bit.cmake | 8 ++++---- toolchains/cxx14-32bit.cmake | 10 ++++++++++ toolchains/cxx17-32bit.cmake | 10 ++++++++++ 9 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 CablePackage.cmake create mode 100644 buildinfo/version.h.in create mode 100644 toolchains/cxx14-32bit.cmake create mode 100644 toolchains/cxx17-32bit.cmake diff --git a/CableBuildInfo.cmake b/CableBuildInfo.cmake index 51e27a3..5ce703e 100644 --- a/CableBuildInfo.cmake +++ b/CableBuildInfo.cmake @@ -69,6 +69,7 @@ function(cable_add_buildinfo_library) ${cable_buildinfo_template_dir}/buildinfo.cmake ${cable_buildinfo_template_dir}/buildinfo.c.in ${cable_buildinfo_template_dir}/buildinfo.json.in + ${cable_buildinfo_template_dir}/version.h.in ${name}-git ${output_dir}/gitinfo.txt ) diff --git a/CableCompilerSettings.cmake b/CableCompilerSettings.cmake index 8267da5..f86aa6e 100644 --- a/CableCompilerSettings.cmake +++ b/CableCompilerSettings.cmake @@ -53,7 +53,7 @@ macro(cable_configure_compiler) if(CABLE_COMPILER_GNULIKE) if(NOT cable_NO_PEDANTIC) - add_compile_options(-pedantic) + add_compile_options(-Wpedantic) endif() # Enable basing warnings set and treat them as errors. diff --git a/CablePackage.cmake b/CablePackage.cmake new file mode 100644 index 0000000..d3207da --- /dev/null +++ b/CablePackage.cmake @@ -0,0 +1,28 @@ +# Cable: CMake Bootstrap Library. +# Copyright 2019 Pawel Bylica. +# Licensed under the Apache License, Version 2.0. See the LICENSE file. + +if(cable_package_included) + return() +endif() +set(cable_package_included TRUE) + +# Configures CPack to build the archive package. +macro(cable_add_archive_package) + if(WIN32) + set(CPACK_GENERATOR ZIP) + set(CPACK_SOURCE_GENERATOR ZIP) + else() + set(CPACK_GENERATOR TGZ) + set(CPACK_SOURCE_GENERATOR TGZ) + endif() + string(TOLOWER ${CMAKE_SYSTEM_NAME} system_name) + string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} system_processor) + set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION}-${system_name}-${system_processor}) + set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION}-source) + set(CPACK_PACKAGE_CHECKSUM SHA256) + set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE) + unset(system_name) + unset(system_processor) + include(CPack) +endmacro() diff --git a/bootstrap.cmake b/bootstrap.cmake index 95ae9b8..162a38a 100644 --- a/bootstrap.cmake +++ b/bootstrap.cmake @@ -10,7 +10,7 @@ # # This is internal variable automatically updated with external tools. # Use CABLE_VERSION variable if you need this information. -set(version 0.4.0) +set(version 0.4.3) # For convenience, 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 f4dbbc3..651b754 100644 --- a/buildinfo/buildinfo.cmake +++ b/buildinfo/buildinfo.cmake @@ -1,7 +1,8 @@ # Cable: CMake Bootstrap Library. -# Copyright 2018 Pawel Bylica. -# Licensed under the Apache License, Version 2.0. See the LICENSE file. +# Copyright 2018-2019 Pawel Bylica. +# Licensed under the Apache License, Version 2.0. +string(TOUPPER "${PROJECT_NAME}" PROJECT_NAME_UPPERCASE) string(TOLOWER "${SYSTEM_NAME}" SYSTEM_NAME) string(TOLOWER "${SYSTEM_PROCESSOR}" SYSTEM_PROCESSOR) string(TOLOWER "${COMPILER_ID}" COMPILER_ID) @@ -82,3 +83,5 @@ configure_file(${CMAKE_CURRENT_LIST_DIR}/buildinfo.c.in ${OUTPUT_DIR}/buildinfo. configure_file(${CMAKE_CURRENT_LIST_DIR}/buildinfo.json.in ${OUTPUT_DIR}/buildinfo.json) configure_file(${CMAKE_CURRENT_LIST_DIR}/buildinfo.sh.in ${OUTPUT_DIR}/buildinfo.sh) configure_file(${CMAKE_CURRENT_LIST_DIR}/buildinfo.ps1.in ${OUTPUT_DIR}/buildinfo.ps1) + +configure_file(${CMAKE_CURRENT_LIST_DIR}/version.h.in ${OUTPUT_DIR}/version.h) diff --git a/buildinfo/version.h.in b/buildinfo/version.h.in new file mode 100644 index 0000000..c53e536 --- /dev/null +++ b/buildinfo/version.h.in @@ -0,0 +1,14 @@ +/* Cable: CMake Bootstrap Library. + * Copyright 2019 Pawel Bylica. + * Licensed under the Apache License, Version 2.0. + */ + +/* Generated by Cable Build Info on @TIMESTAMP@. Do not modify directly. */ + +#pragma once + +#define @PROJECT_NAME_UPPERCASE@_VERSION "@PROJECT_VERSION@" + +#ifdef __cplusplus +constexpr auto @PROJECT_NAME@_version = "@PROJECT_VERSION@"; +#endif diff --git a/toolchains/cxx11-32bit.cmake b/toolchains/cxx11-32bit.cmake index 7627441..f3f28cf 100644 --- a/toolchains/cxx11-32bit.cmake +++ b/toolchains/cxx11-32bit.cmake @@ -1,10 +1,10 @@ # Cable: CMake Bootstrap Library. -# Copyright 2018 Pawel Bylica. -# Licensed under the Apache License, Version 2.0. See the LICENSE file. +# Copyright 2018-2019 Pawel Bylica. +# Licensed under the Apache License, Version 2.0. set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_CXX_EXTENSIONS OFF) -set(CMAKE_C_FLAGS -m32 CACHE STRING "C compiler flags" FORCE) -set(CMAKE_CXX_FLAGS -m32 CACHE STRING "C++ compiler flags" FORCE) +set(CMAKE_C_FLAGS_INIT -m32) +set(CMAKE_CXX_FLAGS_INIT -m32) diff --git a/toolchains/cxx14-32bit.cmake b/toolchains/cxx14-32bit.cmake new file mode 100644 index 0000000..15145ff --- /dev/null +++ b/toolchains/cxx14-32bit.cmake @@ -0,0 +1,10 @@ +# Cable: CMake Bootstrap Library. +# Copyright 2019 Pawel Bylica. +# Licensed under the Apache License, Version 2.0. + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(CMAKE_C_FLAGS_INIT -m32) +set(CMAKE_CXX_FLAGS_INIT -m32) diff --git a/toolchains/cxx17-32bit.cmake b/toolchains/cxx17-32bit.cmake new file mode 100644 index 0000000..183aab3 --- /dev/null +++ b/toolchains/cxx17-32bit.cmake @@ -0,0 +1,10 @@ +# Cable: CMake Bootstrap Library. +# Copyright 2019 Pawel Bylica. +# Licensed under the Apache License, Version 2.0. + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) +set(CMAKE_CXX_EXTENSIONS OFF) + +set(CMAKE_C_FLAGS_INIT -m32) +set(CMAKE_CXX_FLAGS_INIT -m32) From e09808290afd9b47ba1f3d13527e2a6ae7412849 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 12 Aug 2019 11:24:01 +0200 Subject: [PATCH 2/2] cmake: Use CablePackage to configure binary/source packages --- CMakeLists.txt | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dbb51a..e199898 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ option(HUNTER_ENABLED "Enable Hunter package manager support" ${hunter_and_examp include(cmake/cable/bootstrap.cmake) include(CableBuildType) include(CableCompilerSettings) +include(CablePackage) include(CableToolchains) include(CMakePackageConfigHelpers) include(GNUInstallDirs) @@ -86,19 +87,6 @@ if(EVMC_INSTALL) ) endif() -if(WIN32) - set(CPACK_GENERATOR ZIP) - set(CPACK_SOURCE_GENERATOR ZIP) -else() - set(CPACK_GENERATOR TGZ) - set(CPACK_SOURCE_GENERATOR TGZ) -endif() -string(TOLOWER ${CMAKE_SYSTEM_NAME} system_name) -set(CPACK_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION}-${system_name}) -set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-${PROJECT_VERSION}-source) -set(CPACK_PACKAGE_CHECKSUM SHA256) -set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY FALSE) - set( CPACK_SOURCE_IGNORE_FILES /\\\\.git/ @@ -110,5 +98,4 @@ set( /Cargo.toml /target/ ) - -include(CPack) +cable_add_archive_package()