FindTAEF.cmake 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # Find the TAEF path that supports x86 and x64.
  2. get_filename_component(WINDOWS_KIT_10_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE CACHE)
  3. get_filename_component(WINDOWS_KIT_81_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot81]" ABSOLUTE CACHE)
  4. # Find the TAEF path, it will typically look something like this.
  5. # "C:\Program Files (x86)\Windows Kits\8.1\Testing\Development\inc"
  6. set(pfx86 "programfiles(x86)") # Work around behavior for environment names allows chars.
  7. find_path(TAEF_INCLUDE_DIR # Set variable TAEF_INCLUDE_DIR
  8. Wex.Common.h # Find a path with Wex.Common.h
  9. HINTS "$ENV{TAEF_PATH}/../../../Include"
  10. HINTS "$ENV{TAEF_PATH}/../../../Development/inc"
  11. HINTS "${CMAKE_SOURCE_DIR}/external/taef/build/Include"
  12. HINTS "${WINDOWS_KIT_10_PATH}/Testing/Development/inc"
  13. HINTS "${WINDOWS_KIT_81_PATH}/Testing/Development/inc"
  14. DOC "path to TAEF header files"
  15. HINTS
  16. )
  17. macro(find_taef_libraries targetplatform)
  18. set(TAEF_LIBRARIES)
  19. foreach(L Te.Common.lib Wex.Common.lib Wex.Logger.lib)
  20. find_library(TAEF_LIB_${L} NAMES ${L}
  21. HINTS ${TAEF_INCLUDE_DIR}/../Library/${targetplatform}
  22. HINTS ${TAEF_INCLUDE_DIR}/../lib/${targetplatform})
  23. set(TAEF_LIBRARIES ${TAEF_LIBRARIES} ${TAEF_LIB_${L}})
  24. endforeach()
  25. set(TAEF_COMMON_LIBRARY ${TAEF_LIB_Te.Common.lib})
  26. endmacro(find_taef_libraries)
  27. if ("${DXC_BUILD_ARCH}" STREQUAL "x64" )
  28. find_taef_libraries(x64)
  29. elseif (CMAKE_GENERATOR MATCHES "Visual Studio.*ARM" OR "${DXC_BUILD_ARCH}" STREQUAL "ARM")
  30. find_taef_libraries(arm)
  31. elseif (CMAKE_GENERATOR MATCHES "Visual Studio.*ARM64" OR "${DXC_BUILD_ARCH}" MATCHES "ARM64.*")
  32. find_taef_libraries(arm64)
  33. elseif ("${DXC_BUILD_ARCH}" STREQUAL "Win32" )
  34. find_taef_libraries(x86)
  35. endif ("${DXC_BUILD_ARCH}" STREQUAL "x64" )
  36. set(TAEF_INCLUDE_DIRS ${TAEF_INCLUDE_DIR})
  37. # Get TAEF binaries path from the header location
  38. set(TAEF_NUGET_BIN ${TAEF_INCLUDE_DIR}/../Binaries/Release)
  39. set(TAEF_SDK_BIN ${TAEF_INCLUDE_DIR}/../../Runtimes/TAEF)
  40. if(EXISTS "${TAEF_NUGET_BIN}/x64/te.exe" AND EXISTS "${TAEF_NUGET_BIN}/x86/te.exe")
  41. set(TAEF_BIN_DIR "${TAEF_NUGET_BIN}")
  42. elseif(EXISTS "${TAEF_SDK_BIN}/x64/te.exe" AND EXISTS "${TAEF_SDK_BIN}/x86/te.exe")
  43. set(TAEF_BIN_DIR "${TAEF_SDK_BIN}")
  44. elseif(EXISTS "${WINDOWS_KIT_10_PATH}")
  45. message(ERROR "Unable to find TAEF binaries under Windows 10 SDK.")
  46. elseif(EXISTS "${WINDOWS_KIT_81_PATH}")
  47. message(ERROR "Unable to find TAEF binaries under Windows 8.1 or 10 SDK.")
  48. else()
  49. message(ERROR "Unable to find TAEF binaries or Windows 8.1 or 10 SDK.")
  50. endif()
  51. include(FindPackageHandleStandardArgs)
  52. # handle the QUIETLY and REQUIRED arguments and set TAEF_FOUND to TRUE
  53. # if all listed variables are TRUE
  54. find_package_handle_standard_args(TAEF DEFAULT_MSG
  55. TAEF_COMMON_LIBRARY TAEF_INCLUDE_DIR)
  56. mark_as_advanced(TAEF_INCLUDE_DIR TAEF_LIBRARY)