`NOT Found Geant4.` on building G4Py

I’ve installed Geant4, sourced the geant4make.sh and geant4.sh files, but when trying to compile g4py it says that Geant4 is not found. I’m running it on Windows WSL linux interpreter. I’ve tried passing the path to the Geant4/geant4-install/include and lib folders prior to find_package, but it keeps saying that Geant4 is not found. I was trying to call cmake by passing the geant4-source directory, but learned that is not the correct path to give.

Which version of Geant4 is this? Since 10.6.3, Geant4Py can be built as part of Geant4 itself. In earlier versions, it should be sufficient to build it as any other CMake-based project, so the path to Geant4 can be passed either as:

$ cmake -DCMAKE_PREFIX_PATH=/path/to/install/of/geant4 <args>

or

$ cmake -DGeant4_DIR=/path/to/directory_holding_Geant4Config/ <args>

If these don’t work, please post any output you’re getting, and also the version of Geant4/CMake being used.

Running CMake version 3.16.3, I’ve installed Geant4.10.7 into /Geant4.10.7/geant4-install/ on a single thread, and then when I try to compile geant4py by

cmake -DCMAKE_PREFIX_PATH=/home/glicka/Geant4.10.7/geant4-install/ ..

I get the following output:

CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command.  Add a line of
code such as 
project(ProjectName) 
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers.  Use -Wno-dev to suppress it.
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0  
-- Check for working C compiler: /usr/bin/cc 
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++  
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PythonInterp: /home/glicka/anaconda3/bin/python3 (found suitable version "3.8.8", minimum required is "3.0")
-- Found PythonLibs: /home/glicka/anaconda3/lib/libpython3.8.so (found version "3.8.8")
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found suitable version "1.71.0", minimum required is "1.65") found components: python
CMake Error at G4PythonHelpers.cmake:16 (file):
file RELATIVE_PATH must be passed a full path to the file:
Call Stack (most recent call first):
CMakeLists.txt:14 (include)
CMake Error at CMakeLists.txt:23 (geant4_add_feature):
Unknown CMake command "geant4_add_feature".
CMake Warning (dev) in CMakeLists.txt:

No cmake_minimum_required command is present.  A line of code such as
cmake_minimum_required(VERSION 3.16
should be added at the top of the file.  The version specified may be lower
if you wish to support older CMake versions for this project.  For more
information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it. 
-- Configuring incomplete, errors occurred!
See also "/home/glicka/Geant4.10.7/geant4-source/geant4/environments/g4py38/build/CMakeFiles/CMakeOutput.log".

As this is Geant4 10.7, Geant4Py is now built as part of Geant4 itself. To build it, build and install Geant4 itself with:

$ cmake -DGEANT4_USE_PYTHON=ON [-DGEANT_BUILD_MULTITHREADED=ON -DGEANT4_TLS_MODEL=global-dynamic] <args>

The -DGEANT_BUILD_MULTITHREADED=ON -DGEANT4_TLS_MODEL=global-dynamic options are required if you want to build Geant4 in multithreaded mode.

If you have an existing build directory for Geant4, change back to that and run the above before rebuilding/installing, otherwise a from scratch rebuild/install will be needed.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.