From 92c70ff637da5fda06aaeb40914c77499bf2d0ce Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Thu, 7 May 2020 16:59:19 -0400 Subject: DRTVWR-476: Help DirectX.cmake cope with multiple SDK versions. First, get rid of ancient cruft in the find_path() calls: on a 64-bit system, "$ENV{PROGRAMFILES}" expands to the 64-bit 'Program Files' directory rather than the 32-bit 'Program Files (x86)' directory, and none of the ancient cruft would be found there anyway. Empirically, find_path(dxdiag.h) is able to find the file using environment variables (INCLUDE from VS variables?), so it doesn't need the specific pathnames coded into that call. Once we find DIRECTX_INCLUDE_DIR, don't immediately insert it into include_directories: we've had troubles with incompatible Windows SDK versions (compile errors in Microsoft header files!) when DIRECTX_INCLUDE_DIR preceded the Windows SDK directory in the include path. The DIRECTX_FIND_QUIETLY logic seemed backwards: the message(STATUS) output was emitted only when DIRECTX_FIND_QUIETLY was false. Reverse that. The ancient cruft in find_path(dxguid.lib) was causing it to find the wrong (very old) DirectX library. Remove ancient cruft. But empirically, without that, even once we've found DIRECTX_INCLUDE_DIR, CMake could not implicitly find dxguid.lib. If the DirectX directory hierarchy were structured as .../version/Include and .../version/Lib, a relative pathname would have been sufficient hint. Unfortunately it's structured as .../Include/version and .../Lib/version, so a relative pathname would have to include the specific version. Instead, replace "/Include/" with "/Lib/". But even then, we have to drill down to the architecture-specific subdirectory based on ADDRESS_SIZE. --- indra/cmake/DirectX.cmake | 52 +++++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 33 deletions(-) (limited to 'indra/cmake/DirectX.cmake') diff --git a/indra/cmake/DirectX.cmake b/indra/cmake/DirectX.cmake index 25163d0322..201b157264 100644 --- a/indra/cmake/DirectX.cmake +++ b/indra/cmake/DirectX.cmake @@ -1,46 +1,32 @@ # -*- cmake -*- if (WINDOWS) - find_path(DIRECTX_INCLUDE_DIR dxdiag.h - "$ENV{DXSDK_DIR}/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2010)/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2009)/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2009)/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2008)/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2008)/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2008)/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (November 2007)/Include" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2007)/Include" - "C:/DX90SDK/Include" - "$ENV{PROGRAMFILES}/DX90SDK/Include" - ) + find_path(DIRECTX_INCLUDE_DIR dxdiag.h) if (DIRECTX_INCLUDE_DIR) - include_directories(${DIRECTX_INCLUDE_DIR}) - if (DIRECTX_FIND_QUIETLY) + if (NOT DIRECTX_FIND_QUIETLY) message(STATUS "Found DirectX include: ${DIRECTX_INCLUDE_DIR}") - endif (DIRECTX_FIND_QUIETLY) + endif (NOT DIRECTX_FIND_QUIETLY) else (DIRECTX_INCLUDE_DIR) message(FATAL_ERROR "Could not find DirectX SDK Include") endif (DIRECTX_INCLUDE_DIR) - - find_path(DIRECTX_LIBRARY_DIR dxguid.lib - "$ENV{DXSDK_DIR}/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2010)/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2009)/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2009)/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2008)/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2008)/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2008)/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (November 2007)/Lib/x86" - "$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2007)/Lib/x86" - "C:/DX90SDK/Lib" - "$ENV{PROGRAMFILES}/DX90SDK/Lib" - ) + # dxhint isn't meant to be the hard-coded DIRECTX_LIBRARY_DIR, we're just + # suggesting it as a hint to the next find_path(). The version is embedded + # in the DIRECTX_INCLUDE_DIR path string after Include and Lib, which is why + # we don't just append a relative path: if there are multiple versions + # installed on the host, we need to be sure we're using THE SAME version. + string(REPLACE "/Include/" "/Lib/" dxhint "${DIRECTX_INCLUDE_DIR}") + if (ADDRESS_SIZE EQUAL 32) + set(archdir x86) + else() + set(archdir x64) + endif() + string(APPEND dxhint "/${archdir}") + find_path(DIRECTX_LIBRARY_DIR dxguid.lib HINTS "${dxhint}") if (DIRECTX_LIBRARY_DIR) - if (DIRECTX_FIND_QUIETLY) - message(STATUS "Found DirectX include: ${DIRECTX_LIBRARY_DIR}") - endif (DIRECTX_FIND_QUIETLY) + if (NOT DIRECTX_FIND_QUIETLY) + message(STATUS "Found DirectX library: ${DIRECTX_LIBRARY_DIR}") + endif (NOT DIRECTX_FIND_QUIETLY) else (DIRECTX_LIBRARY_DIR) message(FATAL_ERROR "Could not find DirectX SDK Libraries") endif (DIRECTX_LIBRARY_DIR) -- cgit v1.2.3 From c74810ca3fc7e5a3f6b84a3d3259294aaa9288be Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 11 May 2020 11:39:27 -0400 Subject: DRTVWR-476: Use find_library(dxguid) rather than find_path(). --- indra/cmake/DirectX.cmake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'indra/cmake/DirectX.cmake') diff --git a/indra/cmake/DirectX.cmake b/indra/cmake/DirectX.cmake index 201b157264..be9797b575 100644 --- a/indra/cmake/DirectX.cmake +++ b/indra/cmake/DirectX.cmake @@ -11,10 +11,11 @@ if (WINDOWS) endif (DIRECTX_INCLUDE_DIR) # dxhint isn't meant to be the hard-coded DIRECTX_LIBRARY_DIR, we're just - # suggesting it as a hint to the next find_path(). The version is embedded - # in the DIRECTX_INCLUDE_DIR path string after Include and Lib, which is why - # we don't just append a relative path: if there are multiple versions - # installed on the host, we need to be sure we're using THE SAME version. + # suggesting it as a hint to find_library(). The Windows SDK version number + # is embedded in the DIRECTX_INCLUDE_DIR path string after Include and Lib, + # which is why we don't just append a relative path: if there are multiple + # versions installed on the host, we need to be sure we're using THE SAME + # version. string(REPLACE "/Include/" "/Lib/" dxhint "${DIRECTX_INCLUDE_DIR}") if (ADDRESS_SIZE EQUAL 32) set(archdir x86) @@ -22,7 +23,8 @@ if (WINDOWS) set(archdir x64) endif() string(APPEND dxhint "/${archdir}") - find_path(DIRECTX_LIBRARY_DIR dxguid.lib HINTS "${dxhint}") + find_library(DXGUID_LIBRARY dxguid HINTS "${dxhint}") + get_filename_component(DIRECTX_LIBRARY_DIR "${DXGUID_LIBRARY}" DIRECTORY) if (DIRECTX_LIBRARY_DIR) if (NOT DIRECTX_FIND_QUIETLY) message(STATUS "Found DirectX library: ${DIRECTX_LIBRARY_DIR}") -- cgit v1.2.3 From 6148a6443af886f9b71b4c88084db943950e146c Mon Sep 17 00:00:00 2001 From: Nicky Dasmijn Date: Tue, 19 May 2020 00:03:19 +0200 Subject: Remove DirectX.cmake. With recent SDKs (dating back to at least VS 2013 and the 8.1 SDK) DirectX is included in the SDK and does not need any special detection logic. --- indra/cmake/DirectX.cmake | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 indra/cmake/DirectX.cmake (limited to 'indra/cmake/DirectX.cmake') diff --git a/indra/cmake/DirectX.cmake b/indra/cmake/DirectX.cmake deleted file mode 100644 index be9797b575..0000000000 --- a/indra/cmake/DirectX.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# -*- cmake -*- - -if (WINDOWS) - find_path(DIRECTX_INCLUDE_DIR dxdiag.h) - if (DIRECTX_INCLUDE_DIR) - if (NOT DIRECTX_FIND_QUIETLY) - message(STATUS "Found DirectX include: ${DIRECTX_INCLUDE_DIR}") - endif (NOT DIRECTX_FIND_QUIETLY) - else (DIRECTX_INCLUDE_DIR) - message(FATAL_ERROR "Could not find DirectX SDK Include") - endif (DIRECTX_INCLUDE_DIR) - - # dxhint isn't meant to be the hard-coded DIRECTX_LIBRARY_DIR, we're just - # suggesting it as a hint to find_library(). The Windows SDK version number - # is embedded in the DIRECTX_INCLUDE_DIR path string after Include and Lib, - # which is why we don't just append a relative path: if there are multiple - # versions installed on the host, we need to be sure we're using THE SAME - # version. - string(REPLACE "/Include/" "/Lib/" dxhint "${DIRECTX_INCLUDE_DIR}") - if (ADDRESS_SIZE EQUAL 32) - set(archdir x86) - else() - set(archdir x64) - endif() - string(APPEND dxhint "/${archdir}") - find_library(DXGUID_LIBRARY dxguid HINTS "${dxhint}") - get_filename_component(DIRECTX_LIBRARY_DIR "${DXGUID_LIBRARY}" DIRECTORY) - if (DIRECTX_LIBRARY_DIR) - if (NOT DIRECTX_FIND_QUIETLY) - message(STATUS "Found DirectX library: ${DIRECTX_LIBRARY_DIR}") - endif (NOT DIRECTX_FIND_QUIETLY) - else (DIRECTX_LIBRARY_DIR) - message(FATAL_ERROR "Could not find DirectX SDK Libraries") - endif (DIRECTX_LIBRARY_DIR) - -endif (WINDOWS) -- cgit v1.2.3