Skip to content

Commit 8534530

Browse files
authored
CMake: Print Version (#1820)
Print the WarpX and PICSAR version to the terminal. Fetched from `git` as usual. Will use a proper tag-prefixed description as soon as we add tags in the git history.
1 parent bb7ac5d commit 8534530

File tree

6 files changed

+47
-8
lines changed

6 files changed

+47
-8
lines changed

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ set_warpx_binary_name()
251251

252252
# Defines #####################################################################
253253
#
254+
get_source_version(WarpX ${CMAKE_CURRENT_SOURCE_DIR})
255+
target_compile_definitions(WarpX PUBLIC WARPX_GIT_VERSION="${WarpX_GIT_VERSION}")
256+
if(WarpX_QED)
257+
target_compile_definitions(WarpX PUBLIC PICSAR_GIT_VERSION="${PXRMP_QED_GIT_VERSION}")
258+
endif()
259+
254260
if(WarpX_DIMS STREQUAL 3)
255261
target_compile_definitions(WarpX PUBLIC WARPX_DIM_3D)
256262
elseif(WarpX_DIMS STREQUAL 2)

Source/Diagnostics/MultiDiagnostics.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ MultiDiagnostics::ReadParameters ()
4848
if (enable_diags == 1) {
4949
pp_diagnostics.queryarr("diags_names", diags_names);
5050
ndiags = diags_names.size();
51-
Print()<<"ndiags "<<ndiags<<'\n';
5251
}
5352

5453
diags_types.resize( ndiags );

Source/Initialization/WarpXInitData.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ void
6767
WarpX::InitData ()
6868
{
6969
WARPX_PROFILE("WarpX::InitData()");
70+
Print() << "WarpX (" << WarpX::Version() << ")\n";
71+
#ifdef WARPX_QED
72+
Print() << "PICSAR (" << WarpX::PicsarVersion() << ")\n";
73+
#endif
7074

7175
if (restart_chkfile.empty())
7276
{

Source/main.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,10 @@ int main(int argc, char* argv[])
5252

5353
warpx.Evolve();
5454

55-
auto end_total = static_cast<Real>(amrex::second()) - strt_total;
56-
57-
ParallelDescriptor::ReduceRealMax(end_total, ParallelDescriptor::IOProcessorNumber());
5855
if (warpx.Verbose()) {
56+
auto end_total = static_cast<Real>(amrex::second()) - strt_total;
57+
ParallelDescriptor::ReduceRealMax(end_total, ParallelDescriptor::IOProcessorNumber());
5958
Print() << "Total Time : " << end_total << '\n';
60-
Print() << "WarpX Version: " << WarpX::Version() << '\n';
61-
Print() << "PICSAR Version: " << WarpX::PicsarVersion() << '\n';
6259
}
6360
}
6461

cmake/WarpXFunctions.cmake

+29-1
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,40 @@ function(configure_mpiexec num_ranks)
268268
endfunction()
269269

270270

271+
# FUNCTION: get_source_version
272+
#
273+
# Retrieves source version info and sets internal cache variables
274+
# ${NAME}_GIT_VERSION and ${NAME}_PKG_VERSION
275+
#
276+
function(get_source_version NAME SOURCE_DIR)
277+
find_package(Git QUIET)
278+
set(_tmp "")
279+
280+
# Try to inquire software version from git
281+
if(EXISTS ${SOURCE_DIR}/.git AND ${GIT_FOUND})
282+
execute_process(COMMAND git describe --abbrev=12 --dirty --always --tags
283+
WORKING_DIRECTORY ${SOURCE_DIR}
284+
OUTPUT_VARIABLE _tmp)
285+
string( STRIP ${_tmp} _tmp)
286+
endif()
287+
288+
# Is there a CMake project version?
289+
# For deployed releases that build from tarballs, this is what we want to pick
290+
if(NOT _tmp AND ${NAME}_VERSION)
291+
set(_tmp "${${NAME}_VERSION}-nogit")
292+
endif()
293+
294+
set(${NAME}_GIT_VERSION "${_tmp}" CACHE INTERNAL "")
295+
unset(_tmp)
296+
endfunction ()
297+
298+
271299
# Prints a summary of WarpX options at the end of the CMake configuration
272300
#
273301
function(warpx_print_summary)
274302
message("")
275303
message("WarpX build configuration:")
276-
message(" Version: ${WarpX_VERSION}")
304+
message(" Version: ${WarpX_VERSION} (${WarpX_GIT_VERSION})")
277305
message(" C++ Compiler: ${CMAKE_CXX_COMPILER_ID} "
278306
"${CMAKE_CXX_COMPILER_VERSION} "
279307
"${CMAKE_CXX_COMPILER_WRAPPER}")

cmake/dependencies/PICSAR.cmake

+6-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function(find_picsar)
2828

2929
# Always disable tests
3030
set (PXRMP_QED_TEST OFF CACHE INTERNAL "")
31-
31+
3232
if(WarpX_COMPUTE STREQUAL SYCL)
3333
set (PXRMP_DPCPP_FIX ON CACHE INTERNAL "")
3434
endif()
@@ -38,6 +38,7 @@ function(find_picsar)
3838
${WarpX_picsar_src}/multi_physics/QED
3939
_deps/localpicsar-build/
4040
)
41+
get_source_version(PXRMP_QED ${WarpX_picsar_src})
4142
else()
4243
FetchContent_Declare(fetchedpicsar
4344
GIT_REPOSITORY ${WarpX_picsar_repo}
@@ -53,6 +54,10 @@ function(find_picsar)
5354
${fetchedpicsar_BINARY_DIR}
5455
)
5556
endif()
57+
get_source_version(PXRMP_QED ${fetchedpicsar_SOURCE_DIR})
58+
if(NOT PXRMP_QED_GIT_VERSION)
59+
set(PXRMP_QED_GIT_VERSION "${WarpX_picsar_branch}" CACHE INTERNAL "")
60+
endif()
5661

5762
# advanced fetch options
5863
mark_as_advanced(FETCHCONTENT_BASE_DIR)

0 commit comments

Comments
 (0)