Problem 1353 - GMake option/preprocessor macro to identify a non-release (developer, test) build?
Summary: GMake option/preprocessor macro to identify a non-release (developer, test) b...
Status: CLOSED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: cmake (show other problems)
Version: 9.5
Hardware: All All
: P5 trivial
Assignee: Ben Morgan
URL:
Depends on:
Blocks:
 
Reported: 2012-09-14 10:29 CEST by Michael Kelsey
Modified: 2013-03-25 17:21 CET (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this problem.
Description Michael Kelsey 2012-09-14 10:29:45 CEST
A use case has arisen in the Hadronics WG to have some blocks of source code suppressed in user release builds (the code should only be compiled for developers).

Could the build type (INSTALL_TYPES) be mapped to a preprocessor macro (e.g., "GEANT4_INSTALL_DEVELOPER") to enable this use case by way of

  #ifdef GEANT4_INSTALL_DEVELOPER
  /* Code for developer use at runtime ONLY */
  #endif

The INSTALL_TYPES string cannot just be put into a macro value, because #if only works with integer values.
Comment 1 Ben Morgan 2012-09-14 11:52:21 CEST
Just for my own notes, the only tricky part is handling the different build modes in multi-config IDEs.
Look at use of COMPILE_DEFINITIONS_<CONFIG> target property:

http://www.cmake.org/cmake/help/v2.8.9/cmake.html#prop_tgt:COMPILE_DEFINITIONS_CONFIG
Comment 2 Ben Morgan 2013-03-25 17:21:28 CET
Fix proposed in tag cmake-V09-06-06.

The compile definition "GEANT4_DEVELOPER_<CONFIG>" is added to the definitions for each Geant4 target as appropriate for the available build types/configurations. For example, if the build type is "Debug", the the sources will be built with the definition "GEANT4_DEVELOPER_DEBUG". This behaviour is the same for all other build modes, and also works with multiconfiguration tools such as Xcode.

The definition should *not* appear in any Geant4 header files.