Skip to content
Snippets Groups Projects
Commit 92c70ff6 authored by Nat Goodspeed's avatar Nat Goodspeed
Browse files

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.
parent 61ec84b1
No related branches found
No related tags found
No related merge requests found
# -*- cmake -*- # -*- cmake -*-
if (WINDOWS) if (WINDOWS)
find_path(DIRECTX_INCLUDE_DIR dxdiag.h 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"
)
if (DIRECTX_INCLUDE_DIR) if (DIRECTX_INCLUDE_DIR)
include_directories(${DIRECTX_INCLUDE_DIR}) if (NOT DIRECTX_FIND_QUIETLY)
if (DIRECTX_FIND_QUIETLY)
message(STATUS "Found DirectX include: ${DIRECTX_INCLUDE_DIR}") message(STATUS "Found DirectX include: ${DIRECTX_INCLUDE_DIR}")
endif (DIRECTX_FIND_QUIETLY) endif (NOT DIRECTX_FIND_QUIETLY)
else (DIRECTX_INCLUDE_DIR) else (DIRECTX_INCLUDE_DIR)
message(FATAL_ERROR "Could not find DirectX SDK Include") message(FATAL_ERROR "Could not find DirectX SDK Include")
endif (DIRECTX_INCLUDE_DIR) endif (DIRECTX_INCLUDE_DIR)
# dxhint isn't meant to be the hard-coded DIRECTX_LIBRARY_DIR, we're just
find_path(DIRECTX_LIBRARY_DIR dxguid.lib # suggesting it as a hint to the next find_path(). The version is embedded
"$ENV{DXSDK_DIR}/Lib/x86" # in the DIRECTX_INCLUDE_DIR path string after Include and Lib, which is why
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2010)/Lib/x86" # we don't just append a relative path: if there are multiple versions
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2009)/Lib/x86" # installed on the host, we need to be sure we're using THE SAME version.
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2009)/Lib/x86" string(REPLACE "/Include/" "/Lib/" dxhint "${DIRECTX_INCLUDE_DIR}")
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2008)/Lib/x86" if (ADDRESS_SIZE EQUAL 32)
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (June 2008)/Lib/x86" set(archdir x86)
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (March 2008)/Lib/x86" else()
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (November 2007)/Lib/x86" set(archdir x64)
"$ENV{PROGRAMFILES}/Microsoft DirectX SDK (August 2007)/Lib/x86" endif()
"C:/DX90SDK/Lib" string(APPEND dxhint "/${archdir}")
"$ENV{PROGRAMFILES}/DX90SDK/Lib" find_path(DIRECTX_LIBRARY_DIR dxguid.lib HINTS "${dxhint}")
)
if (DIRECTX_LIBRARY_DIR) if (DIRECTX_LIBRARY_DIR)
if (DIRECTX_FIND_QUIETLY) if (NOT DIRECTX_FIND_QUIETLY)
message(STATUS "Found DirectX include: ${DIRECTX_LIBRARY_DIR}") message(STATUS "Found DirectX library: ${DIRECTX_LIBRARY_DIR}")
endif (DIRECTX_FIND_QUIETLY) endif (NOT DIRECTX_FIND_QUIETLY)
else (DIRECTX_LIBRARY_DIR) else (DIRECTX_LIBRARY_DIR)
message(FATAL_ERROR "Could not find DirectX SDK Libraries") message(FATAL_ERROR "Could not find DirectX SDK Libraries")
endif (DIRECTX_LIBRARY_DIR) endif (DIRECTX_LIBRARY_DIR)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment