Linux support. (#4)

* Initial Linux attempt.

* Fix DXIL library linkage.

* Compiling and running on Linux.

* Fix compilation error on Windows.

* Convert almost all dependencies to submodules.
This commit is contained in:
Skyth (Asilkan) 2024-12-21 00:51:39 +03:00 committed by GitHub
parent 4b69741e19
commit 66c618cc72
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 41 additions and 15 deletions

9
.gitmodules vendored
View file

@ -1,3 +1,12 @@
[submodule "thirdparty/smol-v"]
path = thirdparty/smol-v
url = https://github.com/aras-p/smol-v
[submodule "thirdparty/zstd"]
path = thirdparty/zstd
url = https://github.com/facebook/zstd.git
[submodule "thirdparty/xxHash"]
path = thirdparty/xxHash
url = https://github.com/Cyan4973/xxHash.git
[submodule "thirdparty/fmt"]
path = thirdparty/fmt
url = https://github.com/fmtlib/fmt.git

View file

@ -3,6 +3,9 @@ cmake_minimum_required(VERSION 3.20)
include($ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
set(CMAKE_CXX_STANDARD 17)
project(ShaderRecomp-ALL)
project("ShaderRecomp-ALL")
add_subdirectory(ShaderRecomp)
set(SHADER_RECOMP_THIRDPARTY_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty")
add_subdirectory(${SHADER_RECOMP_THIRDPARTY_ROOT})
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/ShaderRecomp")

View file

@ -19,14 +19,12 @@ add_executable(ShaderRecomp
"${SMOLV_SOURCE_DIR}/smolv.cpp")
find_package(directx-dxc CONFIG REQUIRED)
find_package(xxhash CONFIG REQUIRED)
find_package(zstd CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
target_link_libraries(ShaderRecomp PRIVATE
Microsoft::DirectXShaderCompiler
Microsoft::DXIL
xxHash::xxhash
$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>
libzstd_static
fmt::fmt)
target_include_directories(ShaderRecomp PRIVATE ${SMOLV_SOURCE_DIR})
@ -34,13 +32,15 @@ target_include_directories(ShaderRecomp PRIVATE ${SMOLV_SOURCE_DIR})
target_precompile_headers(ShaderRecomp PRIVATE pch.h)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(ShaderRecomp PRIVATE -Wno-switch -Wno-unused-variable)
target_compile_options(ShaderRecomp PRIVATE -Wno-switch -Wno-unused-variable -Wno-null-arithmetic -fms-extensions)
endif()
target_compile_definitions(ShaderRecomp PRIVATE _CRT_SECURE_NO_WARNINGS)
if (WIN32)
target_compile_definitions(ShaderRecomp PRIVATE _CRT_SECURE_NO_WARNINGS)
find_file(DIRECTX_DXIL_LIBRARY "dxil.dll")
file(COPY ${DIRECTX_DXIL_LIBRARY} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
if (SHADER_RECOMP_DXIL)
target_compile_definitions(ShaderRecomp PRIVATE SHADER_RECOMP_DXIL)
endif()
file(COPY ${PACKAGE_PREFIX_DIR}/bin/dxil.dll DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

View file

@ -1,6 +1,9 @@
#pragma once
#ifdef _WIN32
#include <Windows.h>
#endif
#include <dxcapi.h>
#include <bit>

11
thirdparty/CMakeLists.txt vendored Normal file
View file

@ -0,0 +1,11 @@
if (NOT TARGET fmt::fmt)
add_subdirectory("${SHADER_RECOMP_THIRDPARTY_ROOT}/fmt")
endif()
if (NOT TARGET xxHash::xxhash)
add_subdirectory("${SHADER_RECOMP_THIRDPARTY_ROOT}/xxHash/cmake_unofficial")
endif()
if (NOT TARGET libzstd)
add_subdirectory("${SHADER_RECOMP_THIRDPARTY_ROOT}/zstd/build/cmake")
endif()

1
thirdparty/fmt vendored Submodule

@ -0,0 +1 @@
Subproject commit 873670ba3f9e7bc77ec2c1c94b04f1f8bef77e9f

1
thirdparty/xxHash vendored Submodule

@ -0,0 +1 @@
Subproject commit 2bf8313b934633b2a5b7e8fd239645b85e10c852

1
thirdparty/zstd vendored Submodule

@ -0,0 +1 @@
Subproject commit f7a8bb1263448e5028aceeba606a08fe3809550f

View file

@ -1,9 +1,6 @@
{
"builtin-baseline": "e63bd09dc0b7204467705c1c7c71d0e2a3f8860b",
"builtin-baseline": "b322364f06308bdd24823f9d8f03fe0cc86fd46f",
"dependencies": [
"directx-dxc",
"fmt",
"xxhash",
"zstd"
"directx-dxc"
]
}