CMAKE error with example

Hi, I’m Lan, a begineer of Geant4.
I have build and installed Geant4 4-10_06 on Windows10 system with VS2019 and CMAKE. I also added QT when I build G4project with CMAKE. But when I was trying to make an example, CMAKE gave some error informarions like


Then I checked “Geant4PackageCache.cmake”, the code is

macro(geant4_set_and_check_package_variable _name _value _type _docstring)
  if(DEFINED ${_name})
    if(NOT ("${${_name}}" STREQUAL "${_value}"))
      message(WARNING "Value of '${_name}' is already set and does not match value set at Geant4 build-time")
    endif()
  else()
    set(${_name} ${_value} CACHE ${_type} "${_docstring}")
  endif()
endmacro()


# Qt5 Build Time Settings
geant4_set_and_check_package_variable(Qt5Core_DIR "D:/QT/5.7/msvc2015_64/lib/cmake/Qt5Core" PATH "The directory containing a CMake configuration file for Qt5Core.")
geant4_set_and_check_package_variable(Qt5Gui_DIR "D:/QT/5.7/msvc2015_64/lib/cmake/Qt5Gui" PATH "The directory containing a CMake configuration file for Qt5Gui.")
geant4_set_and_check_package_variable(Qt5Widgets_DIR "D:/QT/5.7/msvc2015_64/lib/cmake/Qt5Widgets" PATH "The directory containing a CMake configuration file for Qt5Widgets.")
geant4_set_and_check_package_variable(Qt5OpenGL_DIR "D:/QT/5.7/msvc2015_64/lib/cmake/Qt5OpenGL" PATH "The directory containing a CMake configuration file for Qt5OpenGL.")
geant4_set_and_check_package_variable(Qt5PrintSupport_DIR "D:/QT/5.7/msvc2015_64/lib/cmake/Qt5PrintSupport" PATH "The directory containing a CMake configuration file for Qt5PrintSupport.")

# OpenGL Build Time Settings
geant4_set_and_check_package_variable(OPENGL_INCLUDE_DIR ""  "")
geant4_set_and_check_package_variable(OPENGL_gl_LIBRARY "opengl32" STRING "OpenGL library for win32")
geant4_set_and_check_package_variable(OPENGL_glu_LIBRARY "glu32" STRING "GLU library for win32")
geant4_set_and_check_package_variable(OPENGL_gl_LIBRARY "opengl32" STRING "OpenGL library for win32")
geant4_set_and_check_package_variable(OPENGL_glu_LIBRARY "glu32" STRING "GLU library for win32")

geant4_set_and_check_package_variable(OPENGL_INCLUDE_DIR “” “”)
----I thought this problem is cmake can’t find openGL header file(?). But I don’t konw where to find this lost file. Dose any one know how to fix this problem? And I checked my computer, it is using DX12.

I will appreciate any advice, thanks in advance!

Sorry, but one more thing.
I checked “Geant4Config.cmake” just now, and found

# - OpenGL X11
set(Geant4_vis_opengl_x11_FOUND )
if(Geant4_vis_opengl_x11_FOUND)
  find_dependency(X11)
  include("${CMAKE_CURRENT_LIST_DIR}/G4X11Shim.cmake")
  find_dependency(OpenGL)
  if(APPLE)
    find_dependency(XQuartzGL)
  endif()

  if(("vis_opengl_x11" IN_LIST Geant4_FIND_COMPONENTS) OR Geant4_vis_all_FOUND)
    list(APPEND
      Geant4_DEFINITIONS
      -DG4INTY_USE_XT
      -DG4VIS_USE_OPENGLX
      )
    set(_geant4_use_opengl_library ON)
  endif()
endif()

# - OpenGL Win32
set(Geant4_vis_opengl_win32_FOUND ON)
if(Geant4_vis_opengl_win32_FOUND)
  find_dependency(OpenGL)
  if(("vis_opengl_win32" IN_LIST Geant4_FIND_COMPONENTS) OR Geant4_vis_all_FOUND)
    list(APPEND
      Geant4_DEFINITIONS
      -DG4INTY_USE_WIN32
      -DG4VIS_USE_OPENGLWIN32
      )
    set(_geant4_use_opengl_library ON)
  endif()
endif()

Is this meaning that G4 do not support DX12?

This looks like it might be a bug in the generation on Geant4PackageCache.cmake. Please try changing the line:

geant4_set_and_check_package_variable(OPENGL_INCLUDE_DIR ""  "")

to:

geant4_set_and_check_package_variable(OPENGL_INCLUDE_DIR "" STRING "")

Try then reconfiguring your example, and it should resolve that error. There shouldn’t be any relation to DirectX, if that’s what you mean with “DX12”.

I’d also recommend updating to the latest Qt5 version, as older versions aren’t tested or guaranteed to work. However, let’s get the config error fixed first!

bmorgan

It’s fixed after I correct the config!
A lot of thanks!!