diff --git a/CMake/POET_Scripts.cmake b/CMake/POET_Scripts.cmake new file mode 100644 index 000000000..69760cc44 --- /dev/null +++ b/CMake/POET_Scripts.cmake @@ -0,0 +1,28 @@ +# Set or get version +macro(get_POET_version) + if(EXISTS ${PROJECT_SOURCE_DIR}/.git) + find_program(GIT_EXECUTABLE git DOC "git executable") + mark_as_advanced(GIT_EXECUTABLE) + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE POET_GIT_BRANCH + OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --always + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE POET_GIT_VERSION + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT POET_GIT_BRANCH STREQUAL "master") + set(POET_VERSION "${POET_GIT_BRANCH}/${POET_GIT_VERSION}") + else() + set(POET_VERSION "${POET_GIT_VERSION}") + endif() + elseif(EXISTS ${PROJECT_SOURCE_DIR}/.svn) + file(STRINGS .gitversion POET_VERSION) + else() + set(POET_VERSION "0.1") + endif() + + message(STATUS "Configuring POET version ${POET_VERSION}") +endmacro(get_POET_version) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97d03e37c..3f1a0f4fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Version 3.9+ offers new MPI package variables cmake_minimum_required(VERSION 3.9) -project(POET VERSION 0.1 LANGUAGES CXX C) +project(POET CXX C) # specify the C++ standard set(CMAKE_CXX_STANDARD 14) @@ -9,10 +9,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) +include("CMake/POET_Scripts.cmake") list(APPEND CMAKE_MODULE_PATH "${POET_SOURCE_DIR}/CMake") -# set(GCC_CXX_FLAGS "-D STRICT_R_HEADERS") -# add_definitions(${GCC_CXX_FLAGS}) +# set(GCC_CXX_FLAGS "-D STRICT_R_HEADERS") add_definitions(${GCC_CXX_FLAGS}) find_package(MPI REQUIRED) diff --git a/README.md b/README.md index cb5565209..079a6bad0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ - @@ -22,7 +21,7 @@ To compile POET you need several software to be installed: - C/C++ compiler (tested with GCC) - MPI-Implementation (tested with OpenMPI and MVAPICH) -- R language and environment +- R language and environment - CMake 3.9+ If documantiation should be build during compilation `doxygen`and `graphviz` @@ -38,31 +37,43 @@ The following R libraries must then be installed: ### Compiling source code -The generation of makefiles is done with CMake. So, running +The generation of makefiles is done with CMake. If you obtain POET from a git repository you should be able to generate Makefiles by running -``` -cmake . -B build +```sh +mkdir build && cd build +cmake .. ``` -will create the directory `build`. `cd` into it and run `make` to start build +This will create the directory `build` and processes the CMake files and generate Makefiles from it. You're now able to run `make` to start build process. -If everything went well you'll find the executable at `build/src/poet`. +If POET was obtained from the official SVN repository or the redmine at the branch or tag to be used have to be set via -During the generation of Makefiles, various options can be specified via `cmake --D