compileenv.txt 1.3 KB
Newer Older
1 2 3 4
#this file sets some preprocessor variables that are used in
#init/compile_descr.F90 to determine the programm version and
#some compilation environment description

Daniel Wortmann's avatar
Daniel Wortmann committed
5
cmake_host_system_information(RESULT compile_host QUERY HOSTNAME)
6 7 8
set(compile_user $ENV{USER})
string(TIMESTAMP compile_time)
set(git_hash unkown)
Daniel Wortmann's avatar
Daniel Wortmann committed
9
set(git_describe unkown)
Daniel Wortmann's avatar
Daniel Wortmann committed
10
set(git_branch unkown)
11
if (EXISTS ${CMAKE_SOURCE_DIR}/.git)
12
  execute_process(COMMAND git describe --tags WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE git_describe)
Daniel Wortmann's avatar
Daniel Wortmann committed
13
  execute_process(COMMAND git rev-parse --abbrev-ref HEAD  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE git_branch)
14
  execute_process(COMMAND git rev-parse  HEAD WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} OUTPUT_VARIABLE git_hash)
15 16 17 18 19 20 21
elseif (EXISTS ${CMAKE_SOURCE_DIR}/version)
  file(READ ${CMAKE_SOURCE_DIR}/version git_describe)
endif()

#normalize the strings
string(STRIP  ${git_hash} git_hash)
string(STRIP ${git_describe} git_describe)
Daniel Wortmann's avatar
Daniel Wortmann committed
22
string(STRIP ${git_branch} git_branch)
23

24
file(GENERATE OUTPUT ${CMAKE_SOURCE_DIR}/init/compileinfo.h CONTENT "gitdesc=\"${git_describe}\"\ncompile_date=\"${compile_time}\"\ncompile_user=\"${compile_user}\"\ncompile_host=\"${compile_host}\"\ngitbranch=\"${git_branch}\"\ngithash=\"${git_hash}\"\ncompile_flags=\"${CMAKE_Fortran_FLAGS}\"\nlink_flags=\"${FLEUR_LIBRARIES}\"\n")