use cmake

This commit is contained in:
Martin Errenst 2017-08-27 16:54:47 +02:00
parent 0a8fbdc588
commit 0b2764ea61
3 changed files with 18 additions and 0 deletions

3
.gitignore vendored
View file

@ -1 +1,4 @@
a.out a.out
build/
CMakeCache.txt
CMakeFiles

14
CMakeLists.txt Normal file
View file

@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.7.2)
project (dump-build-information)
add_executable(dummy dummy.cpp )
set_target_properties(dummy PROPERTIES COMPILE_FLAGS ${BUILD_FLAGS} -frecord-gcc-switches)
add_custom_command (OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/buildinformation.h
COMMAND echo \"\#define USED_FLAGS \\\"\"`readelf -p .GCC.command.line ${CMAKE_CURRENT_BINARY_DIR}/dummy | grep -v -e dummy -e "-frecord-gcc-switches" | grep -e \"\\[.*\\]\" | cut -d\\] -f2- | tr -d \"\\n\"`\\\" >> ${CMAKE_CURRENT_BINARY_DIR}/buildinformation.h
COMMAND echo \"\#define GIT_VERSION \\\"\"`git describe --dirty --always --tags`\\\" >> ${CMAKE_CURRENT_BINARY_DIR}/buildinformation.h
COMMAND echo \"\#define USED_COMPILER \\\"\"`${CMAKE_C_COMPILER} --version | head -n1`\\\" >> ${CMAKE_CURRENT_BINARY_DIR}/buildinformation.h
DEPENDS dummy
)
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
add_executable(dump-build-information main.cpp ${CMAKE_CURRENT_BINARY_DIR}/buildinformation.h )

View file

@ -1,4 +1,5 @@
#include <iostream> #include <iostream>
#include "buildinformation.h"
void print_build_information(){ void print_build_information(){
std::cout << "Build from revision: " << GIT_VERSION << std::endl; std::cout << "Build from revision: " << GIT_VERSION << std::endl;