diff --git a/.gitmodules b/.gitmodules index 47afc81..8401190 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 0caffec..41360a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/ShaderRecomp/CMakeLists.txt b/ShaderRecomp/CMakeLists.txt index 7bfbc0d..bec1ab6 100644 --- a/ShaderRecomp/CMakeLists.txt +++ b/ShaderRecomp/CMakeLists.txt @@ -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 - $,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}) diff --git a/ShaderRecomp/pch.h b/ShaderRecomp/pch.h index eca8d39..e59682c 100644 --- a/ShaderRecomp/pch.h +++ b/ShaderRecomp/pch.h @@ -1,6 +1,9 @@ #pragma once +#ifdef _WIN32 #include +#endif + #include #include diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt new file mode 100644 index 0000000..9179251 --- /dev/null +++ b/thirdparty/CMakeLists.txt @@ -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() diff --git a/thirdparty/fmt b/thirdparty/fmt new file mode 160000 index 0000000..873670b --- /dev/null +++ b/thirdparty/fmt @@ -0,0 +1 @@ +Subproject commit 873670ba3f9e7bc77ec2c1c94b04f1f8bef77e9f diff --git a/thirdparty/xxHash b/thirdparty/xxHash new file mode 160000 index 0000000..2bf8313 --- /dev/null +++ b/thirdparty/xxHash @@ -0,0 +1 @@ +Subproject commit 2bf8313b934633b2a5b7e8fd239645b85e10c852 diff --git a/thirdparty/zstd b/thirdparty/zstd new file mode 160000 index 0000000..f7a8bb1 --- /dev/null +++ b/thirdparty/zstd @@ -0,0 +1 @@ +Subproject commit f7a8bb1263448e5028aceeba606a08fe3809550f diff --git a/vcpkg.json b/vcpkg.json index 5e2a2e0..1a3a8f0 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,9 +1,6 @@ { - "builtin-baseline": "e63bd09dc0b7204467705c1c7c71d0e2a3f8860b", + "builtin-baseline": "b322364f06308bdd24823f9d8f03fe0cc86fd46f", "dependencies": [ - "directx-dxc", - "fmt", - "xxhash", - "zstd" + "directx-dxc" ] }