Skip to content

Commit dc0731c

Browse files
authored
Merge pull request #2253 from gridley/buildinfo
Can now print some build info
2 parents dff3ad4 + f58f478 commit dc0731c

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,19 @@ if (OPENMC_USE_MPI)
482482
target_link_libraries(libopenmc MPI::MPI_CXX)
483483
endif()
484484

485+
#===============================================================================
486+
# Log build info that this executable can report later
487+
#===============================================================================
488+
target_compile_definitions(libopenmc PRIVATE BUILD_TYPE=${CMAKE_BUILD_TYPE})
489+
target_compile_definitions(libopenmc PRIVATE COMPILER_ID=${CMAKE_CXX_COMPILER_ID})
490+
target_compile_definitions(libopenmc PRIVATE COMPILER_VERSION=${CMAKE_CXX_COMPILER_VERSION})
491+
if (OPENMC_ENABLE_PROFILE)
492+
target_compile_definitions(libopenmc PRIVATE PROFILINGBUILD)
493+
endif()
494+
if (OPENMC_ENABLE_COVERAGE)
495+
target_compile_definitions(libopenmc PRIVATE COVERAGEBUILD)
496+
endif()
497+
485498
#===============================================================================
486499
# openmc executable
487500
#===============================================================================

include/openmc/output.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ void print_usage();
4040
//! Display current version and copright/license information
4141
void print_version();
4242

43+
//! Display compile flags employed, etc
44+
void print_build_info();
45+
4346
//! Display header listing what physical values will displayed
4447
void print_columns();
4548

src/initialize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ int parse_command_line(int argc, char* argv[])
260260

261261
} else if (arg == "-v" || arg == "--version") {
262262
print_version();
263+
print_build_info();
263264
return OPENMC_E_UNASSIGNED;
264265

265266
} else if (arg == "-t" || arg == "--track") {

src/output.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,61 @@ void print_version()
347347

348348
//==============================================================================
349349

350+
void print_build_info()
351+
{
352+
const std::string n("no");
353+
const std::string y("yes");
354+
355+
std::string mpi(n);
356+
std::string phdf5(n);
357+
std::string dagmc(n);
358+
std::string libmesh(n);
359+
std::string png(n);
360+
std::string profiling(n);
361+
std::string coverage(n);
362+
363+
#ifdef PHDF5
364+
phdf5 = y;
365+
#endif
366+
#ifdef OPENMC_MPI
367+
mpi = y;
368+
#endif
369+
#ifdef DAGMC
370+
dagmc = y;
371+
#endif
372+
#ifdef LIBMESH
373+
libmesh = y;
374+
#endif
375+
#ifdef USE_LIBPNG
376+
png = y;
377+
#endif
378+
#ifdef PROFILINGBUILD
379+
profiling = y;
380+
#endif
381+
#ifdef COVERAGEBUILD
382+
coverage = y;
383+
#endif
384+
385+
// Wraps macro variables in quotes
386+
#define STRINGIFY(x) STRINGIFY2(x)
387+
#define STRINGIFY2(x) #x
388+
389+
if (mpi::master) {
390+
fmt::print("Build type: {}\n", STRINGIFY(BUILD_TYPE));
391+
fmt::print("Compiler ID: {} {}\n", STRINGIFY(COMPILER_ID),
392+
STRINGIFY(COMPILER_VERSION));
393+
fmt::print("MPI enabled: {}\n", mpi);
394+
fmt::print("Parallel HDF5 enabled: {}\n", phdf5);
395+
fmt::print("PNG support: {}\n", png);
396+
fmt::print("DAGMC support: {}\n", dagmc);
397+
fmt::print("libMesh support: {}\n", libmesh);
398+
fmt::print("Coverage testing: {}\n", coverage);
399+
fmt::print("Profiling flags: {}\n", profiling);
400+
}
401+
}
402+
403+
//==============================================================================
404+
350405
void print_columns()
351406
{
352407
if (settings::entropy_on) {

0 commit comments

Comments
 (0)