From c9abdcc806b330ca4a8b7c21e8529da3516f870c Mon Sep 17 00:00:00 2001 From: tobil4sk Date: Sun, 25 Sep 2022 18:15:43 +0100 Subject: [PATCH] [cmake] Add dx12.hdll to build Also remove FindDirectX.cmake, as directx should now be found in the Windows SDK. --- libs/CMakeLists.txt | 5 +- libs/directx/CMakeLists.txt | 73 +++++++++++++------- other/cmake/FindDirectX.cmake | 126 ---------------------------------- 3 files changed, 50 insertions(+), 154 deletions(-) delete mode 100644 other/cmake/FindDirectX.cmake diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt index ed2cccbcd..8fb78e802 100644 --- a/libs/CMakeLists.txt +++ b/libs/CMakeLists.txt @@ -10,10 +10,7 @@ function(set_as_hdll target) endfunction() if(WIN32) - option(WITH_DIRECTX "Build directx.hdll." ON) - if(WITH_DIRECTX) - add_subdirectory(directx) - endif() + add_subdirectory(directx) endif() option(WITH_FMT "Build fmt.hdll." ON) diff --git a/libs/directx/CMakeLists.txt b/libs/directx/CMakeLists.txt index d1c45ee6a..e537fc9fd 100644 --- a/libs/directx/CMakeLists.txt +++ b/libs/directx/CMakeLists.txt @@ -1,24 +1,49 @@ -find_package(DirectX) - -add_library(directx.hdll SHARED - directx.cpp - gamecontroller.c - window.c -) - -set_as_hdll(directx) - -target_link_libraries(directx.hdll - libhl - d3d11 - dxgi - d3dcompiler - xinput9_1_0 - dinput8 -) - -install( - TARGETS - directx.hdll - DESTINATION ${HDLL_DESTINATION} -) +option(WITH_DIRECTX "Build directx.hdll." ON) + +if(WITH_DIRECTX) + add_library(directx.hdll SHARED + directx.cpp + gamecontroller.c + window.c + ) + + set_as_hdll(directx) + + target_link_libraries(directx.hdll + libhl + d3d11 + dxgi + d3dcompiler + xinput9_1_0 + dinput8 + ) + + install( + TARGETS + directx.hdll + DESTINATION ${HDLL_DESTINATION} + ) +endif() + +option(WITH_DX12 "Build dx12.hdll." ON) + +if(WITH_DX12) + add_library(dx12.hdll SHARED + dx12.cpp + ) + + set_as_hdll(dx12) + + target_link_libraries(dx12.hdll + libhl + D3D12 + dxgi + dxcompiler + ) + + install( + TARGETS + dx12.hdll + DESTINATION ${HDLL_DESTINATION} + ) +endif() diff --git a/other/cmake/FindDirectX.cmake b/other/cmake/FindDirectX.cmake deleted file mode 100644 index 869c14619..000000000 --- a/other/cmake/FindDirectX.cmake +++ /dev/null @@ -1,126 +0,0 @@ -# TAKEN FROM HERE: https://github.com/apitrace/apitrace/blob/master/cmake/FindDirectX.cmake -# - try to find DirectX include directories and libraries -# -# Once done this will define: -# -# DirectX_XYZ_INCLUDE_FOUND - system has the include for the XYZ API -# DirectX_XYZ_INCLUDE_DIR - include directory for the XYZ API -# -# Where XYZ can be any of: -# -# DDRAW -# D3D -# D3D8 -# D3D9 -# D3D10 -# D3D10_1 -# D3D11 -# D3D11_1 -# D3D11_2 -# D2D1 -# - - -include (CheckIncludeFileCXX) -include (FindPackageMessage) - - -if (WIN32) - - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set (DirectX_ARCHITECTURE x64) - else () - set (DirectX_ARCHITECTURE x86) - endif () - - # Can't use "$ENV{ProgramFiles(x86)}" to avoid violating CMP0053. See - # http://public.kitware.com/pipermail/cmake-developers/2014-October/023190.html - set (ProgramFiles_x86 "ProgramFiles(x86)") - if ("$ENV{${ProgramFiles_x86}}") - set (ProgramFiles "$ENV{${ProgramFiles_x86}}") - else () - set (ProgramFiles "$ENV{ProgramFiles}") - endif () - - find_path (DirectX_ROOT_DIR - Include/d3d9.h - PATHS - "$ENV{DXSDK_DIR}" - "${ProgramFiles}/Microsoft DirectX SDK (June 2010)" - "${ProgramFiles}/Microsoft DirectX SDK (February 2010)" - "${ProgramFiles}/Microsoft DirectX SDK (March 2009)" - "${ProgramFiles}/Microsoft DirectX SDK (August 2008)" - "${ProgramFiles}/Microsoft DirectX SDK (June 2008)" - "${ProgramFiles}/Microsoft DirectX SDK (March 2008)" - "${ProgramFiles}/Microsoft DirectX SDK (November 2007)" - "${ProgramFiles}/Microsoft DirectX SDK (August 2007)" - "${ProgramFiles}/Microsoft DirectX SDK" - DOC "DirectX SDK root directory" - ) - if (DirectX_ROOT_DIR) - set (DirectX_INC_SEARCH_PATH "${DirectX_ROOT_DIR}/Include") - set (DirectX_LIB_SEARCH_PATH "${DirectX_ROOT_DIR}/Lib/${DirectX_ARCHITECTURE}") - set (DirectX_BIN_SEARCH_PATH "${DirectX_ROOT_DIR}/Utilities/bin/x86") - endif () - - # With VS 2011 and Windows 8 SDK, the DirectX SDK is included as part of - # the Windows SDK. - # - # See also: - # - http://msdn.microsoft.com/en-us/library/windows/desktop/ee663275.aspx - if (MSVC) - set (USE_WINSDK_HEADERS TRUE) - endif () - - # Find a header in the DirectX SDK - macro (find_dxsdk_header var_name header) - set (include_dir_var "DirectX_${var_name}_INCLUDE_DIR") - set (include_found_var "DirectX_${var_name}_INCLUDE_FOUND") - find_path (${include_dir_var} ${header} - HINTS ${DirectX_INC_SEARCH_PATH} - DOC "The directory where ${header} resides" - CMAKE_FIND_ROOT_PATH_BOTH - ) - if (${include_dir_var}) - set (${include_found_var} TRUE) - find_package_message (${var_name}_INC "Found ${header} header: ${${include_dir_var}}/${header}" "[${${include_dir_var}}]") - endif () - mark_as_advanced (${include_found_var}) - endmacro () - - # Find a header in the Windows SDK - macro (find_winsdk_header var_name header) - if (USE_WINSDK_HEADERS) - # Windows SDK - set (include_dir_var "DirectX_${var_name}_INCLUDE_DIR") - set (include_found_var "DirectX_${var_name}_INCLUDE_FOUND") - check_include_file_cxx (${header} ${include_found_var}) - set (${include_dir_var}) - mark_as_advanced (${include_found_var}) - else () - find_dxsdk_header (${var_name} ${header}) - endif () - endmacro () - - find_winsdk_header (D3D d3d.h) - - if (MSVC) - set (DirectX_D3D8_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/dxsdk_aug2007) - set (DirectX_D3D8_INCLUDE_FOUND TRUE) - mark_as_advanced (DirectX_D3D8_INCLUDE_FOUND) - else () - find_dxsdk_header (D3D8 d3d8.h) - endif () - - find_winsdk_header (D3D9 d3d9.h) - - find_winsdk_header (D3D11_4 d3d11_4.h) - - find_winsdk_header (D2D1_1 d2d1_1.h) - - find_program (DirectX_FXC_EXECUTABLE fxc - HINTS ${DirectX_BIN_SEARCH_PATH} - DOC "Path to fxc.exe executable." - ) - -endif ()