当前位置:首页 > 服务端 > geant4 cmake options

geant4 cmake options

Geant4 Build Options

Both On Unix Platforms and On Windows Platforms give the minimal procedure to build and install Geant4 on these platforms. Many additional options can be passed to CMake to adjust the way Geant4 is built and installed and to enable optional components.

Options are divided into Standard Options, which any user or developer can set directly, and Advanced Options, which in general are only needed by advanced users, developers or to give very fine control over the build and install. Some options enable components of Geant4 which require external software (as listed in Geant4 System/Software Prerequisites). If these options are enabled, the required software will be searched for, and hence there are also options which control where CMake should look for these packages. If a required software package is not found, then CMake will exit with an error message detailing what was not found.

These options may be set by passing their name and value to the cmake command via -D flags. For example:

$ cmake -DCMAKE_INSTALL_PREFIX=/opt/geant4 -DGEANT4_USE_GDML=ON /path/to/geant4-source

would configure the build of Geant4 for installation under /opt/geant4 and compilation of support for GDML.

If you have already created a build directory and used CMake to configure the build, you can always rerun CMake in that directory with new options to regenerate the buildscripts (Makefiles or IDE solutions). You can also deactivate a previously selected option to remove a component from the build. For example, if we had configured a build to enable GDML support and wanted to remove it, we could run:

$ cmake -DGEANT4_USE_GDML=OFF .

Note that this assumes we are running cmake in a previously configured build directory so we only need pass the current working directory rather than the full source directory path.

If you reconfigure to unset an option and rebuild and reinstall, your install may contain files installed by the previously set option (for example headers). In this case, you should build the uninstall target before reconfiguring to guarantee removal of these files.

CMake also provides Curses (UNIX only) and Qt (UNIX and Windows) based Terminal/GUI interfaces which may be used to browse and set options. Please see the CMake documentation for more information on these interfaces.
Standard Options

We list standard options here in logical order. If you use CMake’s curses or GUI interfaces, they will be listed alphabetically. Where third-party software requirements are listed, please consult Geant4 System/Software Prerequisites for links and information on these packages.

CMAKE_INSTALL_PREFIX

    Sets the installation prefix for Geant4. Equivalent to --prefix in Autotools. The default is platform dependent:

    Unix: /usr/local

    Windows: C:\Program Files\Geant4

    It should be supplied as an absolute path, otherwise CMake will interpret its value relative to your build directory.

    See also the CMAKE_INSTALL_XXXDIR Advanced Options for fine control of installation locations.

CMAKE_BUILD_TYPE : (DEFAULT : Release)

    Sets the type of build. It defaults to Release which gives a fully optimised build without debugging symbols. The most useful values are:

    Release : Optimised build, no debugging symbols

    Debug : Debugging symbols, no optimisation

    RelWithDebInfo : Optimised build with debugging symbols

    See Options for Changing the Compiler and Build Flags for the compiler flags used in each mode.

    Note that if you use a build system which supports multiconfiguration builds (e.g. Xcode and Visual Studio), this variable has no effect. For these systems, all build types are available inside the CMake generated project and can be selected in the tool itself or via the --config argument to cmake --build, e.g. cmake --build . --config Debug.

GEANT4_BUILD_MULTITHREADED : (DEFAULT : OFF)

    If set to ON, build Geant4 libraries with support for multithreading. At present, this is only supported on Unix systems.

    Requires: Compiler/C++ Standard Library with support for C++ Threading Support

GEANT4_INSTALL_DATA : (DEFAULT : OFF)

    If set to ON, download and install any Geant4 datasets missing from GEANT4_INSTALL_DATADIR. Each dataset will be unpacked and installed in the directory pointed to by GEANT4_INSTALL_DATADIR.

    Requires: A working network connection. It is highly recommended to switch this option on if you have a network connection to give the best integration with application development.

GEANT4_INSTALL_DATADIR : (DEFAULT : CMAKE_INSTALL_DATAROOTDIR)

    Installation directory for Geant4 datasets. It can be supplied as a path relative to CMAKE_INSTALL_PREFIX or as an absolute path. It is always searched for existing datasets, which if present will be reused.

GEANT4_USE_G3TOG4 : (DEFAULT : OFF)

    If set to ON, build the G3ToG4 library for reading ASCII call list files generated from Geant3 geometries.

GEANT4_USE_GDML : (DEFAULT : OFF)

    If set to ON, build the G4persistency library with support for GDML.

    Requires: Xerces-C++ libraries and headers. See the CMAKE_PREFIX_PATH Advanced Options or the CMake FindXercesC documentation if CMake has trouble locating Xerces-C

GEANT4_USE_INVENTOR (DEFAULT : OFF)

    If set to ON, build the X11/Win32 OpenInventor visualization driver.

    Requires: Coin3D Open Inventor implementation, SoXt (Unix) or SoWin (Windows) binding, and OpenGL libraries and headers.

    See the CMAKE_PREFIX_PATH Advanced Options if CMake has trouble locating Coin3D or SoXt/SoWin.

    Known Issue: Use of clang compiler and Debug build mode will cause the Inventor driver build to fail with errors relating to Inventor specific debugging functions.

GEANT4_USE_INVENTOR_QT (DEFAULT : OFF)

    If set to ON, build the OpenInventorQt visualization driver.

    Note that enabling this option will disable build of the X11/Win OpenInventor driver as only one binding can be present.

    Requires: Coin3D Open Inventor implementation plus SoQt binding and Qt5 libraries and headers.

    See the CMAKE_PREFIX_PATH Advanced Options if CMake has trouble locating Coin3D or SoQt.

GEANT4_USE_OPENGL_WIN32 (DEFAULT : OFF, Windows Only)

    If set to ON, build the Win32 OpenGL visualization driver.

    Requires: OpenGL libraries and headers.

GEANT4_USE_OPENGL_X11 (DEFAULT : OFF, Unix Only)

    If set to ON, build the X11 OpenGL visualization driver.

    Requires: X11 and OpenGL libraries and headers.

GEANT4_USE_PYTHON (DEFAULT : OFF)

    If set to ON, build the Geant4Py Python binds to Geant4.

    Requires: Python 3 and Boost Python libraries and headers. If GEANT4_BUILD_MULTITHREADED is ON, then GEANT4_BUILD_TLS_MODEL must be set to global-dynamic to allow runtime loading of the modules.

    See the CMAKE_PREFIX_PATH Advanced Options or the CMake documentation for FindBoost , FindPythonInterp , and FindPythonLibs if CMake has trouble locating Boost or Python3.

GEANT4_USE_QT (DEFAULT : OFF)

    If set to ON, build Qt5 User Interface and Visualization drivers.

    Requires: Qt5 and OpenGL libraries and headers.

    See the CMAKE_PREFIX_PATH variable under Advanced Options if CMake has trouble locating Qt.

GEANT4_USE_RAYTRACER_X11 (DEFAULT : OFF, Unix only)

    If set to ON, build RayTracer visualization driver with X11 support.

    Requires: X11 libraries and headers.

GEANT4_USE_SYSTEM_CLHEP (DEFAULT : OFF)

    If set to ON, build Geant4 with an external install of CLHEP. You should not set this unless your usage of Geant4 mandates a specific external CLHEP installation (e.g. if your project’s software uses CLHEP in other tools and requires consistent use of the same CLHEP across the software stack).

    Requires: CLHEP libraries and headers. See the CMAKE_PREFIX_PATH Advanced Options if CMake has trouble locating CLHEP.

GEANT4_USE_SYSTEM_EXPAT (DEFAULT : ON)

    If set to ON, build Geant4 with an external install of Expat. Whilst Expat is installed on the vast majority of systems, it may be missing in certain instances. In these cases, simply switch this option to OFF and Geant4 will build and use its internal version of Expat.

    Requires: Expat library and headers. See the CMAKE_PREFIX_PATH Advanced Options or the CMake documentation for FindEXPAT if CMake has trouble locating Expat.

GEANT4_USE_SYSTEM_ZLIB (DEFAULT : OFF)

    If set to ON, build Geant4 with an external install of zlib.

    Requires: Zlib library and headers. See the CMAKE_PREFIX_PATH Advanced Options or the CMake documentation for FindEXPAT if CMake has trouble locating ZLIB.

GEANT4_USE_TBB (DEFAULT : ON)

    If set to ON, use Intel TBB as the Tasking backend for PTL.

    Requires: Intel TBB libraries and headers. See the CMAKE_PREFIX_PATH Advanced Options if CMake has trouble locating TBB

GEANT4_USE_XM (DEFAULT : OFF, Unix Only)

    If set to ON, build Motif User Interface and Visualization drivers.

    Requires: Motif and OpenGL libraries and headers. See the CMAKE_PREFIX_PATH Advanced Options or the CMake documentation for FindMotif if CMake has trouble locating Motif.

Advanced Options

Most installs should never need to touch these options, and are primarily to give advanced users more control over the build, enable experimental features, and to help CMake locate needed software packages. Advanced options and variables can be set like the standard ones listed earlier using -D arguments to cmake. In CMake’s curses and GUI interfaces these options can be displayed by pressing t in ccmake, or clicking the ‘advanced’ check box in the CMake GUI.

In the list below, we only list those options most relevant for Geant4. Many additional core CMake variables are available, for which you should consult the Reference Documentation section of the main CMake documentation , and specifically the sections on Variables. The following list is presented in semi-alphabetical order, with grouping by task where appropriate.

BUILD_SHARED_LIBS : (DEFAULT : ON)

    If set to ON build Geant4 shared libraries.

BUILD_STATIC_LIBS : (DEFAULT : OFF)

    If set to ON, build Geant4 static libraries.

CMAKE_INSTALL_BINDIR : (DEFAULT : bin)

    Installation directory for Geant4 Toolkit executables. It can be supplied as a path relative to CMAKE_INSTALL_PREFIX or as an absolute path.

CMAKE_INSTALL_INCLUDEDIR : (DEFAULT : include)

    Installation directory for Geant4 C/C++ headers. It can be supplied as a path relative to CMAKE_INSTALL_PREFIX or as an absolute path. The headers will always be installed in a subdirectory of CMAKE_INSTALL_INCLUDEDIR named Geant4.

CMAKE_INSTALL_LIBDIR : (DEFAULT : lib(+?SUFFIX))

    Installation directory for object code libraries. It can be supplied as a path relative to CMAKE_INSTALL_PREFIX, or an absolute path. When the default is used, SUFFIX will be set to 64 on 64bit Linux platforms apart from Debian systems.

CMAKE_INSTALL_PYTHONDIR : (DEFAULT : CMAKE_INSTALL_LIBDIR/python3.<PYMINOR>/site-packages)

    Installation directory for the Geant4 python package/bindings. It can be supplied as a path relative to CMAKE_INSTALL_PREFIX, or an absolute path.

CMAKE_INSTALL_DATAROOTDIR : (DEFAULT : share)

    Installation directory for read-only architecture-independent data files. It can be supplied as a path relative to CMAKE_INSTALL_PREFIX, or an absolute path.

GEANT4_INSTALL_DATA_TIMEOUT : (DEFAULT : 1500)

    Sets the time in seconds allowed for download of each Geant4 dataset. The value can be increased if you are on a slow network connection and require more time to download.

GEANT4_INSTALL_EXAMPLES : (DEFAULT : ON)

    Set to OFF to prevent installation of the source code and documentation for the Geant4 examples.

GEANT4_BUILD_CXXSTD : (DEFAULT : 11 (UNIX), 17 (Windows))

    Compile Geant4 against given C++ standard ( 11, 14, or 17). Geant4 is written in C++11, and you should use this option if your application requires support for the newer standard. If you set the variable to a standard the compiler does not support, an error will be emitted.

    Requires: C++ Compiler with support for the requested standard.

GEANT4_BUILD_MSVC_MP : (Windows Only, DEFAULT : OFF)

    If set to ON, add /MP to CMAKE_CXX_FLAGS to enable file level parallel compilation when using MSVC and MSBuild. Note that this only works when building Geant4 using Visual Studio Solutions.

GEANT4_BUILD_TLS_MODEL : (DEFAULT : initial-exec)

    If building Geant4 with multithreading support, use a specific model for Thread Local Storage ( initial-exec, local-exec, global-dynamic, local-dynamic or auto). If you set the variable to a model unknown to the compiler, an error will be emitted.

    Geant4’s default model of initial-exec is chosen to give the best performance under a wide variety of use cases.

    The special auto value leaves the choice of TLS model to the compiler.

    Requires: GEANT4_BUILD_MULTITHREADED set to ON

GEANT4_BUILD_STORE_TRAJECTORY : (DEFAULT : ON)

    If set to ON, store trajectories in event processing. It can be switched to OFF to give a degree of performance improvement, but you will not be able to visualise events.

GEANT4_BUILD_VERBOSE_CODE : (DEFAULT : ON)

    If set to ON, build Geant4 libraries with extra verbosity. It can be switched to OFF to give a degree of performance improvement, but you will not have as much information output should you run into problems or need to debug.

GEANT4_BUILD_BUILTIN_BACKTRACE : (DEFAULT : OFF)

    If set to ON, build Geant4 Run Manager with signal handling using G4Backtrace. This provides simple backtrace reporting, but should not be set to ON if you application implements/requires its own signal handling.

GEANT4_BUILD_PHP_AS_HP : (DEFAULT : OFF)

    If set to ON, build the ParticleHP model as HP.

GEANT4_USE_SMARTSTACK : (DEFAULT : OFF)

    If set to ON, use G4SmartStack in G4TrackingManager.

GEANT4_USE_SYSTEM_PTL (DEFAULT : OFF)

    If set to ON, build Geant4 with an external install of PTL.

    Requires: PTL library and headers. See the CMAKE_PREFIX_PATH Advanced Options if CMake has trouble locating PTL.

GEANT4_ENABLE_TESTING : (DEFAULT : OFF)

    If set to ON, build and run Geant4 testing suites.

    WARNING: this option is for Geant4 system testing only and is not intended for use by users. No support is, or will be, provided for user builds with this option.

GEANT4_USE_NETWORKDAWN : (DEFAULT : OFF, Unix Only)

    If set to ON, build network server/client support for DAWN visualization driver. You do not need this to view DAWN files.

GEANT4_USE_NETWORKVRML : (DEFAULT : OFF, Unix Only)

    If set to ON, build network server/client support for VRML visualization driver. You do not need this to view VRML files.

GEANT4_USE_FREETYPE : (DEFAULT : OFF)

    If set to ON, build Geant4 Analysis library with support for Freetype font rendering.

    Requires: Freetype libraries and headers.

GEANT4_USE_HDF5 : (DEFAULT : OFF)

    If set to ON, build Geant4 Analysis library with support for HDF5 persistency.

    WARNING: use of HDF5 is experimental and should be used with caution.

    Requires: HDF5 C libraries and headers, compiled in threadsafe mode if Geant4 is built with multithreading support.

GEANT4_USE_USOLIDS : (DEFAULT : OFF)

    If set to ON, replace Geant4 solids with VecGeom equivalents.

    WARNING: the use of VecGeom is experimental and should be used with caution.

    Requires: VecGeom libraries and headers.

GEANT4_USE_TIMEMORY : (DEFAULT : OFF)

    If set to ON, build Geant4 with support for memory/CPU profiling with TiMemory.

    Requires: TiMemory library and headers.

GEANT4_INSTALL_PACKAGE_CACHE : (DEFAULT : ON)

    If set to ON, install a file containing the locations of external dependencies as used when building this install of Geant4.

    Geant4 10.6 and newer use CMake Imported Targets to link to external dependencies such as CLHEP, avoiding direct hard-coding of paths into the Geant4 install. The package cache file is installed by default to retain the pre-10.6 behaviour for basic installs, and stores these paths for reuse.

    If you are packaging (e.g. rpm, deb, spack, Homebrew, etc) Geant4, you can set this option to OFF to disable install of the cache file and make the package relocatable. Your install of Geant4 will then rely on CMAKE_PREFIX_PATH and other variables used by CMake to re-find any needed dependencies. Alternately, if your packaging system allows install-time patching, you may patch the cache file at that time with known paths to the dependencies at that point. In both cases, it is your responsibility to setup/patch the environment/cache file correctly and as appropriate.

    WARNING: This option is only intended for the packaging case outlined above, and is not recommended for single-user installs of Geant4.*

GEANT4_INSTALL_DATASETS_TENDL : (DEFAULT :OFF)

    If set to ON, enable download and install of the optional TENDL dataset for use with the

CMAKE_PREFIX_PATH

    If you have software packages required by Geant4 installed in custom locations, this variable can be set to list these prefixes to help CMake locate the packages. For example, if Xerces-C is needed and installed in /custom/xerces-c, then CMAKE_PREFIX_PATH could be set on the command line as:

    cmake -DCMAKE_PREFIX_PATH="/custom/xerces-c" <otherargs>

Additional paths may be added, separated by semicolons, e.g.:

cmake -DCMAKE_PREFIX_PATH="/A;/B;/C"

    CMAKE_PREFIX_PATH may also be set in the environment with paths separated by the appropriate element separator for the platform (“:” on UNIX, “;” on Windows).

GEANT4_USE_SYSTEM_CLHEP_GRANULAR (DEFAULT : OFF)

    If set to ON, configure Geant4 to search for and use the Evaluator, Geometry, Random and Vector component libraries of CLHEP rather than the single CLHEP library.

    WARNING: This option should only be used if your project is locked into using the CLHEP granular libraries by other requirements. Use of the single CLHEP library is no different and simplifies the configuration and use of Geant4.

Options for Changing the Compiler and Build Flags

CMake will, by default, select the first C and C++ compilers it finds in your PATH. To specify the C and C++ compilers to be used, you can set the CC and CXX variables:

$ # ... assuming clang/clang++ are in the PATH ...

$ CC=clang CXX=clang++ cmake

$ # ... or ...

$ export CC=clang
$ export CXX=clang++
$ cmake

You can also use a full path should the compilers not be in the PATH or via the CMAKE_ _COMPILER options:

cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++

Use of CMAKE_ _COMPILER will take precedence over any setting of CC or CXX in the environment or on the command line.

Whilst you can change the compiler after an initial configuration with CMake, it is not recommended as you may need to reset some variables by hand. If you are building Geant4 using several compilers and/or versions, we strongly recommend creating one build directory per compiler system. Whilst this takes extra disk space, it provides a clean separation between different builds and also allows fast incremental builds against a single source directory.

Geant4’s CMake scripts configure a set of flags for use with each supported compiler as follows. CMAKE_CXX_FLAGS are always applied, with the CMAKE_CXX_FLAGS_ being appended when building in the given (e.g. “Release”). If you are using an unsupported or unrecognised compiler, CMake will default to a standard and very simple set of flags.

GNU Compiler Collection

    CMAKE_CXX_FLAGS : -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe

    CMAKE_CXX_FLAGS_RELEASE : -O3 -DNDEBUG -fno-trapping-math -ftree-vectorize -fno-math-errno

    CMAKE_CXX_FLAGS_DEBUG : -g

    CMAKE_CXX_FLAGS_RELWITHDEBINFO : -O2 -g

Clang

    CMAKE_CXX_FLAGS : -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -Qunused-arguments

    CMAKE_CXX_FLAGS_RELEASE : -O3 -DNDEBUG -fno-trapping-math -ftree-vectorize -fno-math-errno

    CMAKE_CXX_FLAGS_DEBUG : -g

    CMAKE_CXX_FLAGS_RELWITHDEBINFO : -O2 -g

Microsoft Visual C++

    CMAKE_CXX_FLAGS : -GR -EHsc -Zm200 -nologo -D_CONSOLE -D_WIN32 -DWIN32 -DOS -DXPNET -D_CRT_SECURE_NO_DEPRECATE

    CMAKE_CXX_FLAGS_RELEASE : -MD -Ox -DNDEBUG

    CMAKE_CXX_FLAGS_DEBUG : -MDd -Od -Zi

    CMAKE_CXX_FLAGS_RELWITHDEBINFO : -MD -O2 -Zi

Intel

    CMAKE_CXX_FLAGS : -w1 -Wno-non-virtual-dtor -Wpointer-arith -Wwrite-strings -fp-model precise

    CMAKE_CXX_FLAGS_RELEASE : -O3 -DNDEBUG

    CMAKE_CXX_FLAGS_DEBUG : -g

    CMAKE_CXX_FLAGS_RELWITHDEBINFO : -O2 -g

For the GNU, Clang and Intel compilers, an additional flag selecting the C++ standard to compile against will be set. By default, this will use the C++11 standard. This can be changed if the compiler version supports it by setting the GEANT4_BUILD_CXXSTD to the required standard, as described in Advanced Options.

When Geant4 is built with support for multithreading (GEANT4_BUILD_MULTITHREADED set to ON), the following additional flags are added to all build types for the GNU, Clang and Intel compilers:

-ftls-model=initial-exec -pthread

Note that the model passed to the -ftls-model argument can be changed using the GEANT4_BUILD_TLS_MODEL option described in Advanced Options. The additional auto option to GEANT4_BUILD_TLS_MODEL does not set additional flags, leaving the selection of TLS model to the compiler.

Whilst we strongly recommend the default set of flags as described above, they may be modified. CMake is aware of the CFLAGS and CXXFLAGS variables, so these may be set on the command line or as environment variables like the CC and CXX options above. However, note that these will only prepend extra flags to the default CMAKE_ FLAGS. If you need to completely change the compiler flags, then you can set CMAKE _FLAGS directly as a -D option to CMake. This will override all defaults set by Geant4’s CMake scripts. Compiler flags can be interactively modified through the ccmake and CMake GUI interfaces. As compiler flags are an advanced option, you will need to activate viewing of advanced options. You may then edit the flags as you wish.

作者:jianghp
来源链接:https://www.cnblogs.com/jianghp/p/14892929.html

版权声明:
1、Java侠(https://www.javaxia.com)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaxia.com/server/124837.html

标签: No compiler
分享给朋友: