Skip to content
Snippets Groups Projects
Commit adb2abe2 authored by Tom Fischer's avatar Tom Fischer
Browse files

- added option to generate build information in CMakeLists.txt

[BaseLib/BuildInfo.h.in]
- copied file from OGS-5 and modified it a little bit

[SimpleTests/MatrixTests/MatVecMultNDPerm.cpp]
- program prints build and executing host information
parent 8b7add1f
No related branches found
No related tags found
No related merge requests found
/**
* \file BuildInfo.h.in
* 24/08/2010 LB Initial implementation
* #defines which gets set through CMake
*/
#ifndef BUILDINFO_H
#define BUILDINFO_H
#cmakedefine CMAKE_CMD_ARGS "${CMAKE_CMD_ARGS}"
#cmakedefine CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}"
// #cmakedefine SVN_REVISION "${SVN_REVISION}"
// #cmakedefine GIT_COMMIT_INFO "${GIT_COMMIT_INFO}"
// #cmakedefine GIT_BRANCH_INFO "${GIT_BRANCH_INFO}"
// #cmakedefine BUILD_TIMESTAMP "${BUILD_TIMESTAMP}"
// #cmakedefine CMAKE_RUN_TIMESTAMP ""
// #cmakedefine CMAKE_SYSTEM "${CMAKE_SYSTEM}-x${BITS}"
#cmakedefine CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}"
#cmakedefine CMAKE_CXX_COMPILER "${CMAKE_CXX_COMPILER}"
#cmakedefine CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}"
#cmakedefine CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}"
#cmakedefine CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}"
#cmakedefine CMAKE_GENERATOR "${CMAKE_GENERATOR}"
#endif // BUILDINFO_H
...@@ -34,6 +34,11 @@ IF (OGS_CMAKE_DEBUG) ...@@ -34,6 +34,11 @@ IF (OGS_CMAKE_DEBUG)
list_all_cmake_variable_values() list_all_cmake_variable_values()
ENDIF (OGS_CMAKE_DEBUG) ENDIF (OGS_CMAKE_DEBUG)
OPTION(OGS_BUILD_INFO "Should build information be generated" ON)
IF (OGS_BUILD_INFO)
ADD_DEFINITIONS (-DOGS_BUILD_INFO)
ENDIF (OGS_BUILD_INFO)
###################### ######################
### Subdirectories ### ### Subdirectories ###
###################### ######################
...@@ -52,3 +57,7 @@ IF(NOT MSVC) ...@@ -52,3 +57,7 @@ IF(NOT MSVC)
ADD_SUBDIRECTORY( SimpleTests/SolverTests ) ADD_SUBDIRECTORY( SimpleTests/SolverTests )
ENDIF(NOT MSVC) ENDIF(NOT MSVC)
# Create Configure.h
CONFIGURE_FILE (BaseLib/BuildInfo.h.in ${PROJECT_BINARY_DIR}/BaseLib/BuildInfo.h)
...@@ -12,6 +12,7 @@ ENDIF (CMAKE_USE_PTHREADS_INIT ) ...@@ -12,6 +12,7 @@ ENDIF (CMAKE_USE_PTHREADS_INIT )
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
. .
${CMAKE_SOURCE_DIR}/BaseLib/ ${CMAKE_SOURCE_DIR}/BaseLib/
${CMAKE_BINARY_DIR}/BaseLib/
${CMAKE_SOURCE_DIR}/BaseLib/logog/include ${CMAKE_SOURCE_DIR}/BaseLib/logog/include
${CMAKE_SOURCE_DIR}/MathLib/ ${CMAKE_SOURCE_DIR}/MathLib/
) )
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifdef OGS_BUILD_INFO #ifdef OGS_BUILD_INFO
#include "BuildInfo.h" #include "BuildInfo.h"
#include <sys/unistd.h>
#endif #endif
// BaseLib // BaseLib
...@@ -79,7 +80,17 @@ int main(int argc, char *argv[]) ...@@ -79,7 +80,17 @@ int main(int argc, char *argv[])
logogCout->SetFormatter(*custom_format); logogCout->SetFormatter(*custom_format);
#ifdef OGS_BUILD_INFO #ifdef OGS_BUILD_INFO
INFO("git commit: %s, executed on machine: ", GIT_COMMIT_INFO); INFO("compiler: %s", CMAKE_CXX_COMPILER);
if (std::string(CMAKE_BUILD_TYPE).compare("Release") == 0) {
INFO("CXX_FLAGS: %s %s", CMAKE_CXX_FLAGS, CMAKE_CXX_FLAGS_RELEASE);
} else {
INFO("CXX_FLAGS: %s %s", CMAKE_CXX_FLAGS, CMAKE_CXX_FLAGS_DEBUG);
}
const size_t length(256);
char *hostname(new char[length]);
gethostname (hostname, length);
INFO("hostname: %s", hostname);
delete [] hostname;
#endif #endif
// *** reading matrix in crs format from file // *** reading matrix in crs format from file
...@@ -95,7 +106,7 @@ int main(int argc, char *argv[]) ...@@ -95,7 +106,7 @@ int main(int argc, char *argv[])
CS_read(in, n, iA, jA, A); CS_read(in, n, iA, jA, A);
timer.stop(); timer.stop();
if (verbose) { if (verbose) {
INFO("ok, %e s", timer.elapsed()); INFO("\t- took %e s", timer.elapsed());
} }
} else { } else {
ERR("error reading matrix from %s", fname_mat.c_str()); ERR("error reading matrix from %s", fname_mat.c_str());
...@@ -103,7 +114,7 @@ int main(int argc, char *argv[]) ...@@ -103,7 +114,7 @@ int main(int argc, char *argv[])
} }
unsigned nnz(iA[n]); unsigned nnz(iA[n]);
if (verbose) { if (verbose) {
INFO("Parameters read: n=%d, nnz=%d", n, nnz); INFO("\tParameters read: n=%d, nnz=%d", n, nnz);
} }
MathLib::CRSMatrixReordered mat(n, iA, jA, A); MathLib::CRSMatrixReordered mat(n, iA, jA, A);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment