I have written the CMakeLists.txt file for my HPGe detector simulation similar to the example given in B1 like:
#----------------------------------------------------------------------------
# Setup the project
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
project(hpge)
#----------------------------------------------------------------------------
# Find Geant4 package, activating all available UI and Vis drivers by default
# You can set WITH_GEANT4_UIVIS to OFF via the command line or ccmake/cmake-gui
# to build a batch mode only executable
#
option(WITH_GEANT4_UIVIS "Build example with Geant4 UI and Vis drivers" ON)
if(WITH_GEANT4_UIVIS)
find_package(Geant4 REQUIRED ui_all vis_all)
else()
find_package(Geant4 REQUIRED)
endif()
#----------------------------------------------------------------------------
# Setup Geant4 include directories and compile definitions
# Setup include directory for this project
#
include(${Geant4_USE_FILE})
include_directories(${PROJECT_SOURCE_DIR}/include)
#----------------------------------------------------------------------------
# Locate sources and headers for this project
# NB: headers are included so they will show up in IDEs
#
file(GLOB sources ${PROJECT_SOURCE_DIR}/src/*.cc)
file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.hh)
#----------------------------------------------------------------------------
# Add the executable, and link it to the Geant4 libraries
#
add_executable(hpge hpge_main.cc ${sources} ${headers})
target_link_libraries(hpge ${Geant4_LIBRARIES})
#----------------------------------------------------------------------------
# Copy all scripts to the build directory, i.e. the directory in which we
# build hpge. This is so that we can run the executable directly because it
# relies on these scripts being in the current working directory.
#
set(HPGE_SCRIPT
hepgeDet.in
hpgeDet.out
init_vis.mac
run1.mac
run2.mac
vis.mac
)
foreach(_script ${HPGE_SCRIPTS})
configure_file(
${PROJECT_SOURCE_DIR}/${_script}
${PROJECT_BINARY_DIR}/${_script}
COPYONLY
)
endforeach()
#----------------------------------------------------------------------------
# For internal Geant4 use - but has no effect if you build this
# example standalone
#
add_custom_target(hpgeDet DEPENDS hpge)
#----------------------------------------------------------------------------
# Install the executable to 'bin' directory under CMAKE_INSTALL_PREFIX
#
install(TARGETS hpge DESTINATION bin)
But it is showing me this error below. I guess the system can not detect the header files of geant4 to build the target.
20%] Building CXX object CMakeFiles/hpge.dir/hpge_main.cc.o
[ 40%] Building CXX object CMakeFiles/hpge.dir/src/hpgeDetectorConstruction.cc.o
[ 60%] Building CXX object CMakeFiles/hpge.dir/src/hpgePhysicsList.cc.o
[ 80%] Building CXX object CMakeFiles/hpge.dir/src/hpgePrimaryGeneratorAction.cc.o
/home/subhrod/G4_project/HPGe_design/hpge_main.cc:1:10: fatal error: G4RunManagerFactory.hh: No such file or directory
1 | #include "G4RunManagerFactory.hh"
| ^~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/hpge.dir/build.make:63: CMakeFiles/hpge.dir/hpge_main.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /home/subhrod/G4_project/HPGe_design/src/hpgePhysicsList.cc:2:
/home/subhrod/G4_project/HPGe_design/include/hpgePhysicsList.hh:1: error: unterminated #ifndef
1 | #ifndef hpgePhysicsList_h
|
In file included from /home/subhrod/G4_project/HPGe_design/src/hpgePhysicsList.cc:6:
/home/subhrod/G4_project/HPGe_design/include/hpgePhysicsList.hh:1: error: unterminated #ifndef
1 | #ifndef hpgePhysicsList_h
|
In file included from /home/subhrod/G4_project/HPGe_design/src/hpgePrimaryGeneratorAction.cc:1:
/home/subhrod/G4_project/HPGe_design/include/hpgePrimaryGeneratorAction.hh:16:32: error: ‘MeV’ was not declared in this scope
16 | G4double energy = 1. * MeV,
I could not able to detect the error in it. Please guide me the error and the way to solve this problem. It will be very helpful for me. Thank you.