mirror of https://github.com/status-im/evmc.git
Update cable subtree to commit '5fd6d89e7ed8f5e32c8e32168207dcf4f09b714d'
This commit is contained in:
commit
13e32686d3
|
@ -60,12 +60,13 @@ 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
|
||||
${cable_buildinfo_template_dir}/buildinfo.c.in
|
||||
${NAME}-git
|
||||
${binary_dir}/git_commit_hash.txt
|
||||
${binary_dir}/gitinfo.txt
|
||||
)
|
||||
|
||||
string(TIMESTAMP TIMESTAMP)
|
||||
|
|
|
@ -26,7 +26,7 @@ macro(cable_set_build_type)
|
|||
FORCE
|
||||
)
|
||||
endif()
|
||||
message(STATUS "[cable] Configurations: ${CMAKE_CONFIGURATION_TYPES}")
|
||||
cable_log("Configurations: ${CMAKE_CONFIGURATION_TYPES}")
|
||||
else()
|
||||
if(build_type_DEFAULT AND NOT CMAKE_BUILD_TYPE)
|
||||
set(
|
||||
|
@ -37,7 +37,7 @@ macro(cable_set_build_type)
|
|||
FORCE
|
||||
)
|
||||
endif()
|
||||
message(STATUS "[cable] Build type: ${CMAKE_BUILD_TYPE}")
|
||||
cable_log("Build type: ${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# Cable: CMake Bootstrap Library
|
||||
# Copyright 2018 Pawel Bylica.
|
||||
# Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
|
@ -29,6 +32,12 @@ 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})
|
||||
|
||||
if(cable_UNPARSED_ARGUMENTS)
|
||||
message(FATAL_ERROR "cable_configure_compiler: Uknown options: ${cable_UNPARSED_ARGUMENTS}")
|
||||
endif()
|
||||
|
||||
# Set helper variables recognizing C++ compilers.
|
||||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
|
||||
set(CABLE_COMPILER_GNU TRUE)
|
||||
|
@ -59,9 +68,21 @@ macro(cable_configure_compiler)
|
|||
|
||||
endif()
|
||||
|
||||
cable_add_cxx_compiler_flag_if_supported(-fstack-protector-strong have_stack_protector_strong_support)
|
||||
if(NOT have_stack_protector_strong_support)
|
||||
cable_add_cxx_compiler_flag_if_supported(-fstack-protector)
|
||||
check_cxx_compiler_flag(-fstack-protector fstack-protector)
|
||||
if(fstack-protector)
|
||||
# The compiler supports stack protection options.
|
||||
if(cable_NO_STACK_PROTECTION)
|
||||
# Stack protection explicitly disabled.
|
||||
# Add "no" flag, because in some configuration the compiler has it enabled by default.
|
||||
add_compile_options(-fno-stack-protector)
|
||||
else()
|
||||
# Try enabling the "strong" variant.
|
||||
cable_add_cxx_compiler_flag_if_supported(-fstack-protector-strong have_stack_protector_strong_support)
|
||||
if(NOT have_stack_protector_strong_support)
|
||||
# Fallback to standard variant of "strong" not available.
|
||||
add_compile_options(-fstack-protector)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
cable_add_cxx_compiler_flag_if_supported(-Wimplicit-fallthrough)
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
# Cable
|
||||
|
||||
[![readme style: standard][readme style standard badge]][standard readme]
|
||||
|
||||
> Cable: CMake Bootstrap Library
|
||||
|
||||
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.
|
||||
|
||||
|
||||
## Table of Contents
|
||||
|
||||
- [Install](#install)
|
||||
- [Usage](#usage)
|
||||
- [Maintainer](#maintainer)
|
||||
- [License](#license)
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
### As git submodule
|
||||
|
||||
Include the Cable library as git submodule in your project. The suggested
|
||||
submodule location is `cmake/cable` relative to your project root directory.
|
||||
|
||||
```sh
|
||||
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
|
||||
Cable modules.
|
||||
|
||||
### Example
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
include(cmake/cable/bootstrap.cmake)
|
||||
include(CableBuildType)
|
||||
|
||||
project(tothemoon)
|
||||
|
||||
cable_set_build_type(DEFAULT RelWithDebInfo CONFIGURATION_TYPES Debug Release RelWithDebInfo)
|
||||
```
|
||||
|
||||
|
||||
## Maintainer
|
||||
|
||||
Paweł Bylica [@chfast]
|
||||
|
||||
## License
|
||||
|
||||
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
|
||||
[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
|
|
@ -1,20 +1,22 @@
|
|||
# Cable: CMake Bootstrap Library.
|
||||
# Copyright 2018 Pawel Bylica.
|
||||
# Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
|
||||
# Bootstrap the Cable - CMake Boostrap Library.
|
||||
# Bootstrap the Cable - CMake Boostrap Library by including this file.
|
||||
# e.g. include(cmake/cable/bootstrap.cmake).
|
||||
|
||||
|
||||
# Cable version.
|
||||
#
|
||||
# This is internal variable automaticaly updated with external tools.
|
||||
# Use CABLE_VERSION variable if you need this information.
|
||||
set(version 0.1.4)
|
||||
set(version 0.1.7)
|
||||
|
||||
|
||||
# For conveniance, add the parent dir containg CMake modules to module path.
|
||||
get_filename_component(module_dir ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
|
||||
list(APPEND CMAKE_MODULE_PATH ${module_dir})
|
||||
unset(module_dir)
|
||||
# For conveniance, add the project CMake module dir to module path.
|
||||
set(module_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
if(EXISTS ${module_dir})
|
||||
list(APPEND CMAKE_MODULE_PATH ${module_dir})
|
||||
endif()
|
||||
|
||||
|
||||
if(CABLE_VERSION)
|
||||
|
@ -43,15 +45,30 @@ if(CABLE_VERSION)
|
|||
|
||||
message(
|
||||
${severity}
|
||||
"[cable] Parent Cable ${CABLE_VERSION} (${comment}) initialized in `${cable_top_project_name}` project"
|
||||
"[cable ] Parent Cable ${CABLE_VERSION} (${comment}) initialized in `${cable_top_project_name}` project"
|
||||
)
|
||||
cable_debug("Project CMake modules directory: ${module_dir}")
|
||||
|
||||
unset(version)
|
||||
unset(module_dir)
|
||||
unset(severity)
|
||||
unset(comment)
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
||||
option(CABLE_DEBUG "Enable Cable debug logs" OFF)
|
||||
|
||||
function(cable_log)
|
||||
message(STATUS "[cable ] ${ARGN}")
|
||||
endfunction()
|
||||
|
||||
function(cable_debug)
|
||||
if(CABLE_DEBUG)
|
||||
message(STATUS "[cable*] ${ARGN}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Export Cable version.
|
||||
set(CABLE_VERSION ${version})
|
||||
|
||||
|
@ -61,6 +78,8 @@ set(PROJECT_IS_NESTED FALSE)
|
|||
# Add Cable modules to the CMake module path.
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
message(STATUS "[cable] Cable ${CABLE_VERSION} initialized")
|
||||
cable_log("Cable ${CABLE_VERSION} initialized")
|
||||
cable_debug("Project CMake modules directory: ${module_dir}")
|
||||
|
||||
unset(version)
|
||||
unset(module_dir)
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// Copyright 2018 Pawel Bylica.
|
||||
// Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
/* Cable: CMake Bootstrap Library.
|
||||
* Copyright 2018 Pawel Bylica.
|
||||
* Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
*/
|
||||
|
||||
// Generated by Cable Build Info on @TIMESTAMP@. Do not modify directly.
|
||||
/* Generated by Cable Build Info on @TIMESTAMP@. Do not modify directly. */
|
||||
|
||||
#include "@NAME@.h"
|
||||
|
||||
|
@ -9,12 +11,12 @@ const struct buildinfo* @FUNCTION_NAME@()
|
|||
{
|
||||
static const struct buildinfo buildinfo = {
|
||||
.project_version = "@PROJECT_VERSION@",
|
||||
.git_commit_hash = "@GIT_COMMIT_HASH@",
|
||||
.system_name = "@SYSTEM_NAME@",
|
||||
.system_processor = "@SYSTEM_PROCESSOR",
|
||||
.system_processor = "@SYSTEM_PROCESSOR@",
|
||||
.compiler_id = "@COMPILER_ID@",
|
||||
.compiler_version = "@COMPILER_VERSION@",
|
||||
.build_type = "@BUILD_TYPE@",
|
||||
.git_commit_hash = "@GIT_COMMIT_HASH@",
|
||||
};
|
||||
return &buildinfo;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,60 @@
|
|||
# Cable: CMake Bootstrap Library.
|
||||
# Copyright 2018 Pawel Bylica.
|
||||
# Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
|
||||
# Read the git commit hash from a file. The gitinfo is suppose to update the
|
||||
# file only if the hash changes.
|
||||
file(READ ${BINARY_DIR}/git_commit_hash.txt GIT_COMMIT_HASH)
|
||||
|
||||
string(TOLOWER ${SYSTEM_NAME} SYSTEM_NAME)
|
||||
string(TOLOWER ${SYSTEM_PROCESSOR} SYSTEM_PROCESSOR)
|
||||
string(TOLOWER ${COMPILER_ID} COMPILER_ID)
|
||||
string(TOLOWER ${BUILD_TYPE} BUILD_TYPE)
|
||||
string(TIMESTAMP TIMESTAMP)
|
||||
|
||||
# Read the git info from a file. The gitinfo is suppose to update the file
|
||||
# only if the information has changed.
|
||||
file(READ ${BINARY_DIR}/gitinfo.txt GIT_INFO)
|
||||
|
||||
# The output of `git describe --always --long --tags --match=v*`.
|
||||
string(REGEX MATCH "(v(.+)-([0-9]+)-g)?([0-9a-f]+)(-dirty)?" match "${GIT_INFO}")
|
||||
|
||||
if(NOT match)
|
||||
message(WARNING "Cannot parse git describe: ${GIT_INFO}")
|
||||
endif()
|
||||
|
||||
set(GIT_LATEST_PROJECT_VERSION ${CMAKE_MATCH_2})
|
||||
set(GIT_LATEST_PROJECT_VERSION_DISTANCE ${CMAKE_MATCH_3})
|
||||
set(GIT_COMMIT_HASH ${CMAKE_MATCH_4})
|
||||
if(CMAKE_MATCH_5)
|
||||
set(GIT_DIRTY TRUE)
|
||||
set(dirty_msg " (dirty)")
|
||||
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}")
|
||||
if(GIT_DIRTY)
|
||||
set(version_commit "${version_commit}.dirty")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(${PROJECT_VERSION} STREQUAL "${GIT_LATEST_PROJECT_VERSION}")
|
||||
if(${GIT_LATEST_PROJECT_VERSION_DISTANCE} GREATER 0)
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION}-${GIT_LATEST_PROJECT_VERSION_DISTANCE}${version_commit}")
|
||||
endif()
|
||||
else()
|
||||
if(GIT_LATEST_PROJECT_VERSION)
|
||||
message(WARNING "Git project version mismatch: '${GIT_LATEST_PROJECT_VERSION}' vs '${PROJECT_VERSION}'")
|
||||
endif()
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION}${version_commit}")
|
||||
endif()
|
||||
|
||||
message(
|
||||
" Project Version: ${PROJECT_VERSION}\n"
|
||||
" System Name: ${SYSTEM_NAME}\n"
|
||||
|
@ -18,7 +62,7 @@ message(
|
|||
" Compiler ID: ${COMPILER_ID}\n"
|
||||
" Compiler Version: ${COMPILER_VERSION}\n"
|
||||
" Build Type: ${BUILD_TYPE}\n"
|
||||
" Git Commit Hash: ${GIT_COMMIT_HASH}\n"
|
||||
" Git Info: ${GIT_LATEST_PROJECT_VERSION} ${GIT_LATEST_PROJECT_VERSION_DISTANCE} ${GIT_COMMIT_HASH}${dirty_msg}\n"
|
||||
" Timestamp: ${TIMESTAMP}"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
// Copyright 2018 Pawel Bylica.
|
||||
// Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
/* Cable: CMake Bootstrap Library.
|
||||
* Copyright 2018 Pawel Bylica.
|
||||
* Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
*/
|
||||
|
||||
// Generated by Cable Build Info on @TIMESTAMP@. Do not modify directly.
|
||||
/* Generated by Cable Build Info on @TIMESTAMP@. Do not modify directly. */
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -13,12 +15,12 @@ extern "C"
|
|||
struct buildinfo
|
||||
{
|
||||
const char* project_version;
|
||||
const char* git_commit_hash;
|
||||
const char* system_name;
|
||||
const char* system_processor;
|
||||
const char* compiler_id;
|
||||
const char* compiler_version;
|
||||
const char* build_type;
|
||||
const char* git_commit_hash;
|
||||
};
|
||||
|
||||
const struct buildinfo* @FUNCTION_NAME@();
|
||||
|
|
|
@ -1,26 +1,32 @@
|
|||
# Cable: CMake Bootstrap Library.
|
||||
# Copyright 2018 Pawel Bylica.
|
||||
# Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
|
||||
# Execute git only if the tool is available.
|
||||
if(GIT)
|
||||
execute_process(
|
||||
COMMAND ${GIT} rev-parse HEAD
|
||||
COMMAND ${GIT} describe --always --long --tags --match=v* --abbrev=40 --dirty
|
||||
WORKING_DIRECTORY ${SOURCE_DIR}
|
||||
OUTPUT_VARIABLE commit_hash
|
||||
OUTPUT_VARIABLE gitinfo
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
ERROR_VARIABLE error
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif()
|
||||
|
||||
set(commit_hash_file ${BINARY_DIR}/git_commit_hash.txt)
|
||||
if(error)
|
||||
message(WARNING "Git ${error}")
|
||||
endif()
|
||||
|
||||
if(EXISTS ${commit_hash_file})
|
||||
file(READ ${commit_hash_file} prev_commit_hash)
|
||||
set(gitinfo_file ${BINARY_DIR}/gitinfo.txt)
|
||||
|
||||
if(EXISTS ${gitinfo_file})
|
||||
file(READ ${gitinfo_file} prev_gitinfo)
|
||||
else()
|
||||
# Create empty file, because other targets expect it to exist.
|
||||
file(WRITE ${commit_hash_file} "")
|
||||
file(WRITE ${gitinfo_file} "")
|
||||
endif()
|
||||
|
||||
if(NOT "${commit_hash}" STREQUAL "${prev_commit_hash}")
|
||||
file(WRITE ${commit_hash_file} ${commit_hash})
|
||||
if(NOT "${gitinfo}" STREQUAL "${prev_gitinfo}")
|
||||
file(WRITE ${gitinfo_file} ${gitinfo})
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# Cable: CMake Bootstrap Library.
|
||||
# Copyright 2018 Pawel Bylica.
|
||||
# Licensed under the Apache License, Version 2.0. See the LICENSE file.
|
||||
|
||||
set(CMAKE_SYSTEM_PROCESSOR powerpc64)
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_C_COMPILER powerpc64-linux-gnu-gcc)
|
||||
set(CMAKE_CXX_COMPILER powerpc64-linux-gnu-g++)
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH /usr/powerpc64-linux-gnu)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if(${CMAKE_VERSION} VERSION_LESS 3.10.0)
|
||||
# Until CMake 3.10 the FindThreads uses try_run() check of -pthread flag,
|
||||
# what causes CMake error in crosscompiling mode. Avoid the try_run() check
|
||||
# by specifying the result up front.
|
||||
set(THREADS_PTHREAD_ARG TRUE)
|
||||
endif()
|
Loading…
Reference in New Issue