Warning, /geant4/cmake/Modules/G4InterfaceOptions.cmake is written in an unsupported language. File is not indexed.
0001 # - Configure options for Geant4 UI/Vis requiring Third Party Libraries
0002 # All core Interfaces not requiring third party support are built
0003 # automatically with platform differences taken into account.
0004 # These are:
0005 #
0006 # UI Category : Always built on supported platforms
0007 # G4UIterminal : UNIX, WIN32
0008 # + - G4UItcsh : UNIX only.
0009 # + - G4UIcsh : UNIX, WIN32
0010 # G4UIWin32 : WIN32
0011 #
0012 # UI category : Built on supported platforms when Third Party
0013 # library(libraries) available
0014 # G4UIQt : UNIX, WIN32 (Requires : Qt5)
0015 # G4UIXm : UNIX
0016 #
0017 # Vis Category: Always built on supported platforms
0018 # DAWNFILE : UNIX, Win32
0019 # ...
0020 # gMocren
0021 # HepRep
0022 # RayTracer
0023 # Tree
0024 # VRML
0025 #
0026 # Vis Category : Built on supported platforms when Third Party
0027 # library(libraries) available
0028 # OpenGL : UNIX, WIN32
0029 # OpenInventor : UNIX WIN32
0030 #
0031 # Rather than separate the UI and visualization options, we simply ask if
0032 # the user wants to build support for a particular tool, e.g. Qt.
0033 #
0034 # Specific UI/Vis options are also handled here.
0035 #
0036
0037 #-----------------------------------------------------------------------
0038 # Select options first because these are interdependent
0039 #
0040 # - Coin3D/So{XT,Win,Qt}
0041 option(GEANT4_USE_INVENTOR "Build Geant4 OpenInventor Xt/Win Visualization Driver" OFF)
0042 geant4_add_feature(GEANT4_USE_INVENTOR "Build OpenInventor Xt/Win Driver")
0043
0044 option(GEANT4_USE_INVENTOR_QT "Build Geant4 OpenInventor Qt Visualization Driver" OFF)
0045 geant4_add_feature(GEANT4_USE_INVENTOR_QT "Build OpenInventor Qt Driver")
0046
0047 # GEANT4_USE_INVENTOR is a dual-purpose variable - it marks use of Xt/Win driver for
0048 # user, and marks enablement of G4OpenInventor internally. Check that user-set options
0049 # are consistent before setting *internal* value
0050 if(GEANT4_USE_INVENTOR AND GEANT4_USE_INVENTOR_QT)
0051 message(FATAL_ERROR "Only one of GEANT4_USE_INVENTOR and GEANT4_USE_INVENTOR_QT can be set ON, but both are ON.")
0052 endif()
0053
0054 # User settings o.k., so mark that we're enabling G4OpenInventor
0055 if(GEANT4_USE_INVENTOR_QT)
0056 set(GEANT4_USE_INVENTOR ON)
0057 endif()
0058
0059 # - Qt
0060 # May be required by Coin driver
0061 # Selection also enables ToolsSG driver
0062 option(GEANT4_USE_QT "Build Geant4 with Qt support" OFF)
0063 if(GEANT4_USE_INVENTOR_QT AND NOT GEANT4_USE_QT)
0064 set(GEANT4_USE_QT ON CACHE BOOL "Build Geant4 with Qt support" FORCE)
0065 message(STATUS "Forcing GEANT4_USE_QT to ON, required by selection of GEANT4_USE_INVENTOR_QT as ON")
0066 endif()
0067
0068 # TEMPORARY for 11.2 Beta Development
0069 # Decision still required on whether to allow selection of 5/6 in production
0070 cmake_dependent_option(GEANT4_USE_QT_QT6 "Require Qt6 when building Qt support" OFF "GEANT4_USE_QT" OFF)
0071 mark_as_advanced(GEANT4_USE_QT_QT6)
0072
0073 # - Vtk
0074 option(GEANT4_USE_VTK "Build Geant4 with VTK visualisation" OFF)
0075 if(GEANT4_USE_VTK)
0076 find_package(VTK 9 REQUIRED COMPONENTS
0077 CommonColor
0078 InteractionStyle
0079 IOExport
0080 IOGeometry
0081 IOLegacy
0082 IOPLY
0083 GUISupportQt
0084 RenderingVolumeOpenGL2
0085 )
0086 geant4_save_package_variables(VTK VTK_DIR)
0087 endif()
0088 geant4_add_feature(GEANT4_USE_VTK "Using VTK for visualisation")
0089
0090 # - Unix only
0091 if(UNIX)
0092 # - Motif UI/Vis
0093 # May be required by Coin Vis driver
0094 # Selection also enables ToolsSG driver Xt backend
0095 option(GEANT4_USE_XM "Build Geant4 with Motif (X11) support" OFF)
0096 if((GEANT4_USE_INVENTOR AND NOT GEANT4_USE_INVENTOR_QT)
0097 AND NOT GEANT4_USE_XM)
0098 set(GEANT4_USE_XM ON CACHE BOOL "Build Geant4 with Motif (X11) support" FORCE)
0099 message(STATUS "Forcing GEANT4_USE_XM to ON, required by Inventor driver")
0100 endif()
0101 geant4_add_feature(GEANT4_USE_XM "Build Geant4 with Xm Support")
0102
0103 # - OpenGL/X11 Vis Driver
0104 # Selection also enables ToolsSG driver X11 backend
0105 option(GEANT4_USE_OPENGL_X11 "Build Geant4 OpenGL driver with X11 support" OFF)
0106 geant4_add_feature(GEANT4_USE_OPENGL_X11 "Build Geant4 OpenGL driver with X11 support")
0107
0108 # RayTracer driver with X11 support
0109 option(GEANT4_USE_RAYTRACER_X11 "Build RayTracer driver with X11 support" OFF)
0110 geant4_add_feature(GEANT4_USE_RAYTRACER_X11 "Build RayTracer driver with X11 support")
0111 endif()
0112
0113 # Windows only
0114 if(WIN32)
0115 option(GEANT4_USE_OPENGL_WIN32 "Build OpenGL driver with Win32 support" OFF)
0116 geant4_add_feature(GEANT4_USE_OPENGL_WIN32 "Build OpenGL driver with Win32 support")
0117 endif()
0118
0119 #-----------------------------------------------------------------------
0120 # Find dependencies
0121 #
0122 # Prefer Legacy GL when using CMake >= 3.10
0123 set(OpenGL_GL_PREFERENCE "LEGACY")
0124
0125 # - Coin plus So{Xt,Qt,Win}
0126 if(GEANT4_USE_INVENTOR)
0127 find_package(Coin 4.0.0 REQUIRED)
0128 geant4_save_package_variables(Inventor Coin_DIR)
0129
0130 # Helper to hand-check version because SoXXX use an exact version strategy
0131 # in their CMake config files
0132 function(check_sobind_version _binding _minversion)
0133 if(${_binding}_VERSION VERSION_LESS "${_minversion}")
0134 message(FATAL_ERROR "Found ${_binding}, version: ${${_binding}_VERSION}, but Geant4 requires versions >= ${_minversion}\n"
0135 "${_binding} found at:\n ${${_binding}_DIR}\n")
0136 endif()
0137 endfunction()
0138
0139 if(GEANT4_USE_INVENTOR_QT)
0140 find_package(SoQt REQUIRED)
0141 check_sobind_version(SoQt 1.6.0)
0142 geant4_save_package_variables(Inventor SoQt_DIR)
0143 else()
0144 if(UNIX)
0145 find_package(SoXt REQUIRED)
0146 check_sobind_version(SoXt 1.4.0)
0147 geant4_save_package_variables(Inventor SoXt_DIR)
0148 set(GEANT4_USE_INVENTOR_XT ON)
0149 elseif(WIN32)
0150 find_package(SoWin REQUIRED)
0151 check_sobind_version(SoWin 1.4.0)
0152 geant4_save_package_variables(Inventor SoWin_DIR)
0153 set(GEANT4_USE_INVENTOR_WIN ON)
0154 endif()
0155 endif()
0156 endif()
0157
0158 # - Qt5/6
0159 if(GEANT4_USE_QT)
0160 # Use versioned targets to support Qt5 < 5.15
0161 # 5.9 is selected as the min version to support based on the system version on CentOS7
0162 # Once 5.15 is the minimum version, the "Qt${QT_VERSION_MAJOR}_..." variables can be dropped
0163 # - https://doc.qt.io/qt-6/cmake-manual.html
0164 # TEMPORARY for 11.2 beta:
0165 # - Decision still required on whether to allow selection of 5/6 in production
0166 # TODO:
0167 # - Because VTK and SoQt use Qt themselves, we may want to consider checking that we
0168 # have a consistent link to the same Qt version
0169 if(GEANT4_USE_QT_QT6)
0170 find_package(QT NAMES Qt6 COMPONENTS Core REQUIRED)
0171 else()
0172 find_package(QT 5.9 NAMES Qt5 COMPONENTS Core REQUIRED)
0173 endif()
0174
0175 find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui Widgets OpenGL REQUIRED)
0176
0177 geant4_save_package_variables(Qt${QT_VERSION_MAJOR}
0178 Qt${QT_VERSION_MAJOR}_DIR
0179 Qt${QT_VERSION_MAJOR}Core_DIR
0180 Qt${QT_VERSION_MAJOR}Gui_DIR
0181 Qt${QT_VERSION_MAJOR}Widgets_DIR
0182 Qt${QT_VERSION_MAJOR}OpenGL_DIR)
0183
0184 # G4OpenGL and G4ToolsSG also require OpenGLWidgets in Qt6
0185 if(QT_VERSION_MAJOR GREATER 5)
0186 find_package(Qt${QT_VERSION_MAJOR}OpenGLWidgets REQUIRED)
0187 geant4_save_package_variables(Qt${QT_VERSION_MAJOR} Qt${QT_VERSION_MAJOR}OpenGLWidgets_DIR)
0188 endif()
0189
0190 get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
0191 geant4_add_feature(GEANT4_USE_QT "Build Geant4 with Qt${QT_VERSION_MAJOR} support")
0192
0193 # Qt3D is only supported on 5.15 and above, but always on if available
0194 set(QT3D_MINIMUM_VERSION 5.15.0)
0195 set(GEANT4_USE_QT3D OFF)
0196
0197 if(QT_VERSION VERSION_GREATER_EQUAL QT3D_MINIMUM_VERSION)
0198 find_package(Qt${QT_VERSION_MAJOR}3DCore ${QT_VERSION} EXACT QUIET)
0199 find_package(Qt${QT_VERSION_MAJOR}3DExtras ${QT_VERSION} EXACT QUIET)
0200 find_package(Qt${QT_VERSION_MAJOR}3DRender ${QT_VERSION} EXACT QUIET)
0201
0202 # Forward correct minimum version to CMake/etc files
0203 set(QT3D_MINIMUM_VERSION ${QT_VERSION})
0204
0205 if(Qt${QT_VERSION_MAJOR}3DCore_FOUND AND Qt${QT_VERSION_MAJOR}3DExtras_FOUND AND Qt${QT_VERSION_MAJOR}3DRender_FOUND)
0206 set(GEANT4_USE_QT3D ON)
0207 geant4_save_package_variables(Qt${QT_VERSION_MAJOR}
0208 Qt${QT_VERSION_MAJOR}3DCore_DIR
0209 Qt${QT_VERSION_MAJOR}3DExtras_DIR
0210 Qt${QT_VERSION_MAJOR}3DRender_DIR)
0211 geant4_add_feature(GEANT4_USE_QT3D "Build Geant4 Qt3D driver")
0212 else()
0213 set(_g4_qt3d_missing)
0214 if(NOT Qt${QT_VERSION_MAJOR}3DCore_FOUND)
0215 list(APPEND _g4_qt3d_missing "Qt${QT_VERSION_MAJOR}3DCore")
0216 endif()
0217 if(NOT Qt${QT_VERSION_MAJOR}3DExtras_FOUND)
0218 list(APPEND _g4_qt3d_missing "Qt${QT_VERSION_MAJOR}3DExtras")
0219 endif()
0220 if(NOT Qt${QT_VERSION_MAJOR}3DRender_FOUND)
0221 list(APPEND _g4_qt3d_missing "Qt${QT_VERSION_MAJOR}3DRender")
0222 endif()
0223
0224 message(STATUS "Disabling Geant4 Qt3D driver, missing Qt packages: ${_g4_qt3d_missing}")
0225 endif()
0226 endif()
0227 # Variables for export to GNUmake
0228 execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PREFIX OUTPUT_VARIABLE G4QTHOME OUTPUT_STRIP_TRAILING_WHITESPACE)
0229 execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_LIBS OUTPUT_VARIABLE G4QTLIBPATH OUTPUT_STRIP_TRAILING_WHITESPACE)
0230 endif()
0231
0232 # - OpenGL
0233 if(GEANT4_USE_INVENTOR
0234 OR GEANT4_USE_QT
0235 OR GEANT4_USE_OPENGL_X11
0236 OR GEANT4_USE_XM
0237 OR GEANT4_USE_OPENGL_WIN32)
0238 find_package(OpenGL REQUIRED)
0239 geant4_save_package_variables(OpenGL OPENGL_INCLUDE_DIR OPENGL_gl_LIBRARY)
0240
0241 # X11 drivers on macOS need XQuartzGL
0242 if(APPLE AND
0243 (GEANT4_USE_INVENTOR_XT
0244 OR GEANT4_USE_OPENGL_X11
0245 OR GEANT4_USE_XM))
0246 find_package(XQuartzGL REQUIRED)
0247 geant4_save_package_variables(XQuartzGL XQuartzGL_INCLUDE_DIR XQuartzGL_gl_LIBRARY)
0248 endif()
0249
0250 # Enable G4OpenGL driver
0251 if(GEANT4_USE_INVENTOR
0252 OR GEANT4_USE_QT
0253 OR GEANT4_USE_OPENGL_X11
0254 OR GEANT4_USE_OPENGL_WIN32)
0255 set(GEANT4_USE_OPENGL ON)
0256 endif()
0257 endif()
0258
0259 if(UNIX)
0260 # - X11
0261 if(GEANT4_USE_OPENGL_X11
0262 OR GEANT4_USE_RAYTRACER_X11
0263 OR GEANT4_USE_XM
0264 OR GEANT4_USE_INVENTOR_XT)
0265 find_package(X11 REQUIRED)
0266 include("${CMAKE_CURRENT_LIST_DIR}/G4X11Shim.cmake")
0267
0268 # Check for additional required X11 libraries
0269 if(NOT X11_Xmu_FOUND)
0270 message(FATAL_ERROR "could not find X11 Xmu library and/or headers")
0271 endif()
0272
0273 if(NOT X11_Xt_FOUND)
0274 message(FATAL_ERROR "could not find X11 Xt library and/or headers")
0275 endif()
0276
0277 geant4_save_package_variables(X11
0278 X11_X11_INCLUDE_PATH
0279 X11_X11_LIB
0280 X11_ICE_INCLUDE_PATH
0281 X11_ICE_LIB
0282 X11_SM_INCLUDE_PATH
0283 X11_SM_LIB
0284 X11_Xext_INCLUDE_PATH
0285 X11_Xext_LIB
0286 X11_Xmu_INCLUDE_PATH
0287 X11_Xmu_LIB
0288 X11_Xt_INCLUDE_PATH
0289 X11_Xt_LIB)
0290 endif()
0291
0292 # - Motif
0293 if(GEANT4_USE_XM)
0294 find_package(Motif REQUIRED)
0295 include("${CMAKE_CURRENT_LIST_DIR}/G4MotifShim.cmake")
0296 geant4_save_package_variables(Motif MOTIF_INCLUDE_DIR MOTIF_LIBRARIES)
0297 endif()
0298 endif()