Can now print build info

This commit is contained in:
Gavin Ridley 2022-10-05 17:45:51 -04:00
parent 9a86c9c065
commit 5582180e31
4 changed files with 76 additions and 0 deletions

View file

@ -482,6 +482,19 @@ if (OPENMC_USE_MPI)
target_link_libraries(libopenmc MPI::MPI_CXX)
endif()
#===============================================================================
# Log build info that this executable can report later
#===============================================================================
target_compile_definitions(libopenmc PRIVATE BUILD_TYPE=${CMAKE_BUILD_TYPE})
target_compile_definitions(libopenmc PRIVATE COMPILER_ID=${CMAKE_CXX_COMPILER_ID})
target_compile_definitions(libopenmc PRIVATE COMPILER_VERSION=${CMAKE_CXX_COMPILER_VERSION})
if (OPENMC_ENABLE_PROFILE)
target_compile_definitions(libopenmc PRIVATE PROFILINGBUILD)
endif()
if (OPENMC_ENABLE_COVERAGE)
target_compile_definitions(libopenmc PRIVATE COVERAGEBUILD)
endif()
#===============================================================================
# openmc executable
#===============================================================================

View file

@ -40,6 +40,9 @@ void print_usage();
//! Display current version and copright/license information
void print_version();
//! Display compile flags employed, etc
void print_build_info();
//! Display header listing what physical values will displayed
void print_columns();

View file

@ -262,6 +262,10 @@ int parse_command_line(int argc, char* argv[])
print_version();
return OPENMC_E_UNASSIGNED;
} else if (arg == "-b" || arg == "--build-info") {
print_build_info();
return OPENMC_E_UNASSIGNED;
} else if (arg == "-t" || arg == "--track") {
settings::write_all_tracks = true;

View file

@ -325,6 +325,7 @@ void print_usage()
"max_tracks)\n"
" -e, --event Run using event-based parallelism\n"
" -v, --version Show version information\n"
" -b, --build-info Show compile options\n"
" -h, --help Show this message\n");
}
}
@ -347,6 +348,61 @@ void print_version()
//==============================================================================
void print_build_info()
{
const std::string n("no");
const std::string y("yes");
std::string mpi(n);
std::string phdf5(n);
std::string dagmc(n);
std::string libmesh(n);
std::string png(n);
std::string profiling(n);
std::string coverage(n);
#ifdef PHDF5
phdf5 = y;
#endif
#ifdef OPENMC_MPI
mpi = y;
#endif
#ifdef DAGMC
dagmc = y;
#endif
#ifdef LIBMESH
libmesh = y;
#endif
#ifdef USE_LIBPNG
png = y;
#endif
#ifdef PROFILINGBUILD
profiling = y;
#endif
#ifdef COVERAGEBUILD
coverage = y;
#endif
// Wraps macro variables in quotes
#define STRINGIFY(x) STRINGIFY2(x)
#define STRINGIFY2(x) #x
if (mpi::master) {
fmt::print("Build type: {}\n", STRINGIFY(BUILD_TYPE));
fmt::print("Compiler ID: {} {}\n", STRINGIFY(COMPILER_ID),
STRINGIFY(COMPILER_VERSION));
fmt::print("MPI enabled: {}\n", mpi);
fmt::print("Parallel HDF5 enabled: {}\n", phdf5);
fmt::print("PNG support: {}\n", png);
fmt::print("DAGMC support: {}\n", dagmc);
fmt::print("libMesh support: {}\n", libmesh);
fmt::print("Coverage testing: {}\n", coverage);
fmt::print("Profiling flags: {}\n", profiling);
}
}
//==============================================================================
void print_columns()
{
if (settings::entropy_on) {