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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /cmake/Templates/UseGeant4.cmake (Version 11.3.0) and /cmake/Templates/UseGeant4.cmake (Version 9.6.p2)


  1 # - Use file for Geant4                             1 # - Use file for Geant4
  2 # Add Module directory so that examples can us <<   2 # This file should be included after a find_package call has successfully
  3 # modules. Appended to minimize any conflict w <<   3 # located Geant4. If Geant4 has been located via the Geant4Config.cmake
  4 # settings                                     <<   4 # config file, this will have set the following variable:
  5 # DEPRECATED: Only needed by certain examples  <<   5 #
  6 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_ <<   6 #  Geant4_USE_FILE : Point to the location of the use file for the found
                                                   >>   7 #                    Geant4 installation.
                                                   >>   8 #
                                                   >>   9 # Inclusion of this file, e.g. via
                                                   >>  10 # 
                                                   >>  11 #  include(${Geant4_USE_FILE})
                                                   >>  12 #
                                                   >>  13 # results in the addition of the Geant4 compile definitions and 
                                                   >>  14 # include directories to those of the directory in which this file is 
                                                   >>  15 # included.
                                                   >>  16 #
                                                   >>  17 # The recommended Geant4 compiler flags are also added to CMAKE_CXX_FLAGS
                                                   >>  18 # but duplicated flags are NOT removed.
                                                   >>  19 # Advanced users requiring special sets of flags, or the removal of 
                                                   >>  20 # duplicate flags should therefore *not* use this file, preferring the 
                                                   >>  21 # direct use of the Geant4_XXXX variables set by the Geant4Config file.
                                                   >>  22 #
                                                   >>  23 # The use file also defines a simple macro to help with collating sources
                                                   >>  24 # for simple user applications.
                                                   >>  25 #
                                                   >>  26 #  macro GEANT4_COLLATE_APPLICATION_SOURCES(sources)
                                                   >>  27 #        Create the list of sources in a standard Geant4 application 
                                                   >>  28 #        example.
                                                   >>  29 #        If the project is organized as
                                                   >>  30 #        +- project
                                                   >>  31 #           +- CMakeLists.txt
                                                   >>  32 #           +- project.cc
                                                   >>  33 #           +- include/
                                                   >>  34 #           |  +- project_impl_a.hh
                                                   >>  35 #           |  +- ...
                                                   >>  36 #           +- src/
                                                   >>  37 #              +- project_impl_a.cc
                                                   >>  38 #              +- ...
                                                   >>  39 #        Then when called in the CMakeLists.txt under 'project', it will
                                                   >>  40 #        collate all the .hh and .cc files into the sources variable, and
                                                   >>  41 #        add the include directory to those to be searched for.
                                                   >>  42 #        The CMakeLists.txt for project would then read:
                                                   >>  43 #       
                                                   >>  44 #        cmake_minimum_required(VERSION 2.6.4)
                                                   >>  45 #        project(myproject)
                                                   >>  46 #
                                                   >>  47 #        find_package(Geant4 REQUIRED)
                                                   >>  48 #        include(${Geant4_USE_FILE})
                                                   >>  49 #
                                                   >>  50 #        GEANT4_COLLATE_APPLICATION_SOURCES(my_project_sources)
                                                   >>  51 #
                                                   >>  52 #        add_executable(myproject ${my_project_sources})
                                                   >>  53 #        target_link_libraries(myproject ${Geant4_LIBRARIES})
                                                   >>  54 #
                                                   >>  55 #
                                                   >>  56 #        This gives you maximum flexibility in setting up your project, as
                                                   >>  57 #        you can either use this macro for simplicity and to easily convert
                                                   >>  58 #        an existing application to CMake, or you can set the sources manually
                                                   >>  59 #        with your own arrangement of headers and source files.
                                                   >>  60 #
                                                   >>  61 #
                                                   >>  62 # The last thing the module does is to optionally include an internal Use 
                                                   >>  63 # file. This file can contain variables, functions and macros for strict
                                                   >>  64 # internal use in Geant4, such as building and running validation tests.
                                                   >>  65 #
                                                   >>  66 
                                                   >>  67 #-----------------------------------------------------------------------
                                                   >>  68 # macro GEANT4_COLLATE_SOURCES(source_dest_var)
                                                   >>  69 #
                                                   >>  70 macro(GEANT4_COLLATE_APPLICATION_SOURCES source_dest_var)
                                                   >>  71   message(" WARNING: macro geant4_collate_application sources is deprecated and will be removed in GEANT4 version 10.0.")
                                                   >>  72   file(GLOB_RECURSE 
                                                   >>  73     ${source_dest_var} 
                                                   >>  74     ${CMAKE_CURRENT_SOURCE_DIR}/*.hh 
                                                   >>  75     ${CMAKE_CURRENT_SOURCE_DIR}/*.cc
                                                   >>  76     )
                                                   >>  77   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
                                                   >>  78 endmacro()
                                                   >>  79 
                                                   >>  80 #-----------------------------------------------------------------------
                                                   >>  81 # We need to set the compile definitions and include directories
                                                   >>  82 #
                                                   >>  83 add_definitions(${Geant4_DEFINITIONS})
                                                   >>  84 include_directories(${Geant4_INCLUDE_DIRS})
                                                   >>  85 
                                                   >>  86 #-----------------------------------------------------------------------
                                                   >>  87 # Because Geant4 is sensitive to the compiler flags, lets set the base set
                                                   >>  88 # here. This reproduces as far as possible the behaviour of the original
                                                   >>  89 # makefile system.
                                                   >>  90 #
                                                   >>  91 set(CMAKE_CXX_FLAGS                "${Geant4_CXX_FLAGS}")
                                                   >>  92 set(CMAKE_CXX_FLAGS_DEBUG          "${Geant4_CXX_FLAGS_DEBUG}")
                                                   >>  93 set(CMAKE_CXX_FLAGS_MINSIZEREL     "${Geant4_CXX_FLAGS_MINSIZEREL}")
                                                   >>  94 set(CMAKE_CXX_FLAGS_RELEASE        "${Geant4_CXX_FLAGS_RELEASE}")
                                                   >>  95 set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${Geant4_CXX_FLAGS_RELWITHDEBINFO}")
                                                   >>  96 set(CMAKE_EXE_LINKER_FLAGS         "${Geant4_EXE_LINKER_FLAGS}")
                                                   >>  97 
                                                   >>  98 
                                                   >>  99 
                                                   >> 100 #-----------------------------------------------------------------------
                                                   >> 101 # Locate ourselves
                                                   >> 102 #
                                                   >> 103 get_filename_component(_use_geant4_dir ${CMAKE_CURRENT_LIST_FILE} PATH)
                                                   >> 104 
                                                   >> 105 #-----------------------------------------------------------------------
                                                   >> 106 # Append the local module path to CMAKE_MODULE_PATH to automatically
                                                   >> 107 # make FindXXX modules for examples available
                                                   >> 108 #
                                                   >> 109 list(APPEND CMAKE_MODULE_PATH ${_use_geant4_dir}/Modules)
                                                   >> 110 
                                                   >> 111 #-----------------------------------------------------------------------
                                                   >> 112 # Include internal use file if it exists. It should only exist in the
                                                   >> 113 # build tree!
                                                   >> 114 #
                                                   >> 115 include(${_use_geant4_dir}/UseGeant4_internal.cmake OPTIONAL)
                                                   >> 116