mirror of https://github.com/status-im/evmc.git
commit
0d04650f9a
|
@ -0,0 +1 @@
|
|||
/.idea
|
|
@ -12,18 +12,19 @@ set(cable_buildinfo_template_dir ${CMAKE_CURRENT_LIST_DIR}/buildinfo)
|
|||
|
||||
function(cable_add_buildinfo_library)
|
||||
|
||||
cmake_parse_arguments("" "" PREFIX "" ${ARGN})
|
||||
cmake_parse_arguments("" "" PROJECT_NAME "" ${ARGN})
|
||||
|
||||
# Come up with the target and C function name.
|
||||
if(_PREFIX)
|
||||
set(NAME ${_PREFIX}-buildinfo)
|
||||
set(FUNCTION_NAME ${_PREFIX}_get_buildinfo)
|
||||
else()
|
||||
set(NAME buildinfo)
|
||||
set(FUNCTION_NAME get_buildinfo)
|
||||
if(NOT _PROJECT_NAME)
|
||||
message(FATAL_ERROR "The PROJECT_NAME argument missing")
|
||||
endif()
|
||||
|
||||
set(binary_dir ${CMAKE_CURRENT_BINARY_DIR})
|
||||
# Come up with the target and the C function names.
|
||||
set(name ${_PROJECT_NAME}-buildinfo)
|
||||
set(FUNCTION_NAME ${_PROJECT_NAME}_get_buildinfo)
|
||||
|
||||
set(output_dir ${CMAKE_CURRENT_BINARY_DIR}/${_PROJECT_NAME})
|
||||
set(header_file ${output_dir}/buildinfo.h)
|
||||
set(source_file ${output_dir}/buildinfo.c)
|
||||
|
||||
if(CMAKE_CONFIGURATION_TYPES)
|
||||
set(build_type ${CMAKE_CFG_INTDIR})
|
||||
|
@ -40,21 +41,21 @@ function(cable_add_buildinfo_library)
|
|||
# The executed script gitinfo.cmake check git status and updates files
|
||||
# containing git information if anything has changed.
|
||||
add_custom_target(
|
||||
${NAME}-git
|
||||
${name}-git
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DGIT=${GIT_EXECUTABLE}
|
||||
-DSOURCE_DIR=${PROJECT_SOURCE_DIR}
|
||||
-DBINARY_DIR=${binary_dir}
|
||||
-DOUTPUT_DIR=${output_dir}
|
||||
-P ${cable_buildinfo_template_dir}/gitinfo.cmake
|
||||
BYPRODUCTS ${binary_dir}/gitinfo.txt
|
||||
BYPRODUCTS ${output_dir}/gitinfo.txt
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
COMMENT "Updating ${NAME}:"
|
||||
OUTPUT ${binary_dir}/${NAME}.c
|
||||
COMMENT "Updating ${name}:"
|
||||
OUTPUT ${source_file}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DBINARY_DIR=${binary_dir}
|
||||
-DNAME=${NAME}
|
||||
-DOUTPUT_DIR=${output_dir}
|
||||
-DPROJECT_NAME=${_PROJECT_NAME}
|
||||
-DFUNCTION_NAME=${FUNCTION_NAME}
|
||||
-DPROJECT_VERSION=${PROJECT_VERSION}
|
||||
-DSYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
||||
|
@ -66,16 +67,22 @@ function(cable_add_buildinfo_library)
|
|||
DEPENDS
|
||||
${cable_buildinfo_template_dir}/buildinfo.cmake
|
||||
${cable_buildinfo_template_dir}/buildinfo.c.in
|
||||
${NAME}-git
|
||||
${binary_dir}/gitinfo.txt
|
||||
${name}-git
|
||||
${output_dir}/gitinfo.txt
|
||||
)
|
||||
|
||||
string(TIMESTAMP TIMESTAMP)
|
||||
configure_file(${cable_buildinfo_template_dir}/buildinfo.h.in ${binary_dir}/${NAME}.h)
|
||||
configure_file(${cable_buildinfo_template_dir}/buildinfo.h.in ${header_file})
|
||||
|
||||
# Add buildinfo library under given name.
|
||||
# Make is static and do not build by default until some other target will actually use it.
|
||||
add_library(${NAME} STATIC EXCLUDE_FROM_ALL ${binary_dir}/${NAME}.c ${binary_dir}/${NAME}.h)
|
||||
add_library(${name} STATIC EXCLUDE_FROM_ALL ${source_file} ${header_file})
|
||||
|
||||
target_include_directories(${NAME} PUBLIC ${binary_dir})
|
||||
target_include_directories(${name} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
set_target_properties(
|
||||
${name} PROPERTIES
|
||||
LIBRARY_OUTPUT_DIRECTORY ${output_dir}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${output_dir}
|
||||
OUTPUT_NAME buildinfo
|
||||
)
|
||||
endfunction()
|
||||
|
|
|
@ -121,9 +121,12 @@ macro(cable_configure_compiler)
|
|||
# Set the linker flags first, they are required to properly test the compiler flag.
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES "--coverage ${CMAKE_REQUIRED_LIBRARIES}")
|
||||
check_cxx_compiler_flag(--coverage have_coverage)
|
||||
string(REPLACE "--coverage " "" CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
|
||||
if(NOT have_coverage)
|
||||
message(FATAL_ERROR "Unsupported sanitizer: ${SANITIZE}")
|
||||
message(FATAL_ERROR "Coverage not supported")
|
||||
endif()
|
||||
add_compile_options(-g --coverage)
|
||||
endif()
|
||||
|
|
|
@ -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.2.3)
|
||||
set(version 0.2.6)
|
||||
|
||||
# For conveniance, add the project CMake module dir to module path.
|
||||
set(module_dir ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
|
||||
/* Generated by Cable Build Info on @TIMESTAMP@. Do not modify directly. */
|
||||
|
||||
#include "@NAME@.h"
|
||||
#include "buildinfo.h"
|
||||
|
||||
const struct buildinfo* @FUNCTION_NAME@()
|
||||
{
|
||||
static const struct buildinfo buildinfo = {
|
||||
.project_name = "@PROJECT_NAME@",
|
||||
.project_version = "@PROJECT_VERSION@",
|
||||
.project_name_with_version = "@PROJECT_NAME@-@PROJECT_VERSION@",
|
||||
.git_commit_hash = "@GIT_COMMIT_HASH@",
|
||||
.system_name = "@SYSTEM_NAME@",
|
||||
.system_processor = "@SYSTEM_PROCESSOR@",
|
||||
|
|
|
@ -10,7 +10,7 @@ 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)
|
||||
file(READ ${OUTPUT_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}")
|
||||
|
@ -48,8 +48,15 @@ else()
|
|||
set(PROJECT_VERSION "${PROJECT_VERSION}${version_commit}")
|
||||
endif()
|
||||
|
||||
if(PROJECT_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$")
|
||||
set(PROJECT_VERSION_IS_PRERELEASE false)
|
||||
else()
|
||||
set(PROJECT_VERSION_IS_PRERELEASE true)
|
||||
set(prerelease_comment " (prerelease)")
|
||||
endif()
|
||||
|
||||
message(
|
||||
" Project Version: ${PROJECT_VERSION}\n"
|
||||
" Project Version: ${PROJECT_VERSION}${prerelease_comment}\n"
|
||||
" System Name: ${SYSTEM_NAME}\n"
|
||||
" System Processor: ${SYSTEM_PROCESSOR}\n"
|
||||
" Compiler ID: ${COMPILER_ID}\n"
|
||||
|
@ -59,4 +66,6 @@ message(
|
|||
" Timestamp: ${TIMESTAMP}"
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/buildinfo.c.in ${BINARY_DIR}/${NAME}.c)
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/buildinfo.c.in ${OUTPUT_DIR}/buildinfo.c)
|
||||
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)
|
||||
|
|
|
@ -14,7 +14,9 @@ extern "C"
|
|||
|
||||
struct buildinfo
|
||||
{
|
||||
const char* project_name;
|
||||
const char* project_version;
|
||||
const char* project_name_with_version;
|
||||
const char* git_commit_hash;
|
||||
const char* system_name;
|
||||
const char* system_processor;
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
$env:project_name="@PROJECT_NAME@"
|
||||
$env:project_version="@PROJECT_VERSION@"
|
||||
$env:project_version_is_prerelease="@PROJECT_VERSION_IS_PRERELEASE@"
|
||||
$env:system_name='@SYSTEM_NAME@'
|
||||
$env:system_processor='@SYSTEM_PROCESSOR@'
|
|
@ -0,0 +1,5 @@
|
|||
PROJECT_NAME='@PROJECT_NAME@'
|
||||
PROJECT_VERSION='@PROJECT_VERSION@'
|
||||
PROJECT_VERSION_IS_PRERELEASE='@PROJECT_VERSION_IS_PRERELEASE@'
|
||||
SYSTEM_NAME='@SYSTEM_NAME@'
|
||||
SYSTEM_PROCESSOR='@SYSTEM_PROCESSOR@'
|
|
@ -18,7 +18,7 @@ if(error)
|
|||
message(WARNING "Git ${error}")
|
||||
endif()
|
||||
|
||||
set(gitinfo_file ${BINARY_DIR}/gitinfo.txt)
|
||||
set(gitinfo_file ${OUTPUT_DIR}/gitinfo.txt)
|
||||
|
||||
if(EXISTS ${gitinfo_file})
|
||||
file(READ ${gitinfo_file} prev_gitinfo)
|
||||
|
|
Loading…
Reference in New Issue