mirror of
https://github.com/cosmo-sims/monofonIC.git
synced 2024-09-19 17:03:45 +02:00
added compile time version information output and new logo
This commit is contained in:
parent
6a515072ac
commit
b09b9c7589
4 changed files with 96 additions and 7 deletions
|
@ -1,18 +1,28 @@
|
|||
cmake_minimum_required(VERSION 3.9)
|
||||
set(PRGNAME fastLPT)
|
||||
project(fastLPT)
|
||||
set(PRGNAME monofonIC)
|
||||
project(monofonIC)
|
||||
|
||||
# include class submodule
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/external/class.cmake)
|
||||
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -march=native -Wall -fno-omit-frame-pointer -g -fsanitize=undefined")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -Wall -pedantic")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -march=native -Wall -fno-omit-frame-pointer -g -fsanitize=address")
|
||||
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -Wall -pedantic")
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
set(CMAKE_MODULE_PATH
|
||||
"${CMAKE_MODULE_PATH};${PROJECT_SOURCE_DIR}")
|
||||
|
||||
|
||||
########################################################################################################################
|
||||
# Add a custom command that produces version.cc, plus
|
||||
# a dummy output that's not actually produced, in order
|
||||
# to force version.cmake to always be re-run before the build
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cc
|
||||
${CMAKE_CURRENT_BINARY_DIR}/_version.cc
|
||||
COMMAND ${CMAKE_COMMAND} -P
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/version.cmake)
|
||||
|
||||
########################################################################################################################
|
||||
# OpenMP
|
||||
find_package(OpenMP REQUIRED)
|
||||
|
@ -53,6 +63,8 @@ include_directories(${PROJECT_SOURCE_DIR}/include)
|
|||
file( GLOB SOURCES
|
||||
${PROJECT_SOURCE_DIR}/src/*.cc
|
||||
)
|
||||
# add the auto generated version file
|
||||
list (APPEND SOURCES "${CMAKE_CURRENT_BINARY_DIR}/version.cc")
|
||||
|
||||
# PLUGINS
|
||||
# get all the *.cc files in the plugin subfolder
|
||||
|
|
|
@ -126,3 +126,13 @@ extern bool MPI_threads_ok;
|
|||
extern bool FFTW_threads_ok;
|
||||
extern int num_threads;
|
||||
} // namespace CONFIG
|
||||
|
||||
|
||||
// These variables are autogenerated and compiled
|
||||
// into the library by the version.cmake script
|
||||
extern "C"
|
||||
{
|
||||
extern const char* GIT_TAG;
|
||||
extern const char* GIT_REV;
|
||||
extern const char* GIT_BRANCH;
|
||||
}
|
22
src/main.cc
22
src/main.cc
|
@ -49,9 +49,25 @@ int main( int argc, char** argv )
|
|||
}
|
||||
#endif
|
||||
|
||||
csoca::ilog << "-----------------------------------------------------------------------------" << std::endl
|
||||
<< ">> FastLPT v0.1 >>" << std::endl
|
||||
<< "-----------------------------------------------------------------------------" << std::endl;
|
||||
csoca::ilog //<< " __ _____ _____ \n"
|
||||
//<< " / _| |_ _/ __ \\ \n"
|
||||
//<< " _ __ ___ ___ _ __ ___ | |_ ___ _ __ | | | / \\/ \n"
|
||||
//<< " | '_ ` _ \\ / _ \\| '_ \\ / _ \\| _/ _ \\| '_ \\ | | | | \n"
|
||||
//<< " | | | | | | (_) | | | | (_) | || (_) | | | || |_| \\__/\\ \n"
|
||||
//<< " |_| |_| |_|\\___/|_| |_|\\___/|_| \\___/|_| |_\\___/ \\____/ \n"
|
||||
//<< " \n"
|
||||
<< "\n\n"
|
||||
<< " .8888b dP a88888b. \n"
|
||||
<< " 88 \" 88 d8\' `88 \n"
|
||||
<< " 88d8b.d8b. .d8888b. 88d888b. .d8888b. 88aaa .d8888b. 88d888b. 88 88 \n"
|
||||
<< " 88\'`88\'`88 88\' `88 88\' `88 88\' `88 88 88\' `88 88\' `88 88 88 \n"
|
||||
<< " 88 88 88 88. .88 88 88 88. .88 88 88. .88 88 88 88 Y8. .88 \n"
|
||||
<< " dP dP dP `88888P\' dP dP `88888P\' dP `88888P\' dP dP dP Y88888P\' \n"
|
||||
<< " \n"
|
||||
<< "--------------------------------------------------------------------------------" << std::endl
|
||||
<< " version : v0.1a" << std::endl
|
||||
<< " git rev. : " << GIT_REV << ", tag: " << GIT_TAG << ", branch: " << GIT_BRANCH <<"\n"
|
||||
<< "--------------------------------------------------------------------------------" << std::endl;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
51
version.cmake
Normal file
51
version.cmake
Normal file
|
@ -0,0 +1,51 @@
|
|||
# CMake script to get git repository version at compile time
|
||||
# taken from Matt Keeter's blog and slightly adapted
|
||||
# https://www.mattkeeter.com/blog/2018-01-06-versioning/
|
||||
|
||||
execute_process(COMMAND git log --pretty=format:'%h' -n 1
|
||||
OUTPUT_VARIABLE GIT_REV
|
||||
ERROR_QUIET)
|
||||
|
||||
# Check whether we got any revision (which isn't
|
||||
# always the case, e.g. when someone downloaded a zip
|
||||
# file from Github instead of a checkout)
|
||||
if ("${GIT_REV}" STREQUAL "")
|
||||
set(GIT_REV "N/A")
|
||||
set(GIT_DIFF "")
|
||||
set(GIT_TAG "N/A")
|
||||
set(GIT_BRANCH "N/A")
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND bash -c "git diff --quiet --exit-code || echo +"
|
||||
OUTPUT_VARIABLE GIT_DIFF)
|
||||
execute_process(
|
||||
COMMAND git describe --exact-match --tags
|
||||
OUTPUT_VARIABLE GIT_TAG ERROR_QUIET)
|
||||
execute_process(
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
OUTPUT_VARIABLE GIT_BRANCH)
|
||||
|
||||
string(STRIP "${GIT_REV}" GIT_REV)
|
||||
string(SUBSTRING "${GIT_REV}" 1 7 GIT_REV)
|
||||
string(STRIP "${GIT_DIFF}" GIT_DIFF)
|
||||
string(STRIP "${GIT_TAG}" GIT_TAG)
|
||||
string(STRIP "${GIT_BRANCH}" GIT_BRANCH)
|
||||
endif()
|
||||
|
||||
if("${GIT_TAG}" STREQUAL "")
|
||||
set(GIT_TAG "N/A")
|
||||
endif()
|
||||
|
||||
set(VERSION "const char* GIT_REV=\"${GIT_REV}${GIT_DIFF}\";
|
||||
const char* GIT_TAG=\"${GIT_TAG}\";
|
||||
const char* GIT_BRANCH=\"${GIT_BRANCH}\";")
|
||||
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/version.cc)
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/version.cc VERSION_)
|
||||
else()
|
||||
set(VERSION_ "")
|
||||
endif()
|
||||
|
||||
if (NOT "${VERSION}" STREQUAL "${VERSION_}")
|
||||
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/version.cc "${VERSION}")
|
||||
endif()
|
Loading…
Reference in a new issue