mirror of
https://github.com/RPCSX/rpcsx.git
synced 2024-11-26 21:00:35 +00:00
cmake: try system libraries first (#71)
This commit is contained in:
parent
71c2185bf6
commit
7e78907829
2
.github/workflows/rpcsx.yml
vendored
2
.github/workflows/rpcsx.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
||||
sudo apt update
|
||||
sudo apt install -y cmake build-essential libunwind-dev \
|
||||
libglfw3-dev libvulkan-dev vulkan-validationlayers-dev \
|
||||
spirv-tools glslang-tools libspirv-cross-c-shared-dev libsox-dev
|
||||
libsox-dev
|
||||
VULKANVER=1.3.259
|
||||
curl -sSfLo Vulkan-Headers.tar.gz https://github.com/KhronosGroup/Vulkan-Headers/archive/v${VULKANVER}.tar.gz
|
||||
tar -xf Vulkan-Headers*.tar.gz
|
||||
|
55
3rdparty/CMakeLists.txt
vendored
55
3rdparty/CMakeLists.txt
vendored
@ -1,21 +1,40 @@
|
||||
add_subdirectory(crypto)
|
||||
add_subdirectory(xbyak)
|
||||
add_subdirectory(SPIRV-Headers)
|
||||
add_subdirectory(SPIRV-Tools)
|
||||
|
||||
set(SPIRV_CROSS_SHARED on)
|
||||
set(SPIRV_CROSS_STATIC on)
|
||||
set(SPIRV_CROSS_ENABLE_GLSL on)
|
||||
set(SPIRV_CROSS_ENABLE_HLSL off)
|
||||
set(SPIRV_CROSS_ENABLE_MSL off)
|
||||
set(SPIRV_CROSS_ENABLE_CPP off)
|
||||
set(SPIRV_CROSS_ENABLE_REFLECT off)
|
||||
set(SPIRV_CROSS_ENABLE_C_API off)
|
||||
set(SPIRV_CROSS_ENABLE_UTIL off)
|
||||
set(SPIRV_CROSS_CLI off)
|
||||
set(SPIRV_CROSS_ENABLE_TESTS off)
|
||||
set(SPIRV_CROSS_SKIP_INSTALL on)
|
||||
add_subdirectory(SPIRV-Cross)
|
||||
if(NOT xbyak_FOUND)
|
||||
add_subdirectory(xbyak)
|
||||
endif()
|
||||
|
||||
add_subdirectory(glslang)
|
||||
add_subdirectory(json)
|
||||
if(NOT SPIRV-Headers_FOUND)
|
||||
add_subdirectory(SPIRV-Headers)
|
||||
endif()
|
||||
|
||||
if(NOT SPIRV-Tools-opt_FOUND)
|
||||
add_subdirectory(SPIRV-Tools)
|
||||
endif()
|
||||
|
||||
if(NOT SPIRV-Cross_FOUND)
|
||||
set(SPIRV_CROSS_SHARED on)
|
||||
set(SPIRV_CROSS_STATIC on)
|
||||
set(SPIRV_CROSS_ENABLE_GLSL on)
|
||||
set(SPIRV_CROSS_ENABLE_HLSL off)
|
||||
set(SPIRV_CROSS_ENABLE_MSL off)
|
||||
set(SPIRV_CROSS_ENABLE_CPP off)
|
||||
set(SPIRV_CROSS_ENABLE_REFLECT off)
|
||||
set(SPIRV_CROSS_ENABLE_C_API off)
|
||||
set(SPIRV_CROSS_ENABLE_UTIL off)
|
||||
set(SPIRV_CROSS_CLI off)
|
||||
set(SPIRV_CROSS_ENABLE_TESTS off)
|
||||
set(SPIRV_CROSS_SKIP_INSTALL on)
|
||||
add_subdirectory(SPIRV-Cross)
|
||||
endif()
|
||||
|
||||
if(NOT glslang_FOUND)
|
||||
add_subdirectory(glslang)
|
||||
if(NOT TARGET glslang::glslang-standalone)
|
||||
add_executable(glslang::glslang-standalone ALIAS glslang-standalone)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT nlohmann_json_FOUND)
|
||||
add_subdirectory(json)
|
||||
endif()
|
||||
|
@ -5,6 +5,18 @@ set(CMAKE_CXX_EXTENSIONS off)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
find_package(nlohmann_json CONFIG)
|
||||
find_package(SPIRV-Cross 1.6 MODULE)
|
||||
find_package(SPIRV-Tools-opt MODULE)
|
||||
find_package(xbyak CONFIG)
|
||||
|
||||
if(SPIRV-Tools-opt_FOUND)
|
||||
find_package(glslang CONFIG)
|
||||
find_package(SPIRV-Headers CONFIG)
|
||||
endif()
|
||||
|
||||
add_subdirectory(3rdparty EXCLUDE_FROM_ALL)
|
||||
|
||||
function(add_precompiled_vulkan_spirv target)
|
||||
@ -29,8 +41,8 @@ function(add_precompiled_vulkan_spirv target)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${outputpath}
|
||||
COMMAND $<TARGET_FILE:glslang-standalone> -V --target-env vulkan1.3 --vn "${varname}" -o "${outputpath}" "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${input}" glslang-standalone
|
||||
COMMAND $<TARGET_FILE:glslang::glslang-standalone> -V --target-env vulkan1.3 --vn "${varname}" -o "${outputpath}" "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
|
||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${input}" glslang::glslang-standalone
|
||||
COMMENT "Generating ${outputname}..."
|
||||
)
|
||||
|
||||
|
51
cmake/FindSPIRV-Cross.cmake
Normal file
51
cmake/FindSPIRV-Cross.cmake
Normal file
@ -0,0 +1,51 @@
|
||||
find_library(SPIRV-Cross_core_LIBRARY NAMES spirv-cross-core)
|
||||
find_library(SPIRV-Cross_glsl_LIBRARY NAMES spirv-cross-glsl)
|
||||
|
||||
find_path(SPIRV-Cross_INCLUDE_DIR NAMES spirv.hpp PATH_SUFFIXES spirv_cross)
|
||||
if(SPIRV-Cross_INCLUDE_DIR)
|
||||
if(EXISTS "${SPIRV-Cross_INCLUDE_DIR}/spirv.hpp")
|
||||
file(STRINGS "${SPIRV-Cross_INCLUDE_DIR}/spirv.hpp" _ver_line
|
||||
REGEX "^[\t ]*#define[\t ]+SPV_VERSION[\t ]+0x[0-9]+"
|
||||
LIMIT_COUNT 1
|
||||
)
|
||||
string(REGEX MATCH "0x[0-9]+" _ver "${_ver_line}")
|
||||
math(EXPR SPIRV-Cross_MAJOR_VERSION "${_ver} >> 16")
|
||||
math(EXPR SPIRV-Cross_MINOR_VERSION "${_ver} >> 8 & 0xFF")
|
||||
set(SPIRV-Cross_VERSION
|
||||
"${SPIRV-Cross_MAJOR_VERSION}.${SPIRV-Cross_MINOR_VERSION}"
|
||||
)
|
||||
unset(_ver_line)
|
||||
unset(_ver)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(SPIRV-Cross
|
||||
REQUIRED_VARS
|
||||
SPIRV-Cross_INCLUDE_DIR
|
||||
SPIRV-Cross_core_LIBRARY
|
||||
SPIRV-Cross_glsl_LIBRARY
|
||||
VERSION_VAR SPIRV-Cross_VERSION
|
||||
)
|
||||
|
||||
if(SPIRV-Cross_FOUND AND NOT TARGET spirv-cross-core)
|
||||
add_library(spirv-cross-core UNKNOWN IMPORTED)
|
||||
set_target_properties(spirv-cross-core PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SPIRV-Cross_INCLUDE_DIR}"
|
||||
IMPORTED_LOCATION "${SPIRV-Cross_core_LIBRARY}"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(SPIRV-Cross_FOUND AND NOT TARGET spirv-cross-glsl)
|
||||
add_library(spirv-cross-glsl UNKNOWN IMPORTED)
|
||||
set_target_properties(spirv-cross-glsl PROPERTIES
|
||||
IMPORTED_LOCATION "${SPIRV-Cross_glsl_LIBRARY}"
|
||||
)
|
||||
target_link_libraries(spirv-cross-glsl INTERFACE spirv-cross-core)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(
|
||||
SPIRV-Cross_INCLUDE_DIR
|
||||
SPIRV-Cross_core_LIBRARY
|
||||
SPIRV-Cross_glsl_LIBRARY
|
||||
)
|
17
cmake/FindSPIRV-Tools-opt.cmake
Normal file
17
cmake/FindSPIRV-Tools-opt.cmake
Normal file
@ -0,0 +1,17 @@
|
||||
include(CheckCXXSymbolExists)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
set(CMAKE_REQUIRED_LIBRARIES SPIRV-Tools-opt)
|
||||
check_cxx_symbol_exists(spvtools::CreateBitCastCombinePass
|
||||
"spirv-tools/optimizer.hpp"
|
||||
HAVE_CREATE_BIT_CAST_COMBINE_PASS
|
||||
)
|
||||
|
||||
if(HAVE_CREATE_BIT_CAST_COMBINE_PASS)
|
||||
find_package(SPIRV-Tools-opt QUIET CONFIG)
|
||||
find_package_handle_standard_args(SPIRV-Tools-opt CONFIG_MODE)
|
||||
else()
|
||||
find_package_handle_standard_args(SPIRV-Tools-opt
|
||||
REQUIRED_VARS HAVE_CREATE_BIT_CAST_COMBINE_PASS
|
||||
)
|
||||
endif()
|
23
cmake/Findlibunwind.cmake
Normal file
23
cmake/Findlibunwind.cmake
Normal file
@ -0,0 +1,23 @@
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_search_module(UNWIND QUIET IMPORTED_TARGET libunwind)
|
||||
|
||||
find_library(libunwind_x86_64_LIBRARY
|
||||
NAMES unwind-x86_64
|
||||
HINTS "${UNWIND_LIBRARY_DIRS}"
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(libunwind
|
||||
REQUIRED_VARS UNWIND_LINK_LIBRARIES libunwind_x86_64_LIBRARY
|
||||
VERSION_VAR UNWIND_VERSION
|
||||
)
|
||||
|
||||
if(libunwind_FOUND AND NOT TARGET libunwind::unwind-x86_64)
|
||||
add_library(libunwind::unwind-x86_64 UNKNOWN IMPORTED)
|
||||
set_target_properties(libunwind::unwind-x86_64 PROPERTIES
|
||||
IMPORTED_LOCATION "${libunwind_x86_64_LIBRARY}"
|
||||
)
|
||||
target_link_libraries(libunwind::unwind-x86_64 INTERFACE PkgConfig::UNWIND)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(libunwind_x86_64_LIBRARY)
|
12
cmake/Findsox.cmake
Normal file
12
cmake/Findsox.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_search_module(SOX QUIET IMPORTED_TARGET sox)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(sox
|
||||
REQUIRED_VARS SOX_LINK_LIBRARIES
|
||||
VERSION_VAR SOX_VERSION
|
||||
)
|
||||
|
||||
if(sox_FOUND AND NOT TARGET sox::sox)
|
||||
add_library(sox::sox ALIAS PkgConfig::SOX)
|
||||
endif()
|
@ -9,11 +9,6 @@ add_precompiled_vulkan_spirv(${PROJECT_NAME}-shaders
|
||||
src/rect_list.geom.glsl
|
||||
)
|
||||
|
||||
find_package(SPIRV-Tools REQUIRED CONFIG)
|
||||
find_package(SPIRV-Tools-opt REQUIRED CONFIG)
|
||||
find_package(spirv_cross_core REQUIRED CONFIG)
|
||||
find_package(spirv_cross_glsl REQUIRED CONFIG)
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC ${INCLUDE} ${SRC})
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
@ -24,7 +19,7 @@ PUBLIC
|
||||
util
|
||||
SPIRV-Tools
|
||||
SPIRV-Tools-opt
|
||||
spirv-cross-glsl
|
||||
$<$<CONFIG:Debug>:spirv-cross-glsl>
|
||||
|
||||
PRIVATE
|
||||
${PROJECT_NAME}-shaders
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <vulkan/vulkan_core.h>
|
||||
|
||||
#ifndef NDEBUG
|
||||
#include <spirv_cross/spirv_glsl.hpp>
|
||||
#include <spirv_glsl.hpp>
|
||||
#endif
|
||||
|
||||
using namespace amdgpu;
|
||||
|
@ -15,7 +15,7 @@ set(SRC
|
||||
)
|
||||
|
||||
add_library(${PROJECT_NAME} STATIC ${INCLUDE} ${SRC})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC spirv amdgpu::base)
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC spirv amdgpu::base spirv-cross-core)
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC include PRIVATE include/${PROJECT_PATH})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
|
||||
add_library(amdgpu::shader ALIAS ${PROJECT_NAME})
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include <spirv/GLSL.std.450.h>
|
||||
#include <spirv/spirv-instruction.hpp>
|
||||
#include <spirv_cross/spirv.hpp>
|
||||
#include <spirv.hpp>
|
||||
#include <util/unreachable.hpp>
|
||||
|
||||
#include <bit>
|
||||
|
@ -1,5 +1,7 @@
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE on)
|
||||
|
||||
find_package(sox REQUIRED)
|
||||
|
||||
add_library(obj.orbis-utils-ipc OBJECT
|
||||
src/utils/SharedMutex.cpp
|
||||
src/utils/SharedCV.cpp
|
||||
@ -71,7 +73,7 @@ add_library(obj.orbis-kernel OBJECT
|
||||
src/utils/Logs.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(obj.orbis-kernel PUBLIC orbis::kernel::config $<TARGET_OBJECTS:obj.orbis-utils-ipc> sox)
|
||||
target_link_libraries(obj.orbis-kernel PUBLIC orbis::kernel::config $<TARGET_OBJECTS:obj.orbis-utils-ipc> sox::sox)
|
||||
|
||||
target_include_directories(obj.orbis-kernel
|
||||
PUBLIC
|
||||
|
@ -1,3 +1,5 @@
|
||||
find_package(libunwind REQUIRED)
|
||||
|
||||
add_library(standalone-config INTERFACE)
|
||||
target_include_directories(standalone-config INTERFACE orbis-kernel-config)
|
||||
add_library(orbis::kernel::config ALIAS standalone-config)
|
||||
@ -62,7 +64,7 @@ add_executable(rpcsx-os
|
||||
)
|
||||
|
||||
target_include_directories(rpcsx-os PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
target_link_libraries(rpcsx-os PUBLIC orbis::kernel amdgpu::bridge rx libcrypto unwind unwind-x86_64 xbyak)
|
||||
target_link_libraries(rpcsx-os PUBLIC orbis::kernel amdgpu::bridge rx libcrypto libunwind::unwind-x86_64 xbyak::xbyak)
|
||||
target_link_options(rpcsx-os PUBLIC "LINKER:-Ttext-segment,0x0000010000000000")
|
||||
target_compile_options(rpcsx-os PRIVATE "-mfsgsbase")
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
add_executable(spv-gen spv-gen.cpp)
|
||||
target_link_libraries(spv-gen PUBLIC nlohmann_json)
|
||||
target_link_libraries(spv-gen PUBLIC nlohmann_json::nlohmann_json)
|
||||
|
Loading…
Reference in New Issue
Block a user