@@ -117,6 +117,10 @@ if(NOT DAEMON_EXTERNAL_APP)
117117 option (USE_MUMBLE "Build Daemon with mumblelink sumpport" ON )
118118 endif ()
119119
120+ if (BUILD_CLIENT)
121+ # option(USE_VULKAN "Use Vulkan rendering API instead of OpenGL." OFF)
122+ endif ()
123+
120124 option (USE_SMP "Compile with support for running the renderer in a separate thread" ON )
121125 option (USE_BREAKPAD "Generate Daemon crash dumps (which require Breakpad tools to read)" OFF )
122126endif ()
@@ -634,65 +638,72 @@ if (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP)
634638 endif ()
635639endif ()
636640
637- # Look for OpenGL here before we potentially switch to looking for static libs.
638- if (BUILD_CLIENT)
639- if (LINUX OR FREEBSD)
640- # Set LEGACY OpenGL ABI if the variable is not explictly set.
641- # The backward-incompatible GLVND OpenGL ABI should only be used
642- # by developers who have a good reason to require it.
643- # See: https://github.com/DaemonEngine/Daemon/issues/945#issuecomment-1835091256
644- set (OpenGL_GL_PREFERENCE "LEGACY" CACHE STRING "Linux OpenGL ABI (LEGACY or GLVND)." )
645- endif ()
646-
647- find_package (OpenGL REQUIRED)
648- include_directories (${OPENGL_INCLUDE_DIR} )
649- set (LIBS_CLIENT ${LIBS_CLIENT} OpenGL::GL)
650-
651- # When OpenGL_GL_PREFERENCE is set but neither GLVND nor LEGACY are available,
652- # This code is unreachable since it already errored out at find_package time.
653- # This code only executes if OpenGL is supported, either because the GLVND ABI
654- # is available, either because the LEGACY ABI is available.
655- if (LINUX OR FREEBSD)
656- if (NOT OPENGL_gl_LIBRARY)
657- # When OpenGL_GL_PREFERENCE is supported and GLVND is available
658- # OPENGL_gl_LIBRARY is expected to be empty. So we can use the
659- # emptyness of OPENGL_gl_LIBRARY to detect that CMake supports
660- # OpenGL_GL_PREFERENCE and GLVND is used:
661- # > If the GLVND OpenGL and GLX libraries are available, prefer them.
662- # > This forces OPENGL_gl_LIBRARY to be empty.
663- # -- https://cmake.org/cmake/help/latest/module/FindOpenGL.html
664- set (OpenGL_selected_ABI "GLVND" )
665- set (OpenGL_selected_LIBRARY "${OPENGL_opengl_LIBRARY} " )
666- else ()
667- # When OpenGL_GL_PREFERENCE is not supported or GLVND is not available
668- # the OPENGL_gl_LIBRARY is always set, so if it is set, it means the ABI
669- # is the LEGACY one.
670- set (OpenGL_selected_ABI "LEGACY" )
671- set (OpenGL_selected_LIBRARY "${OPENGL_gl_LIBRARY} " )
641+ if (USE_VULKAN)
642+ add_definitions ("-DDAEMON_RENDERER_VULKAN=1" )
643+ add_definitions ("-DVK_NO_PROTOTYPES=1" )
644+ else ()
645+ add_definitions ("-DDAEMON_RENDERER_OPENGL=1" )
646+
647+ # Look for OpenGL here before we potentially switch to looking for static libs.
648+ if (BUILD_CLIENT)
649+ if (LINUX OR FREEBSD)
650+ # Set LEGACY OpenGL ABI if the variable is not explictly set.
651+ # The backward-incompatible GLVND OpenGL ABI should only be used
652+ # by developers who have a good reason to require it.
653+ # See: https://github.com/DaemonEngine/Daemon/issues/945#issuecomment-1835091256
654+ set (OpenGL_GL_PREFERENCE "LEGACY" CACHE STRING "Linux OpenGL ABI (LEGACY or GLVND)." )
672655 endif ()
673656
674- if (OpenGL_selected_ABI STREQUAL "GLVND" )
675- message (WARNING "The GLVND OpenGL ABI is backward incompatible with legacy drivers. \n See https://github.com/DaemonEngine/Daemon/issues/945" )
676- endif ( )
657+ find_package (OpenGL REQUIRED )
658+ include_directories ( ${OPENGL_INCLUDE_DIR} )
659+ set (LIBS_CLIENT ${LIBS_CLIENT} OpenGL::GL )
677660
678- if (OpenGL_GL_PREFERENCE STREQUAL "GLVND" )
679- if (NOT OPENGL_opengl_LIBRARY)
680- message (WARNING "GLVND OpenGL ABI not available but LEGACY is.\n Try OpenGL_GL_PREFERENCE=LEGACY" )
681- message (FATAL_ERROR "Could NOT find GLVND libOpenGL.so" )
682- endif ()
683- else ()
661+ # When OpenGL_GL_PREFERENCE is set but neither GLVND nor LEGACY are available,
662+ # This code is unreachable since it already errored out at find_package time.
663+ # This code only executes if OpenGL is supported, either because the GLVND ABI
664+ # is available, either because the LEGACY ABI is available.
665+ if (LINUX OR FREEBSD)
684666 if (NOT OPENGL_gl_LIBRARY)
685- message (WARNING "LEGACY OpenGL ABI not available but GLVND is.\n Try OpenGL_GL_PREFERENCE=GLVND" )
686- message (FATAL_ERROR "Could NOT find LEGACY libGL.so" )
667+ # When OpenGL_GL_PREFERENCE is supported and GLVND is available
668+ # OPENGL_gl_LIBRARY is expected to be empty. So we can use the
669+ # emptyness of OPENGL_gl_LIBRARY to detect that CMake supports
670+ # OpenGL_GL_PREFERENCE and GLVND is used:
671+ # > If the GLVND OpenGL and GLX libraries are available, prefer them.
672+ # > This forces OPENGL_gl_LIBRARY to be empty.
673+ # -- https://cmake.org/cmake/help/latest/module/FindOpenGL.html
674+ set (OpenGL_selected_ABI "GLVND" )
675+ set (OpenGL_selected_LIBRARY "${OPENGL_opengl_LIBRARY} " )
676+ else ()
677+ # When OpenGL_GL_PREFERENCE is not supported or GLVND is not available
678+ # the OPENGL_gl_LIBRARY is always set, so if it is set, it means the ABI
679+ # is the LEGACY one.
680+ set (OpenGL_selected_ABI "LEGACY" )
681+ set (OpenGL_selected_LIBRARY "${OPENGL_gl_LIBRARY} " )
682+ endif ()
683+
684+ if (OpenGL_selected_ABI STREQUAL "GLVND" )
685+ message (WARNING "The GLVND OpenGL ABI is backward incompatible with legacy drivers.\n See https://github.com/DaemonEngine/Daemon/issues/945" )
686+ endif ()
687+
688+ if (OpenGL_GL_PREFERENCE STREQUAL "GLVND" )
689+ if (NOT OPENGL_opengl_LIBRARY)
690+ message (WARNING "GLVND OpenGL ABI not available but LEGACY is.\n Try OpenGL_GL_PREFERENCE=LEGACY" )
691+ message (FATAL_ERROR "Could NOT find GLVND libOpenGL.so" )
692+ endif ()
693+ else ()
694+ if (NOT OPENGL_gl_LIBRARY)
695+ message (WARNING "LEGACY OpenGL ABI not available but GLVND is.\n Try OpenGL_GL_PREFERENCE=GLVND" )
696+ message (FATAL_ERROR "Could NOT find LEGACY libGL.so" )
697+ endif ()
687698 endif ()
688- endif ()
689699
690- message (STATUS "Found OpenGL ABI: ${OpenGL_selected_ABI} " )
691- message (STATUS "Found OpenGL library: ${OpenGL_selected_LIBRARY} " )
700+ message (STATUS "Found OpenGL ABI: ${OpenGL_selected_ABI} " )
701+ message (STATUS "Found OpenGL library: ${OpenGL_selected_LIBRARY} " )
692702
693- daemon_add_buildinfo("char*" "DAEMON_OPENGL_ABI_STRING" "\" ${OpenGL_selected_ABI} \" " )
694- add_definitions ("-DDAEMON_OPENGL_ABI_${OpenGL_selected_ABI} " )
695- add_definitions ("-DDAEMON_OPENGL_ABI" )
703+ daemon_add_buildinfo("char*" "DAEMON_OPENGL_ABI_STRING" "\" ${OpenGL_selected_ABI} \" " )
704+ add_definitions ("-DDAEMON_OPENGL_ABI_${OpenGL_selected_ABI} " )
705+ add_definitions ("-DDAEMON_OPENGL_ABI" )
706+ endif ()
696707 endif ()
697708endif ()
698709
@@ -985,6 +996,7 @@ if (NOT NACL)
985996 set_property (TARGET engine-lib APPEND PROPERTY INCLUDE_DIRECTORIES ${ENGINE_DIR} ${MOUNT_DIR} ${LIB_DIR} )
986997 set_property (TARGET engine-lib APPEND PROPERTY COMPILE_OPTIONS ${WARNINGS} )
987998 set_target_properties (engine-lib PROPERTIES FOLDER "engine/objects" )
999+
9881000 ADD_PRECOMPILED_HEADER(engine-lib)
9891001
9901002 if (BUILD_DUMMY_APP)
@@ -1007,9 +1019,16 @@ if (BUILD_CLIENT)
10071019 if (USE_SMP)
10081020 list (APPEND Definitions USE_SMP)
10091021 endif ()
1022+
1023+ if (USE_VULKAN)
1024+ set (CLIENT_EXECUTABLE_NAME daemon-vulkan)
1025+ else ()
1026+ set (CLIENT_EXECUTABLE_NAME daemon)
1027+ endif ()
1028+
10101029 AddApplication(
10111030 Target client
1012- ExecutableName daemon
1031+ ExecutableName ${CLIENT_EXECUTABLE_NAME}
10131032 ApplicationMain ${ENGINE_DIR} /client/ClientApplication.cpp
10141033 Definitions ${Definitions}
10151034 Flags ${WARNINGS}
0 commit comments