GEANT4 installation - CMake Error - CMAKE_HAVE_LIBC_PTHREAD - Failed

Hello GEANT4 installation specialists,

_Geant4 Version:_11.3.0
_Operating System:_Red Hat Enterprise Linux 8.8
_Compiler/Version:_gcc-native/13.2.0
_CMake Version:_cmake/3.27.2 (same problem with 3.20.2)

I have a problem when installing GEANT4 version 11.3.0. I tried to build and install GEANT4, but I encountered the following error during the build process:

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
CMake Error at cmake/Modules/G4ConfigureGNUMakeHelpers.cmake:578 (get_filename_component):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  cmake/Modules/G4ConfigureGNUMakeHelpers.cmake:694 (_g4tc_configure_tc_variables)
  cmake/Modules/G4ConfigureGNUMakeHelpers.cmake:770 (_g4tc_configure_build_tree_scripts)
  cmake/Modules/G4CMakeMain.cmake:91 (include)
  CMakeLists.txt:49 (include)
-- Configuring incomplete, errors occurred!
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target 'install'.  Stop.

Here is the GEANT4 installation script I use to perform the installation :

#!/bin/sh
. /XXX/Geant4/scripts/env_softstack.sh
export VERSION=11.3.0
export CC=gcc
export CXX=g++
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_CXX_FLAGS='-std=gnu++11 -ftls-model=global-dynamic -pthread' \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_CXX_STANDARD=17 \
-DGEANT4_USE_GDML=ON \
-DGEANT4_BUILD_MULTITHREADED=ON \
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
-DGEANT4_USE_SYSTEM_EXPAT=on \
-DGEANT4_USE_OPENGL=OFF \
-DGEANT4_INSTALL_DATADIR=${SOFTSTACK_HOME}/data/DATA_G4 \
-DXercesC_LIBRARY=${XERCES_HOME}/lib64/libxerces-c-3.2.so \
-DXercesC_INCLUDE_DIR=${XERCES_HOME}/include \
-DCMAKE_PREFIX_PATH=${XERCES_HOME} \
-DCMAKE_INSTALL_PREFIX=${SOFTSTACK_HOME}/install/geant4.${VERSION} \
${SOFTSTACK_HOME}/src/geant4.${VERSION}
make -j 1 
make install

I am running first env_softstack.sh to set variables for paths :

#!/bin/bash
export SOFTSTACK_HOME=/XXX/Geant4
module load cmake/3.27.2
module load gcc-native/13.2.0
export XERCES_HOME=${SOFTSTACK_HOME}/install/xerces-c-3.2.3/
export LD_LIBRARY_PATH=${XERCES_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${XERCES_HOME}/bin:${PATH}
export GEANT4_HOME=${SOFTSTACK_HOME}/install/geant4.11.3.0/
export LD_LIBRARY_PATH=${GEANT4_HOME}/lib64:${LD_LIBRARY_PATH}
export PATH=${GEANT4_HOME}/bin:${PATH}

I would like to add that, I previously installed XERCES successfully. Additionally, with a very similar GEANT4 installation script that the one above, I was able to install the previous GEANT4 version 10.07.p01 few years ago, but I am stuck with this new 11.3.0 version.
Could anyone have the same issue regarding ‘pthread’?
If needed, I can also provide a CMakeError.log in using CMake 3.20.2.

Thank you so much for your time and help.

Hi,

I had an issue with glibc and xerces on an old linux install - solved via using apptainer. It’s my only post here.

Try to remove the obsolete redefinition of CMAKE_CXX_FLAGS in your script and simply use the default settings.

Thank you very much for your response.

I tried removing the command CMAKE_CXX_FLAGS from my installation script as you mentioned, but I encountered the same issue.
I also tried removing the following line:
-DGEANT4_BUILD_TLS_MODEL=global-dynamic
Finally, I attempted to install with -DGEANT4_BUILD_MULTITHREADED=OFF ,
but I still face the same issue.

Do you have any other ideas about where the problem might be coming from?

Thank you so much for your time and help.

Thank you very much for the suggestion. I will look through it.

Though this is probably a minor bug in our CMake scripts, it caused by over specifying the paths to XercesC. Your installation script can be reduced to:

#!/bin/sh
. /XXX/Geant4/scripts/env_softstack.sh
export VERSION=11.3.0
export CC=gcc
export CXX=g++
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_CXX_STANDARD=17 \
-DGEANT4_USE_GDML=ON \
-DGEANT4_BUILD_MULTITHREADED=ON \
-DGEANT4_BUILD_TLS_MODEL=global-dynamic \
-DGEANT4_USE_SYSTEM_EXPAT=ON \
-DGEANT4_USE_OPENGL=OFF \
-DGEANT4_INSTALL_DATADIR=${SOFTSTACK_HOME}/data/DATA_G4 \
-DCMAKE_PREFIX_PATH=${XERCES_HOME} \
-DCMAKE_INSTALL_PREFIX=${SOFTSTACK_HOME}/install/geant4.${VERSION} \
${SOFTSTACK_HOME}/src/geant4.${VERSION}
make -j 1 
make install