2
0
Эх сурвалжийг харах

Fix all the cross-compiling builds due to bugs in SDL CMakeLists.txt.
Fix SDL library build on Windows platform.

Yao Wei Tjong 姚伟忠 9 жил өмнө
parent
commit
3e40a5ebeb

+ 1 - 1
CMake/Modules/CheckCompilerToolchain.cmake

@@ -62,7 +62,7 @@ endmacro ()
 if (MSVC)
     # On MSVC compiler, use the chosen CMake/VS generator to determine the ABI
     # TODO: revisit this later because VS may use Clang as compiler in the future
-    if (CMAKE_GENERATOR MATCHES Win64)
+    if (CMAKE_CL_64)
         set (NATIVE_64BIT 1)
     else ()
         set (NATIVE_64BIT 0)

+ 173 - 70
CMake/Modules/FindDirectX.cmake

@@ -23,91 +23,194 @@
 # For MSVC compiler, find Microsoft DirectX installation in Windows SDK or in June 2010 DirectX SDK or later
 # For MinGW compiler, assume MinGW not only comes with the necessary headers & libraries but also has the headers & libraries directories in its default search path
 # (use 'echo |$MINGW_PREFIX-gcc -v -E -' and '$MINGW_PREFIX-gcc -print-search-dirs', respectively, to double check)
+# The MinGW headers on Linux host are usually shipped in a development package which should be installed automatically as part of the package dependency by the package manager when installing MinGW
+# (in Debian-based it is 'mingw-w64-dev' and in RedHat-based 'mingw64-headers' for 64-bit; 'mingw-w64-i686-dev' and 'mingw32-headers', respectively, for 32-bit)
 #
-#  DIRECT3D_FOUND
-#  DIRECT3D_INCLUDE_DIRS
+#  DIRECTX_FOUND (TRUE when any of the components is found)
+#  DIRECTX_INCLUDE_DIRS
+#  DIRECTX_LIBRARY_DIRS
+#  HAVE_DIRECTX (Synonym to DIRECTX_FOUND)
+#  USE_WINSDK_DIRECTX (TRUE when using Windows SDK or FALSE when using DirectX SDK; not defined on MinGW)
+#
+# When corresponding component is found:
+#  DirectX_D3D_FOUND (Currently synonym to DirectX_D3D9_FOUND)
+#  DirectX_D3D9_FOUND
+#  DirectX_D3D11_FOUND
+#  DirectX_DInput_FOUND
+#  DirectX_DSound_FOUND
+#  DirectX_XAudio2_FOUND
+#  DirectX_XInput_FOUND
+#
+# When any of the Direct3D components is found:
 #  DIRECT3D_LIBRARIES
 #  DIRECT3D_DLL
 #
+# When corresponding header is found:
+#  HAVE_D3DCOMPILER_H
+#  HAVE_D3D_H (Currently synonym to HAVE_D3D9_H)
+#  HAVE_D3D9_H
+#  HAVE_D3D11_H
+#  HAVE_DDRAW_H
+#  HAVE_DSOUND_H
+#  HAVE_DINPUT_H
+#  HAVE_DXGI_H
+#  HAVE_XAUDIO2_H
+#  HAVE_XINPUT_H
+#
+
+set (DIRECTX_HEADERS d3dcompiler.h d3d9.h d3d11.h ddraw.h dsound.h dinput.h dxgi.h xaudio2.h xinput.h)
+if (CMAKE_CL_64)
+    set (PATH_SUFFIX x64)
+else ()
+    set (PATH_SUFFIX x86)
+endif ()
+set (CMAKE_REQUIRED_INCLUDES_SAVED ${CMAKE_REQUIRED_INCLUDES})
 
-# Microsoft SDK can be used on VS2012 and above; else fallback to search for the DirectX SDK
-if (MSVC_VERSION GREATER 1600 OR MINGW)  # MinGW compiler toolchain is assumed to come with its own necessary headers and libraries for Direct3D
-    # Try to find the compiler DLL from the Microsoft SDK
+# Version older than VS2012 fallbacks to search for the DirectX SDK
+if (NOT MSVC_VERSION GREATER 1600 OR MINGW)     # MinGW meets both conditional checks intentionally
     if (MINGW)
-        # Assume that 'libd3dcompiler.a' is a symlink pointing to 'libd3dcompiler_46.a' (See this discussion http://urho3d.prophpbb.com/topic504.html)
-        # Anyway, we could not do anything else in the build system automation with version lower than 46 and libd3dcompiler_46.a is the latest supported version
-        set (DLL_NAMES d3dcompiler_46.dll)
+        # Intentionally searching for d3dcompiler(_XX) libraries in this particular order because currently the libd3dcompiler.a is an "import library" for d3dcompiler_43.dll, so we want to use libd3dcompiler_47.a or libd3dcompiler_46.a when they are available instead
+        set (D3DCOMPILER_NAMES d3dcompiler_47 d3dcompiler_46 d3dcompiler)
+        # MinGW does not need search paths as DirectX headers and libraries (when installed) are in its default search path
+        # However, we do not explicitly unset the DIRECTX_INC_SEARCH_PATH and DIRECTX_LIB_SEARCH_PATH variables here, so module user could set these two variables externally when for some reasons the DirectX headers and libraries are not installed in MinGW default search path
     else ()
-        set (DLL_NAMES d3dcompiler_47.dll d3dcompiler_46.dll)
-    endif ()
-    if (CMAKE_CL_64)
-        set (PATH_SUFFIX x64)
-    else ()
-        set (PATH_SUFFIX x86)
+        set (D3DCOMPILER_NAMES d3dcompiler)
+        # Module user could also prepopulate the DIRECTX_INC_SEARCH_PATH and DIRECTX_LIB_SEARCH_PATH variables externally when the following search paths does not work and the usage of DIRECTX_ROOT and DXSDK_DIR environment variable is not preferable
+        list (APPEND DIRECTX_INC_SEARCH_PATH
+            "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include"
+            "C:/Program Files/Microsoft DirectX SDK (June 2010)/Include"
+            $ENV{DIRECTX_ROOT}/Include
+            $ENV{DXSDK_DIR}/Include)
+        list (APPEND DIRECTX_LIB_SEARCH_PATH
+            "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/${PATH_SUFFIX}"
+            "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib/${PATH_SUFFIX}"
+            $ENV{DIRECTX_ROOT}/Lib/${PATH_SUFFIX}
+            $ENV{DXSDK_DIR}/Lib/${PATH_SUFFIX})
+        if (NOT CMAKE_CL_64)
+            list (APPEND DIRECTX_LIB_SEARCH_PATH
+                "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib"
+                "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib"
+                $ENV{DIRECTX_ROOT}/Lib
+                $ENV{DXSDK_DIR}/Lib)
+        endif ()
     endif ()
-    find_file (DIRECT3D_DLL NAMES ${DLL_NAMES} PATHS
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0;InstallationFolder]/Redist/D3D/${PATH_SUFFIX}"
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]/Redist/D3D/${PATH_SUFFIX}"
-        "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]/Redist/D3D/${PATH_SUFFIX}"
-        DOC "Direct3D DLL"
-        NO_DEFAULT_PATH)    # Do not use default paths such as the PATH variable, to potentially avoid using a wrong architecture DLL
-    if (DIRECT3D_DLL OR MINGW)
-        if (URHO3D_D3D11)
-            set (DIRECT3D_LIBRARIES d3d11 d3dcompiler dxgi dxguid)
-        else ()
-            set (DIRECT3D_LIBRARIES d3d9 d3dcompiler)
+    find_path (DIRECTX_INCLUDE_DIRS NAMES ${DIRECTX_HEADERS} PATHS ${DIRECTX_INC_SEARCH_PATH} DOC "DirectX include directory")
+    if (DIRECTX_INCLUDE_DIRS)
+        set (CMAKE_REQUIRED_INCLUDES ${DIRECTX_INCLUDE_DIRS})
+        set (DIRECTX_LIBRARY_DIRS)
+        set (DIRECT3D_LIBRARIES)
+        if (NOT URHO3D_OPENGL)
+            find_library (DIRECTX_D3DCOMPILER NAMES ${D3DCOMPILER_NAMES} PATHS ${DIRECTX_LIB_SEARCH_PATH} DOC "DirectX d3dcompiler library")
+            if (DIRECTX_D3DCOMPILER)
+                get_filename_component (NAME ${DIRECTX_D3DCOMPILER} NAME)
+                string (REGEX REPLACE "^.*(d3dcompiler[_0-9]*).*$" \\1 D3DCOMPILER_LIB_NAME ${NAME})
+                if (URHO3D_D3D11)
+                    set (DIRECT3D_LIB_NAMES d3d11 dxgi dxguid)
+                else ()
+                    set (DIRECT3D_LIB_NAMES d3d9)
+                endif ()
+                foreach (NAME ${D3DCOMPILER_LIB_NAME} ${DIRECT3D_LIB_NAMES})
+                    string (REGEX REPLACE _[0-9]+$ "" BASE_NAME ${NAME})
+                    string (TOUPPER ${BASE_NAME} UPCASE_NAME)
+                    find_library (DIRECTX_${UPCASE_NAME} NAMES ${NAME} PATHS ${DIRECTX_LIB_SEARCH_PATH} DOC "DirectX ${BASE_NAME} library")
+                    if (DIRECTX_${UPCASE_NAME})
+                        get_filename_component (PATH ${DIRECTX_${UPCASE_NAME}} PATH)
+                        list (APPEND DIRECTX_LIBRARY_DIRS ${PATH})      # All the libs should be found in a same place, but just in case
+                        list (APPEND DIRECT3D_LIBRARIES ${NAME})
+                    else ()
+                        set (MISSING_DIRECT3D_LIB TRUE)
+                    endif ()
+                    mark_as_advanced (DIRECTX_${UPCASE_NAME})
+                endforeach ()
+                if (NOT MISSING_DIRECT3D_LIB)
+                    if (NOT MINGW)
+                        set (USE_WINSDK_DIRECTX FALSE)
+                    endif ()
+                    set (HAVE_DIRECTX TRUE)
+                    if (URHO3D_D3D11)
+                        set (DirectX_D3D11_FOUND TRUE)
+                    else ()
+                        set (DirectX_D3D9_FOUND TRUE)
+                        set (DirectX_D3D_FOUND TRUE)
+                    endif ()
+                endif ()
+            endif ()
+        endif ()
+        if (DIRECTX_LIBRARY_DIRS)
+            list (REMOVE_DUPLICATES DIRECTX_LIBRARY_DIRS)
         endif ()
-        unset (DIRECT3D_INCLUDE_DIRS)
     endif ()
-    set (FAIL_MESSAGE "Could NOT find Direct3D using Windows SDK search paths")
-    mark_as_advanced (DIRECT3D_DLL)
-else ()
-    # Try to find the DirectX SDK
-    set (DIRECTX_INC_SEARCH_PATH
-        "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Include"
-        "C:/Program Files/Microsoft DirectX SDK (June 2010)/Include"
-        "$ENV{DIRECTX_ROOT}/Include"
-        "$ENV{DXSDK_DIR}/Include")
-    find_path (DIRECT3D_INCLUDE_DIRS NAMES d3dcompiler.h PATHS ${DIRECTX_INC_SEARCH_PATH} DOC "Direct3D include directory")
-    if (CMAKE_CL_64)
-        set (DIRECTX_LIB_SEARCH_PATH
-            "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x64"
-            "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib/x64"
-            "$ENV{DIRECTX_ROOT}/Lib/x64"
-            "$ENV{DXSDK_DIR}/Lib/x64")
+    if (MINGW)
+        set (FAIL_MESSAGE "Could NOT find DirectX using MinGW default search paths")
     else ()
-        set (DIRECTX_LIB_SEARCH_PATH
-            "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib"
-            "C:/Program Files (x86)/Microsoft DirectX SDK (June 2010)/Lib/x86"
-            "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib"
-            "C:/Program Files/Microsoft DirectX SDK (June 2010)/Lib/x86"
-            "$ENV{DIRECTX_ROOT}/Lib"
-            "$ENV{DIRECTX_ROOT}/Lib/x86"
-            "$ENV{DXSDK_DIR}/Lib"
-            "$ENV{DXSDK_DIR}/Lib/x86")
+        set (FAIL_MESSAGE "Could NOT find DirectX using DirectX SDK default search paths")
     endif ()
-    if (URHO3D_D3D11)
-        find_library (DIRECT3D_LIB_D3D11 NAMES d3d11 PATHS ${DIRECTX_LIB_SEARCH_PATH} DOC "Direct3D d3d11 library directory")
-        find_library (DIRECT3D_LIB_D3DCOMPILER NAMES d3dcompiler PATHS ${DIRECTX_LIB_SEARCH_PATH} DOC "Direct3D d3dcompiler library directory")
-        find_library (DIRECT3D_LIB_DXGI NAMES dxgi PATHS ${DIRECTX_LIB_SEARCH_PATH} DOC "Direct3D dxgi library directory")
-        find_library (DIRECT3D_LIB_DXGUID NAMES dxguid PATHS ${DIRECTX_LIB_SEARCH_PATH} DOC "Direct3D dxguid library directory")
-        if (DIRECT3D_INCLUDE_DIRS AND DIRECT3D_LIB_D3D11 AND DIRECT3D_LIB_D3DCOMPILER AND DIRECT3D_LIB_DXGI AND DIRECT3D_LIB_DXGUID)
-            set (DIRECT3D_LIBRARIES ${DIRECT3D_LIB_D3D11} ${DIRECT3D_LIB_D3DCOMPILER} ${DIRECT3D_LIB_DXGI} ${DIRECT3D_LIB_DXGUID})
+    mark_as_advanced (DIRECTX_INCLUDE_DIRS)
+endif ()
+
+# Windows SDK can be used on VS2012 and above
+if (MSVC_VERSION GREATER 1600 OR MINGW)     # MinGW meets both conditional checks intentionally
+    if (NOT URHO3D_OPENGL)
+        if (MINGW)
+            # Search the corresponding DLL for the found d3dcompiler "import library"
+            if (D3DCOMPILER_LIB_NAME STREQUAL d3dcompiler)
+                set (DIRECT3D_DLL_NAMES d3dcompiler_43.dll)
+            else ()
+                set (DIRECT3D_DLL_NAMES ${D3DCOMPILER_LIB_NAME}.dll)
+            endif ()
+        else ()
+            set (DIRECT3D_DLL_NAMES d3dcompiler_47.dll d3dcompiler_46.dll)
         endif ()
-        mark_as_advanced (DIRECT3D_LIB_D3D11 DIRECT3D_LIB_D3DCOMPILER DIRECT3D_LIB_DXGI DIRECT3D_LIB_DXGUID)
-    else ()
-        find_library (DIRECT3D_LIB_D3D9 NAMES d3d9 PATHS ${DIRECTX_LIB_SEARCH_PATH} DOC "Direct3D d3d9 library directory")
-        find_library (DIRECT3D_LIB_D3DCOMPILER NAMES d3dcompiler PATHS ${DIRECTX_LIB_SEARCH_PATH} DOC "Direct3D d3dcompiler library directory")
-        if (DIRECT3D_INCLUDE_DIRS AND DIRECT3D_LIB_D3D9 AND DIRECT3D_LIB_D3DCOMPILER)
-            set (DIRECT3D_LIBRARIES ${DIRECT3D_LIB_D3D9} ${DIRECT3D_LIB_D3DCOMPILER})
+        find_file (DIRECT3D_DLL NAMES ${DIRECT3D_DLL_NAMES} PATHS
+            "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0;InstallationFolder]/Redist/D3D/${PATH_SUFFIX}"
+            "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v8.1;InstallationFolder]/Redist/D3D/${PATH_SUFFIX}"
+            "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]/Redist/D3D/${PATH_SUFFIX}"
+            DOC "Direct3D DLL"
+            NO_DEFAULT_PATH)    # Do not use default paths such as the PATH variable, to potentially avoid using a wrong architecture DLL
+        if (DIRECT3D_DLL AND NOT MINGW)
+            set (USE_WINSDK_DIRECTX TRUE)
+            set (HAVE_DIRECTX TRUE)
+            if (URHO3D_D3D11)
+                set (DIRECT3D_LIBRARIES d3dcompiler d3d11 dxgi dxguid)
+                set (DirectX_D3D11_FOUND TRUE)
+            else ()
+                set (DIRECT3D_LIBRARIES d3dcompiler d3d9)
+                set (DirectX_D3D9_FOUND TRUE)
+                set (DirectX_D3D_FOUND TRUE)
+            endif ()
+            # The headers and libraries are in Windows default search paths
+            unset (DIRECTX_INCLUDE_DIRS)
+            unset (DIRECTX_LIBRARY_DIRS)
+            set (FAIL_MESSAGE "Could NOT find DirectX using Windows SDK search paths")
         endif ()
-        mark_as_advanced (DIRECT3D_LIB_D3D9 DIRECT3D_LIB_D3DCOMPILER)
+        mark_as_advanced (DIRECT3D_DLL)
     endif ()
-    set (FAIL_MESSAGE "Could NOT find Direct3D using DirectX SDK search paths")
 endif ()
 
-# DIRECT3D_INCLUDE_DIRS is not required for Windows SDK, it is required for DirectX SDK but it is implied when DIRECT3D_LIBRARIES can be set, so we just check on DIRECT3D_LIBRARIES variable
-include (FindPackageHandleStandardArgs)
-find_package_handle_standard_args (DirectX REQUIRED_VARS DIRECT3D_LIBRARIES FAIL_MESSAGE ${FAIL_MESSAGE})
+# For now take shortcut for the other DirectX components by just checking on the headers and not the libraries
+include (CheckIncludeFiles)
+include (CheckIncludeFile)
+foreach (NAME ${DIRECTX_HEADERS})
+    string (REPLACE . _ BASE_NAME ${NAME})
+    string (TOUPPER ${BASE_NAME} UPCASE_NAME)
+    if (NAME STREQUAL xinput.h)
+        # Workaround an issue in finding xinput.h using check_include_file() as it depends on windows.h but not included it by itself in WinSDK
+        check_include_files (windows.h\;${NAME} HAVE_${UPCASE_NAME})
+    else ()
+        check_include_file (${NAME} HAVE_${UPCASE_NAME})
+    endif ()
+endforeach ()
+if (HAVE_D3D9_H)
+    set (HAVE_D3D_H TRUE)
+endif ()
+foreach (COMPONENT DInput DSound XAudio2 XInput)
+    string (TOUPPER ${COMPONENT} UPCASE_NAME)
+    if (HAVE_${UPCASE_NAME}_H)
+        set (DirectX_${COMPONENT}_FOUND TRUE)
+        set (HAVE_DIRECTX TRUE)
+    endif ()
+endforeach ()
+set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVED})
 
-mark_as_advanced (DIRECT3D_INCLUDE_DIRS DIRECT3D_LIBRARIES)
+include (FindPackageHandleStandardArgs)
+find_package_handle_standard_args (DirectX REQUIRED_VARS HAVE_DIRECTX HANDLE_COMPONENTS FAIL_MESSAGE ${FAIL_MESSAGE})

+ 1 - 1
CMake/Modules/FindMir.cmake

@@ -49,4 +49,4 @@ if (MIR_FOUND)
     set (MIR_LIBRARIES ${MIR_CLIENT} ${MIR_COMMON} ${XKB})
 endif ()
 
-mark_as_advanced (MIR_INCLUDE_DIRS MIR_CLIENT_INCLUDE_DIR MIR_COMMON_INCLUDE_DIR MIR_LIBRARIES MIR_CLIENT MIR_COMMON XKB)
+mark_as_advanced (MIR_CLIENT_INCLUDE_DIR MIR_COMMON_INCLUDE_DIR MIR_CLIENT MIR_COMMON XKB)

+ 1 - 1
CMake/Modules/FindUrho3D.cmake

@@ -349,4 +349,4 @@ elseif (Urho3D_FIND_REQUIRED)
         "Use URHO3D_HOME environment variable or build option to specify the location of the non-default SDK installation or build tree. ${NOT_FOUND_MESSAGE} ${TRY_COMPILE_OUT}")
 endif ()
 
-mark_as_advanced (URHO3D_BASE_INCLUDE_DIR URHO3D_LIBRARIES URHO3D_LIBRARIES_DBG URHO3D_DLL_REL URHO3D_DLL_DBG URHO3D_HOME)
+mark_as_advanced (URHO3D_BASE_INCLUDE_DIR URHO3D_LIBRARIES URHO3D_LIBRARIES_DBG URHO3D_DLL_REL URHO3D_DLL_DBG)

+ 1 - 1
CMake/Modules/FindVideoCore.cmake

@@ -49,4 +49,4 @@ if (VIDEOCORE_FOUND)
     set (VIDEOCORE_LIBRARIES ${VIDEOCORE_BCM_HOST} ${VIDEOCORE_EGL} ${VIDEOCORE_GLES2})
 endif ()
 
-mark_as_advanced (VIDEOCORE_INCLUDE_DIRS VIDEOCORE_LIBRARIES VIDEOCORE_BCM_HOST VIDEOCORE_EGL VIDEOCORE_GLES2)
+mark_as_advanced (VIDEOCORE_INCLUDE_DIRS VIDEOCORE_BCM_HOST VIDEOCORE_EGL VIDEOCORE_GLES2)

+ 13 - 16
CMake/Modules/Urho3D-CMake-common.cmake

@@ -459,15 +459,19 @@ if (URHO3D_DATABASE_SQLITE OR URHO3D_DATABASE_ODBC)
 endif ()
 
 if (WIN32)
-    # Find DirectX include & library directories in MS Windows SDK or DirectX SDK. They may also be required by SDL
-    # even if using OpenGL instead of Direct3D, but do not make DirectX REQUIRED in that case
+    set (DIRECTX_REQUIRED_COMPONENTS)
+    set (DIRECTX_OPTIONAL_COMPONENTS DInput DSound XAudio2 XInput)
     if (NOT URHO3D_OPENGL)
-        find_package (DirectX REQUIRED)
-    else ()
-        find_package (DirectX)
+        if (URHO3D_D3D11)
+            list (APPEND DIRECTX_REQUIRED_COMPONENTS D3D11)
+        else ()
+            list (APPEND DIRECTX_REQUIRED_COMPONENTS D3D)
+        endif ()
     endif ()
-    if (DIRECT3D_INCLUDE_DIRS)
-        include_directories (${DIRECT3D_INCLUDE_DIRS})
+    find_package (DirectX REQUIRED ${DIRECTX_REQUIRED_COMPONENTS} OPTIONAL_COMPONENTS ${DIRECTX_OPTIONAL_COMPONENTS})
+    if (DIRECTX_FOUND)
+        include_directories (${DIRECTX_INCLUDE_DIRS})   # These variables may be empty when WinSDK or MinGW is being used
+        link_directories (${DIRECTX_LIBRARY_DIRS})
     endif ()
 endif ()
 
@@ -1132,7 +1136,7 @@ macro (setup_executable)
         add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND scp $<TARGET_FILE:${TARGET_NAME}> ${URHO3D_SCP_TO_TARGET} || exit 0
             COMMENT "Scp-ing ${TARGET_NAME} executable to target system")
     endif ()
-    if (DIRECT3D_DLL AND NOT URHO3D_OPENGL AND NOT ARG_NODEPS AND CMAKE_RUNTIME_OUTPUT_DIRECTORY)
+    if (DIRECT3D_DLL AND NOT ARG_NODEPS AND CMAKE_RUNTIME_OUTPUT_DIRECTORY)
         # Make a copy of the D3D DLL to the runtime directory in the build tree
         add_custom_command (TARGET ${TARGET_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${DIRECT3D_DLL} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
     endif ()
@@ -1543,14 +1547,7 @@ macro (define_dependency_libs TARGET)
                 list (APPEND LIBS GL)
             endif ()
         elseif (DIRECT3D_LIBRARIES)
-            # Check if the libs are using absolute path
-            list (GET DIRECT3D_LIBRARIES 0 FIRST_LIB)
-            if (IS_ABSOLUTE ${FIRST_LIB})
-                list (APPEND ABSOLUTE_PATH_LIBS ${DIRECT3D_LIBRARIES})
-            else ()
-                # Assume the libraries are found from default directories
-                list (APPEND LIBS ${DIRECT3D_LIBRARIES})
-            endif ()
+            list (APPEND LIBS ${DIRECT3D_LIBRARIES})
         endif ()
 
         # Database

+ 3 - 3
Docs/GettingStarted.dox

@@ -17,7 +17,7 @@ Although all required third-party libraries are included as source code, there a
     - libiodbc2-dev (Debian-based) or libiodbc-devel (RedHat-based) for iODBC driver manager. Mutually exclusive with ODBC driver manager.
     - unixodbc-dev (Debian-based) or unixODBC-devel (RedHat-based) for ODBC driver manager. Mutually exclusive with iODBC driver manager. *Recommended but optional*
   + Display server:
-    - libdirectfb-dev (Debian-based only) for Direct Frame Buffer (DirectFB).
+    - libdirectfb-dev (Debian-based only) for Direct Frame Buffer (DirectFB). Disabled by default even when installed, use SDL_OPT_VIDEO_DIRECTFB build option to enable.
     - mir-client-platform-mesa-dev and mircommon-dev (Ubuntu only) for Mir.
     - libwayland-client-devel, libwayland-cursor-devel, and mesa-libwayland-egl-devel (RedHat-based only, pre-installed on Fedora 22+) for Wayland.
     - libx11-dev and libxrandr-dev (Debian-based) or libX11-devel and libXrandr-devel (RedHat-based) for X11. *Recommended*
@@ -25,8 +25,8 @@ Although all required third-party libraries are included as source code, there a
     - libasound2-dev (Debian-based) or  alsa-lib-devel (RedHat-based) for Advanced Linux Sound Architecture (ALSA).
     - arts-devel (RedHat-based only) for Analog Real Time Synthesizer (aRts).
     - libaudio-dev (Debian-based only) for Network Audio System (NAS).
-    - libesd0-dev (Debian-based) or esound-devel (RedHat-based) for Enlightened Sound Eaemon (ESounD).
-    - libfusionsound-dev (DB-based only, not available on Ubuntu) for FusionSound. Disabled by default even when installed, use SDL_OPT_FUSIONSOUND(_SHARED) build option to enable.
+    - libesd0-dev (Debian-based) or esound-devel (RedHat-based) for Enlightened Sound Daemon (ESounD).
+    - libfusionsound-dev (Debian-based only, not available on Ubuntu) for FusionSound. Disabled by default even when installed, use SDL_OPT_FUSIONSOUND build option to enable.
     - libpulse-dev (Debian-based) or pulseaudio-libs-devel (RedHat-based) for PulseAudio. *Recommended*
     - libroar-dev (Debian-based only) for RoarAudio (SNDIO).
   + Misc.:

+ 23 - 58
Source/ThirdParty/SDL/CMakeLists.txt

@@ -195,10 +195,10 @@ endif()
 
 # Urho3D - commented out compiler/linker flags setup as we have configured all our compiler/linker flags as we want globally
 
-# Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config,
-# etc. are created correctly.
-set(SDL_LIBS "-lSDL2")
-set(SDL_CFLAGS "")
+# Those are used for pkg-config and friends, so that the SDL2.pc, sdl2-config, # etc. are created correctly.
+# Urho3D - we do not use these variables for pkg-config setup for SDL library but we may need them later for Urho3D library
+set (SDL_LIBS)
+set (SDL_CFLAGS)
 
 # Emscripten toolchain has a nonempty default value for this, and the checks
 # in this file need to change that, so remember the original value, and
@@ -314,9 +314,12 @@ foreach(_SUB ${SDL_X11_OPTIONS})
   dep_option(${_OPT}           "Enable ${_SUB} support" ON "VIDEO_X11" OFF)
 endforeach()
 set_option(VIDEO_COCOA         "Use Cocoa video driver" ${APPLE})
-set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
+# Urho3D - only make DIRECTX option available on Windows platform when URHO3D_OPENGL is enabled
+if (WINDOWS)
+  dep_option(DIRECTX             "Use DirectX for Windows audio/video" ON URHO3D_OPENGL ON)
+endif ()
 # Urho3D - commented out RENDER_D3D as an option to avoid potential conflict with our URHO3D_OPENGL and URHO3D_D3D11 build options on Windows platform
-#          Instead just initialize the variable according to our build options
+#          Instead just initialize the variable according to our build options; Urho3D also by default disables the SDL renderer subsystem
 if (WINDOWS)
   if (URHO3D_OPENGL)
     set (RENDER_D3D FALSE)
@@ -924,34 +927,8 @@ elseif(WINDOWS)
 
   # Check for DirectX
   if(DIRECTX)
-    if(DEFINED MSVC_VERSION AND NOT ${MSVC_VERSION} LESS 1700)
-        set(USE_WINSDK_DIRECTX TRUE)
-    endif()
-    if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
-      if("$ENV{DXSDK_DIR}" STREQUAL "")
-        message_error("DIRECTX requires the \$DXSDK_DIR environment variable to be set")
-      endif()
-      set(CMAKE_REQUIRED_FLAGS "/I\"$ENV{DXSDK_DIR}\\Include\"")
-    endif()
-
-    # Urho3D - simplify the check for xinput.h
-    check_include_file(xinput.h HAVE_XINPUT_H)
-    check_include_file(d3d9.h HAVE_D3D_H)
-    check_include_file(d3d11_1.h HAVE_D3D11_H)
-    check_include_file(ddraw.h HAVE_DDRAW_H)
-    check_include_file(dsound.h HAVE_DSOUND_H)
-    check_include_file(dinput.h HAVE_DINPUT_H)
-    check_include_file(xaudio2.h HAVE_XAUDIO2_H)
-    check_include_file(dxgi.h HAVE_DXGI_H)
-    if(HAVE_D3D_H OR HAVE_D3D11_H OR HAVE_DDRAW_H OR HAVE_DSOUND_H OR HAVE_DINPUT_H OR HAVE_XAUDIO2_H)
-      set(HAVE_DIRECTX TRUE)
-      if(NOT CMAKE_COMPILER_IS_MINGW AND NOT USE_WINSDK_DIRECTX)
-      # TODO: change $ENV{DXSDL_DIR} to get the path from the include checks
-        link_directories($ENV{DXSDK_DIR}\\lib\\${PROCESSOR_ARCH})
-        include_directories($ENV{DXSDK_DIR}\\Include)
-      endif()
-    endif()
-    set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
+    # Urho3D - bug fix - use our own FindDirectX.cmake module which does not rely on DXSDK_DIR environment variable directly when DirectX SDK is being used
+    # Urho3D - TODO - move the find_package(DirectX) call from Urho3D common module to here later after we have refactored the library dependency handling
   endif()
 
   if(SDL_AUDIO)
@@ -991,6 +968,8 @@ elseif(WINDOWS)
       set(HAVE_RENDER_D3D TRUE)
     endif()
     set(HAVE_SDL_VIDEO TRUE)
+    # Urho3D - bug fix - we are going to need this later when we refactor the library dependency handling
+    list (APPEND EXTRA_LIBS ${DIRECT3D_LIBRARIES})    # Empty when none of the D3D components is used
   endif()
 
   if(SDL_THREADS)
@@ -1093,14 +1072,8 @@ elseif(WINDOWS)
     endif()
   endif()
 
-  file(GLOB VERSION_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.rc)
-  file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/windows/*.c)
-  if(MINGW OR CYGWIN)
-    list(APPEND EXTRA_LIBS mingw32)
-    list(APPEND EXTRA_LDFLAGS "-mwindows")
-    set(SDL_CFLAGS "${SDL_CFLAGS} -Dmain=SDL_main")
-    list(APPEND SDL_LIBS "-lmingw32" "-lSDL2main" "-mwindows")
-  endif()
+  # Urho3D - commented out adding main entry point for Windows platform
+  # Urho3D - commented out '-mwindows' linker flags setup as it appears to be automatically added by CMake; also commented out 'mingw32' library dependency as it does not appear to be needed, at least that the case for MinGW
 elseif(APPLE)
   # TODO: rework this for proper MacOS X, iOS and Darwin support
 
@@ -1171,6 +1144,7 @@ elseif(APPLE)
   endif()
 
   # Actually load the frameworks at the end so we don't duplicate include.
+  # Urho3D - TODO - this list in complete, do this when we refactor the library dependency handling
   if(SDL_FRAMEWORK_COREVIDEO)
     find_library(COREVIDEO CoreVideo)
     list(APPEND EXTRA_LIBS ${COREVIDEO})
@@ -1288,9 +1262,7 @@ if(NOT HAVE_SDL_TIMERS)
   set(SOURCE_FILES ${SOURCE_FILES} ${TIMER_SOURCES})
 endif()
 
-if(NOT SDLMAIN_SOURCES)
-  file(GLOB SDLMAIN_SOURCES ${SDL2_SOURCE_DIR}/src/main/dummy/*.c)
-endif()
+# Urho3D - commented out inclusion of dummy main
 
 # Append the -MMD -MT flags
 # if(DEPENDENCY_TRACKING)
@@ -1318,7 +1290,7 @@ set(EXTRA_CFLAGS ${_EXTRA_CFLAGS})
 
 # Compat helpers for the configuration files
 if(NOT WINDOWS OR CYGWIN)
-# Urho3D - commeted out the call to updaterev.sh script as it won't work on any platform as it assumes hg to be the version source control which is not the case in our case
+  # Urho3D - commeted out the call to updaterev.sh script as it won't work on any platform as it assumes hg to be the version source control which is not true in our case
 
   set(prefix ${CMAKE_INSTALL_PREFIX})
   set(exec_prefix "\${prefix}")
@@ -1349,10 +1321,8 @@ if(NOT WINDOWS OR CYGWIN)
   listtostr(SDL_LIBS _SDL_LIBS)
   set(SDL_LIBS ${_SDL_LIBS})
 
-  # MESSAGE(STATUS "SDL_LIBS: ${SDL_LIBS}")
-  # MESSAGE(STATUS "SDL_STATIC_LIBS: ${SDL_STATIC_LIBS}")
-
-# Urho3D - commented out pkg-config configuration file generation
+  # Urho3D - commented out pkg-config configuration file generation
+  # Urho3D - TODO - utilize the populated variables for pkg-config configuration file generation for Urho3D.pc
 endif()
 
 # Urho3D - restore the original CMake global settings
@@ -1400,17 +1370,14 @@ message(STATUS "")
 message(STATUS " Build Shared Library: ${SDL_SHARED}")
 message(STATUS " Build Static Library: ${SDL_STATIC}")
 message(STATUS "")
-if(UNIX)
-  message(STATUS "If something was not detected, although the libraries")
-  message(STATUS "were installed, then make sure you have set the")
-  message(STATUS "CFLAGS and LDFLAGS environment variables correctly.")
-  message(STATUS "")
-endif()
+# Urho3D - commented out messages informing user to set the CFLAGS and LDFLAGS environment variables to workaround detection problems, our modified version does not support that
 endif (NOT SDL_INFO_ECHOED_STATUS)
 
 # Ensure that the extra cflags are used at compile time
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
+# Urho3D - commented out targets defined by original CMakeLists.txt, instead we setup our own target that meets our own needs
+
 # Urho3D - use Emscripten's own SDL2 port
 if (WEB)
   # Emscripten has its own SDL2 port, so just create a custom target to:
@@ -1433,5 +1400,3 @@ if (ANDROID)
   install_header_files (FILES src/SDL_internal.h DESTINATION ${DEST_INCLUDE_DIR}/ThirdParty/SDL)
   install_header_files (DIRECTORY src/dynapi DESTINATION ${DEST_INCLUDE_DIR}/ThirdParty/SDL FILES_MATCHING PATTERN *.h)
 endif ()
-
-# Urho3D - commented out other targets

+ 1 - 1
Source/ThirdParty/SDL/cmake/sdlchecks.cmake

@@ -1076,7 +1076,7 @@ endmacro()
 macro(CheckRPI)
   if(VIDEO_RPI)
     # Urho3D - bug fix - when cross-compiling the headers are rooted
-    # Urho3D - TODO - move the find_package(VideoCore REQUIRED) call from Urho3D common module to here
+    # Urho3D - TODO - move the find_package(VideoCore REQUIRED) call from Urho3D common module to here later after we have refactored the library dependency handling
     listtostr (VIDEOCORE_INCLUDE_DIRS VIDEO_RPI_INCLUDE_FLAGS "-I")
     listtostr (VIDEOCORE_LIBRARIES VIDEO_RPI_LIBRARY_FLAGS "-L")
     set(CMAKE_REQUIRED_FLAGS "${VIDEO_RPI_INCLUDE_FLAGS} ${VIDEO_RPI_LIBRARY_FLAGS}")