summaryrefslogtreecommitdiff
path: root/indra/cmake
diff options
context:
space:
mode:
authorNat Goodspeed <nat@lindenlab.com>2020-05-07 16:59:19 -0400
committerNat Goodspeed <nat@lindenlab.com>2020-05-07 16:59:19 -0400
commit92c70ff637da5fda06aaeb40914c77499bf2d0ce (patch)
tree6de9b8a3cea0b0e164cdfd6ab7e590f10189b5b6 /indra/cmake
parent61ec84b1d88a5972cd8cc7ed0f5ad9f0ae92c27c (diff)
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.
Diffstat (limited to 'indra/cmake')
-rw-r--r--indra/cmake/DirectX.cmake52
1 files changed, 19 insertions, 33 deletions
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)