Import Geant4 9.6.0 source tree
This commit is contained in:
@@ -1,55 +1,68 @@
|
||||
# - Basic setup for testing Geant4 using CTest
|
||||
# Still rather rough.
|
||||
#
|
||||
# - Basic setup for testing Geant4 using CMake/CTest
|
||||
#
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Configure CTest and relevant Geant4 settings, if required
|
||||
#
|
||||
if(GEANT4_ENABLE_TESTING)
|
||||
# - Core CTest
|
||||
enable_testing()
|
||||
include(CTest)
|
||||
|
||||
#---Deduce the build name--------------------------------------------------------
|
||||
set(BUILDNAME ${GEANT4_SYSTEM}-${GEANT4_COMPILER}-${CMAKE_BUILD_TYPE})
|
||||
enable_testing()
|
||||
include(CTest)
|
||||
# - Geant4_DIR is needed to locate GeantConfig.cmake file required
|
||||
# by tests and examples
|
||||
set(Geant4_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Current build directory")
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# OLD STYLE DATA CONFIGURATION
|
||||
# - Configure data location, as most tests will require access to these
|
||||
#if(GEANT4_INSTALL_DATA)
|
||||
# set(GEANT4_DATA_DIR ${CMAKE_BINARY_DIR}/data CACHE PATH "Directory where the Geant4 data is located")
|
||||
#elseif(NOT "$ENV{GEANT4_DATA_DIR}" STREQUAL "")
|
||||
# set(GEANT4_DATA_DIR "$ENV{GEANT4_DATA_DIR}" CACHE PATH "Directory where the Geant4 data is located" FORCE)
|
||||
#endif()
|
||||
|
||||
#if(NOT GEANT4_DATA_DIR)
|
||||
# message(STATUS " GEANT4_DATA_DIR not defined! This may cause many Geant4 tests to fail\n"
|
||||
# " Add -DGEANT4_DATA_DIR=<path> to the cmake command or define environment")
|
||||
# return()
|
||||
#endif()
|
||||
|
||||
#---Many tests require access to the Geant4 data----------------------------------------------------
|
||||
if(GEANT4_INSTALL_DATA)
|
||||
set(GEANT4_DATA_DIR ${CMAKE_BINARY_DIR}/data CACHE PATH "Directory where the Geant4 data is located")
|
||||
else()
|
||||
set(GEANT4_DATA_DIR "" CACHE PATH "Directory where the Geant4 data is located")
|
||||
# - Configure test environment (basically, the data library pointers)
|
||||
#foreach( tuple "G4NEUTRONHPDATA;G4NDL"
|
||||
# "G4LEDATA;G4EMLOW"
|
||||
# "G4LEVELGAMMADATA;PhotonEvaporation"
|
||||
# "G4RADIOACTIVEDATA;RadioactiveDecay"
|
||||
# "G4NEUTRONXSDATA;G4NEUTRONXS"
|
||||
# "G4PIIDATA;G4PII"
|
||||
# "G4REALSURFACEDATA;RealSurface"
|
||||
# "G4SAIDXSDATA;G4SAIDDATA"
|
||||
# )
|
||||
# list(GET tuple 0 envname)
|
||||
# list(GET tuple 1 dirname)
|
||||
# GEANT4_LATEST_VERSION(${GEANT4_DATA_DIR} ${dirname} _result)
|
||||
# #list(APPEND GEANT4_TEST_ENVIRONMENT ${envname}=${_result})
|
||||
#endforeach()
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# - Configure data using new style API methods
|
||||
geant4_get_datasetnames(_dslist)
|
||||
foreach(_ds ${_dslist})
|
||||
geant4_get_dataset_property(${_ds} ENVVAR _dsenvvar)
|
||||
geant4_get_dataset_property(${_ds} BUILD_DIR _dspath)
|
||||
list(APPEND GEANT4_TEST_ENVIRONMENT ${_dsenvvar}=${_dspath})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(Geant4_DIR ${CMAKE_BINARY_DIR} CACHE PATH "Current build directory")
|
||||
|
||||
|
||||
if(NOT GEANT4_DATA_DIR)
|
||||
message(WARNING "GEANT4_DATA_DIR not defined! This may cause many Geant4 tests to fail")
|
||||
return()
|
||||
endif()
|
||||
|
||||
#---Helper function to locate the most recent version of a dataset-----------------------------------
|
||||
function(GEANT4_LATEST_VERSION dir name var)
|
||||
file(GLOB files RELATIVE ${dir} ${dir}/${name}*)
|
||||
set(newer 0.0)
|
||||
foreach(file ${files})
|
||||
string(REPLACE ${name} "" version ${file})
|
||||
if(${version} VERSION_GREATER ${newer})
|
||||
set(newer ${version})
|
||||
#-----------------------------------------------------------------------
|
||||
# Add Unit Tests if required
|
||||
#
|
||||
if(GEANT4_BUILD_TESTS)
|
||||
file(GLOB_RECURSE files RELATIVE ${CMAKE_SOURCE_DIR} source/CMakeLists.txt)
|
||||
foreach( file ${files} )
|
||||
get_filename_component(path ${file} PATH)
|
||||
if(path MATCHES "/test$")
|
||||
add_subdirectory(${path})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${var} ${dir}/${name}${newer} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
#---Define the TEST environment (basically the varibles pointing to DATA files)----------------------
|
||||
foreach( tuple "G4LEVELGAMMADATA;PhotonEvaporation"
|
||||
"G4LEDATA;G4EMLOW"
|
||||
"G4RADIOACTIVEDATA;RadioactiveDecay"
|
||||
"G4ELASTICDATA;G4ELASTIC"
|
||||
"NeutronHPCrossSections;G4NDL"
|
||||
"G4NEUTRONHPDATA;G4NDL"
|
||||
"G4ABLADATA;G4ABLA"
|
||||
"G4PIIDATA;G4PII"
|
||||
"G4NEUTRONXSDATA;G4NEUTRONXS")
|
||||
list(GET tuple 0 envname)
|
||||
list(GET tuple 1 dirname)
|
||||
GEANT4_LATEST_VERSION(${GEANT4_DATA_DIR} ${dirname} _result)
|
||||
list(APPEND GEANT4_TEST_ENVIRONMENT ${envname}=${_result})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user