Problem 1356

Summary: G4INCLUDE not set properly when include/Geant4 is populated
Product: Geant4 Reporter: Michael Kelsey <kelsey>
Component: cmakeAssignee: Ben Morgan <Ben.Morgan>
Status: CLOSED MOVED    
Severity: minor    
Priority: P5    
Version: 9.5   
Hardware: All   
OS: All   
Problem Depends on:    
Problem Blocks: 1352    

Description Michael Kelsey 2012-09-19 06:13:02 CEST
When building GEANT4 9.5(.p01) using CMake, the include/Geant4/ directory is populated with all of the toolkit's .hh files, just as it was in previous releases when requested by the user during "./Configure".

However, in geant4make.csh/sh, the G4INCLUDE variable is not set properly to reflect this:

   G4INCLUDE=/Applications/GEANT4/geant4.9.5.p01/no_include

This ought to be set to (in this case) 

   G4INCLUDE=/Applications/GEANT4/geant4.9.5.p01/build/include/Geant4

If the intention is that the include/ directory not be used during user application builds, then the G4INCLUDE variable should not be set at all.  Its existence is taken by binmake.gmk to mean that the directory referenced is correct, and is populated by the .hh files.
Comment 1 Ben Morgan 2012-09-19 13:23:09 CEST
There are two different geant4make.(c)sh scripts, one that's generated where you build Geant4 (so you can use your build of Geant4 without installing it if you wish), and one that's installed when you do "make install" (it is located in the "InstallTreeFiles" directory where you build Geant4, and is not usable until it has been installed). 

The first of these sets G4INCLUDE to ".../no_include" because
binmake.gmk actually checks that G4INCLUDE contains "globals.hh" (line 16 of binmake.gmk). If the file is not there, then it falls back to using all include directories it knows about under G4BASE (#ifndef block at line 43 of binmake.gmk), which is the "source/" directory under the Geant4 source tree. 
At present, we don't copy (or forward) headers into the build tree, so we use this fallback mechanism to obtain the correct paths.

Even if we didn't set G4INCLUDE, architecture.gmk would automatically set it. It's therefore always set in the scripts as this provides a better guarantee of the correct behaviour and gives a cleaner implementation.

We can set G4INCLUDE to ${PROJECT_BINARY_DIR}/include/Geant4, and this will not result in any difference to how binmake.gmk will set up include paths.
Nevertheless, it may be worthwhile to do this to allow for copying/generating/forwarding headers in future. Does that sound reasonable?
Comment 2 Ben Morgan 2012-11-22 16:28:15 CET
Postponing to first patch of 9.6, we'll resolve this more generally so that all build products are output to a hierarchy under the build directory matching the install structure. For example, on UNIX systems, the build directory could contain 
something like

+- my-geant4-build/
   +- Makefile
   +- ... etc ..
   +- build_products/
      +- bin/
      |  +- geant4-config
      +- include/
      |  +- Geant4/
      |     +- G4Config.hh
      |     +- ...
      +- lib/
      |  +- libG4global.so
      |  +- ...
      +- share/

I'm not completely sure what to do with the headers yet. A straight copy or forwarding might be expensive, but would make the -I paths simpler!
Comment 3 Ben Morgan 2013-04-03 20:46:34 CEST
Closing here, moving to DEV project on JIRA.