From 640ca59dcd244e85a890734b7536acc55efe3254 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Wed, 22 May 2024 13:54:22 +0200 Subject: [PATCH 01/12] CMake changes --- 3rdParty/glfw/CMakeLists.txt | 3 ++- 3rdParty/glm/CMakeLists.txt | 21 +++++++++++++-------- 3rdParty/imgui/CMakeLists.txt | 25 ++----------------------- CMakeLists.txt | 22 ++++++---------------- openVulkanoCpp/Math/Math.hpp | 1 + 5 files changed, 24 insertions(+), 48 deletions(-) diff --git a/3rdParty/glfw/CMakeLists.txt b/3rdParty/glfw/CMakeLists.txt index 15ccd6c..0ff8d20 100644 --- a/3rdParty/glfw/CMakeLists.txt +++ b/3rdParty/glfw/CMakeLists.txt @@ -13,4 +13,5 @@ FetchContent_Declare( ) set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE) -FetchContent_MakeAvailable(glfw) \ No newline at end of file +FetchContent_MakeAvailable(glfw) +set(glfw_FOUND ON PARENT_SCOPE) \ No newline at end of file diff --git a/3rdParty/glm/CMakeLists.txt b/3rdParty/glm/CMakeLists.txt index 6886ec0..bab40a1 100644 --- a/3rdParty/glm/CMakeLists.txt +++ b/3rdParty/glm/CMakeLists.txt @@ -8,16 +8,21 @@ FetchContent_Declare( glm EXCLUDE_FROM_ALL GIT_REPOSITORY ${GLM_REPO} - GIT_TAG 0.9.9.8 + GIT_TAG 1.0.1 GIT_SHALLOW TRUE ) set(GLM_TEST_ENABLE OFF CACHE BOOL "" FORCE) FetchContent_MakeAvailable(glm) -add_compile_definitions(GLM_FORCE_SILENT_WARNINGS) -if (NOT ANDROID AND NOT IOS) - # TODO check target architecture first - add_compile_definitions(GLM_FORCE_AVX2) -else () - add_compile_definitions(GLM_FORCE_INTRINSICS) -endif () \ No newline at end of file +function(SetGlmDefines TARGET) + target_compile_definitions(${TARGET} PUBLIC GLM_FORCE_SILENT_WARNINGS) + target_compile_definitions(${TARGET} PUBLIC GLM_ENABLE_EXPERIMENTAL) + target_compile_definitions(${TARGET} PUBLIC GLM_FORCE_ALIGNED_GENTYPES) + + if (NOT ANDROID AND NOT IOS) + # TODO check target architecture first + target_compile_definitions(${TARGET} PUBLIC GLM_FORCE_AVX2) + else () + target_compile_definitions(${TARGET} PUBLIC GLM_FORCE_INTRINSICS) + endif () +endfunction() \ No newline at end of file diff --git a/3rdParty/imgui/CMakeLists.txt b/3rdParty/imgui/CMakeLists.txt index 1682ca7..5f0ae37 100644 --- a/3rdParty/imgui/CMakeLists.txt +++ b/3rdParty/imgui/CMakeLists.txt @@ -24,33 +24,12 @@ add_library(imgui_internal STATIC ${IMGUI_SRC_DIR}/backends/imgui_impl_vulkan.cpp ) -find_package(glfw3) -if (glfw3_FOUND) +if (glfw_FOUND) target_sources(imgui_internal PRIVATE ${IMGUI_SRC_DIR}/backends/imgui_impl_glfw.cpp) target_link_libraries(imgui_internal PUBLIC glfw) endif () -if (APPLE) - # Try to find xcframework of MoltenVK - cmake_path(SET MoltenVK_path NORMALIZE "$ENV{VULKAN_SDK}/../MoltenVK/") - cmake_path(SET MoltenVK_XC_path NORMALIZE "$ENV{VULKAN_SDK}/../MoltenVK/MoltenVK.xcframework") - if (EXISTS "${MoltenVK_path}" AND EXISTS "${MoltenVK_XC_path}") - if (EXISTS "${MoltenVK_path}/include") - set(Vulkan_INCLUDE_DIR "${MoltenVK_path}/include") - endif() - - target_link_libraries(imgui_internal PRIVATE "${MoltenVK_XC_path}/ios-arm64/libMoltenVK.a") - message("Found MoltenVK xcframework: ${MoltenVK_XC_path}") - endif() - - if (NOT ${Vulkan_INCLUDE_DIR}) - #find_package(Vulkan REQUIRED COMPONENTS MoltenVK) - #target_link_libraries(imgui_internal PRIVATE Vulkan::MoltenVK) - endif() -else () - find_package(Vulkan REQUIRED) - target_link_libraries(imgui_internal PRIVATE Vulkan::Vulkan) -endif() +SetupVulkan(imgui_internal) target_include_directories(imgui_internal PUBLIC ${Vulkan_INCLUDE_DIR}) target_include_directories(imgui_internal diff --git a/CMakeLists.txt b/CMakeLists.txt index e555ef4..62d4b29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 3.28 FATAL_ERROR) +include(cmake/VarsFromFile.cmake) include(cmake/SetCompilerSettings.cmake) include(cmake/SetupVulkan.cmake) include(cmake/Filter.cmake) @@ -32,6 +33,7 @@ else() endif() FilterPlatformPaths(sources) SetWarningSettings(openVulkanoCpp) +set_property(TARGET openVulkanoCpp PROPERTY CXX_STANDARD 17) target_sources(openVulkanoCpp PRIVATE ${sources}) target_include_directories(openVulkanoCpp PUBLIC openVulkanoCpp) @@ -74,20 +76,15 @@ if(IOS) target_link_libraries(openVulkanoCpp PRIVATE ${SYSTEMCONFIGURATION}) endif () -#Setup Vulkan SetupVulkan(openVulkanoCpp) -set_property(TARGET openVulkanoCpp PROPERTY CXX_STANDARD 17) - if (NOT ANDROID AND NOT IOS) Find_Package(libjpeg-turbo) - target_include_directories(openVulkanoCpp PRIVATE ${OpenCV_INCLUDE_DIRS}) - target_link_libraries(openVulkanoCpp PRIVATE glfw ${OpenCV_LIBS} pugixml) + target_link_libraries(openVulkanoCpp PRIVATE glfw pugixml) if (libjpeg-turbo_FOUND) target_link_libraries(openVulkanoCpp PRIVATE libjpeg-turbo::turbojpeg) endif() target_link_libraries(openVulkanoCpp PRIVATE assimp) - add_compile_definitions(GLM_FORCE_AVX2) target_link_libraries(openVulkanoCpp PRIVATE ftxui::screen ftxui::dom ftxui::component) endif() @@ -97,23 +94,16 @@ if (IOS) target_include_directories(openVulkanoCpp PRIVATE "/opt/libjpeg-turbo-ios/include") endif () -if (LINUX) - find_package(spdlog) - find_package(fmt) - find_package(yaml-cpp) - target_link_libraries(openVulkanoCpp PRIVATE fmt) -endif() - find_package(LibArchive REQUIRED) set(ZLIB_USE_STATIC_LIBS ON) find_package(ZLIB REQUIRED) target_include_directories(openVulkanoCpp PRIVATE ${LibArchive_INCLUDE_DIR}) -target_link_libraries(openVulkanoCpp PRIVATE magic_enum yaml-cpp spdlog glm pugixml ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} stb eigen utf8cpp imgui_internal TracyClient stud-uuid) +target_link_libraries(openVulkanoCpp PRIVATE magic_enum yaml-cpp fmt spdlog glm pugixml ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} stb eigen utf8cpp imgui_internal TracyClient stud-uuid) -add_compile_definitions(GLM_FORCE_INTRINSICS) -add_compile_definitions(GLM_FORCE_SILENT_WARNINGS) add_compile_definitions(LIBARCHIVE_STATIC) if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_definitions(DEBUG) endif() + +SetGlmDefines(openVulkanoCpp) \ No newline at end of file diff --git a/openVulkanoCpp/Math/Math.hpp b/openVulkanoCpp/Math/Math.hpp index 1f580d9..6c4d115 100644 --- a/openVulkanoCpp/Math/Math.hpp +++ b/openVulkanoCpp/Math/Math.hpp @@ -8,6 +8,7 @@ #define GLM_FORECE_DEPTH_ZERO_TO_ONE // TODO handle this better #include +#include #include #include #include From cd2b8cc822b341a714fc6fbca15fddef80d2ee95 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Wed, 22 May 2024 14:38:51 +0200 Subject: [PATCH 02/12] Make assimp optional --- 3rdParty/CMakeLists.txt | 2 +- 3rdParty/assimp/CMakeLists.txt | 52 ++++++++++++++++++++++------------ CMakeLists.txt | 9 ++++-- 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/3rdParty/CMakeLists.txt b/3rdParty/CMakeLists.txt index a40f3d2..0c733a3 100644 --- a/3rdParty/CMakeLists.txt +++ b/3rdParty/CMakeLists.txt @@ -2,8 +2,8 @@ add_subdirectory(glm) if (NOT ANDROID AND NOT IOS) add_subdirectory(glfw) add_subdirectory(ftxui) - add_subdirectory(assimp) endif() +add_subdirectory(assimp) add_subdirectory(fmt) add_subdirectory(spdlog) add_subdirectory(yaml-cpp) diff --git a/3rdParty/assimp/CMakeLists.txt b/3rdParty/assimp/CMakeLists.txt index aa65379..6c32a3d 100644 --- a/3rdParty/assimp/CMakeLists.txt +++ b/3rdParty/assimp/CMakeLists.txt @@ -1,23 +1,39 @@ include(FetchContent) -if(NOT DEFINED ASSIMP_REPO) - set(ASSIMP_REPO https://github.com/assimp/assimp.git) +find_package(assimp QUIET) +if (assimp_FOUND) + message("Using system assimp") +elseif (USE_ASSIMP) + if(NOT DEFINED ASSIMP_REPO) + set(ASSIMP_REPO https://github.com/assimp/assimp.git) + endif () + FetchContent_Declare( + assimp + EXCLUDE_FROM_ALL + GIT_REPOSITORY ${ASSIMP_REPO} + GIT_TAG v5.0.1 + GIT_SHALLOW TRUE + ) + + set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) + set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE) + set(ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "" FORCE) + set(ASSIMP_INJECT_DEBUG_POSTFIX OFF CACHE BOOL "" FORCE) + set(ASSIMP_INSTALL OFF CACHE BOOL "" FORCE) + set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "" FORCE) + set(ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "" FORCE) + + FetchContent_MakeAvailable(assimp) + + set(assimp_FOUND ON PARENT_SCOPE) endif () -FetchContent_Declare( - assimp - EXCLUDE_FROM_ALL - GIT_REPOSITORY ${ASSIMP_REPO} - GIT_TAG v5.0.1 - GIT_SHALLOW TRUE -) -set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) -set(ASSIMP_BUILD_TESTS OFF CACHE BOOL "" FORCE) -set(ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "" FORCE) -set(ASSIMP_INJECT_DEBUG_POSTFIX OFF CACHE BOOL "" FORCE) -set(ASSIMP_INSTALL OFF CACHE BOOL "" FORCE) -set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "" FORCE) -set(ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "" FORCE) - -FetchContent_MakeAvailable(assimp) \ No newline at end of file +function(LinkAssimp TARGET) + if (NOT assimp_FOUND) + find_package(assimp QUIET) + endif () + if (assimp_FOUND) + target_link_libraries(${TARGET} PUBLIC assimp) + endif () +endfunction() \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 62d4b29..189ab09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,14 @@ cmake_minimum_required(VERSION 3.28 FATAL_ERROR) +option(USE_ASSIMP "If assimp should be used" ON) + include(cmake/VarsFromFile.cmake) include(cmake/SetCompilerSettings.cmake) include(cmake/SetupVulkan.cmake) include(cmake/Filter.cmake) +VarsFromFile("DependencyMirrors.txt") # Load mirror list (for CICD) + set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) if(LINUX) @@ -84,7 +88,6 @@ if (NOT ANDROID AND NOT IOS) if (libjpeg-turbo_FOUND) target_link_libraries(openVulkanoCpp PRIVATE libjpeg-turbo::turbojpeg) endif() - target_link_libraries(openVulkanoCpp PRIVATE assimp) target_link_libraries(openVulkanoCpp PRIVATE ftxui::screen ftxui::dom ftxui::component) endif() @@ -106,4 +109,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_definitions(DEBUG) endif() -SetGlmDefines(openVulkanoCpp) \ No newline at end of file +SetGlmDefines(openVulkanoCpp) + +LinkAssimp(openVulkanoCpp) \ No newline at end of file From 1e7b20bf626bbe2980502a3aca9f61f19252484b Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Wed, 22 May 2024 14:50:17 +0200 Subject: [PATCH 03/12] Install ninja --- .gitea/workflows/build_pc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build_pc.yml b/.gitea/workflows/build_pc.yml index 57af470..ba1fe67 100644 --- a/.gitea/workflows/build_pc.yml +++ b/.gitea/workflows/build_pc.yml @@ -43,7 +43,7 @@ jobs: cache: true - name: Install Dev Packages if: matrix.config.os == 'ubuntu-latest' - run: sudo apt update && sudo apt install -y extra-cmake-modules libwayland-dev libxkbcommon-dev xorg-dev libarchive-dev libturbojpeg0-dev libassimp-dev + run: sudo apt update && sudo apt install -y extra-cmake-modules libwayland-dev libxkbcommon-dev xorg-dev libarchive-dev libturbojpeg0-dev libassimp-dev ninja-build - name: Configure CMake run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build From 824c74d901f5dc18f55ba75dfc682f444eaa40fe Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Thu, 23 May 2024 12:11:13 +0200 Subject: [PATCH 04/12] Fix issues with touch processing --- openVulkanoCpp/Input/Touch/GestureProcessor.cpp | 2 +- openVulkanoCpp/Input/Touch/InputDeviceTouch.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/openVulkanoCpp/Input/Touch/GestureProcessor.cpp b/openVulkanoCpp/Input/Touch/GestureProcessor.cpp index 4c1b568..6c1cade 100644 --- a/openVulkanoCpp/Input/Touch/GestureProcessor.cpp +++ b/openVulkanoCpp/Input/Touch/GestureProcessor.cpp @@ -43,7 +43,7 @@ namespace OpenVulkano::Input Logger::INPUT->debug("Replacing pan with multitouch gesture"); return ConflictResult::NewGesture; } - return ConflictResult::ExistingGesture; + return ConflictResult::BothGestures; }; } diff --git a/openVulkanoCpp/Input/Touch/InputDeviceTouch.cpp b/openVulkanoCpp/Input/Touch/InputDeviceTouch.cpp index 1019193..07745c8 100644 --- a/openVulkanoCpp/Input/Touch/InputDeviceTouch.cpp +++ b/openVulkanoCpp/Input/Touch/InputDeviceTouch.cpp @@ -201,7 +201,7 @@ namespace OpenVulkano::Input diff = m_next2FPanInfo.position - m_last2FPanInfo.position; m_axes[InputKey::Touch::Axis::AXIS_PAN_TWO_FINGERS_X] = diff.x; m_axes[InputKey::Touch::Axis::AXIS_PAN_TWO_FINGERS_Y] = diff.y; - m_next2FPanInfo = m_last2FPanInfo; + m_last2FPanInfo = m_next2FPanInfo; // Pinch m_axes[InputKey::Touch::Axis::AXIS_PINCH] = m_nextPinchInfo.scale - m_lastPinchInfo.scale; From d73f308f14cf67fd2e6cb992b3c967a90ade654d Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Thu, 23 May 2024 12:11:48 +0200 Subject: [PATCH 05/12] Add ArcballCameraController --- .../Controller/ArcballCameraController.cpp | 90 +++++++++++++++++++ .../Controller/ArcballCameraController.hpp | 49 ++++++++++ 2 files changed, 139 insertions(+) create mode 100644 openVulkanoCpp/Controller/ArcballCameraController.cpp create mode 100644 openVulkanoCpp/Controller/ArcballCameraController.hpp diff --git a/openVulkanoCpp/Controller/ArcballCameraController.cpp b/openVulkanoCpp/Controller/ArcballCameraController.cpp new file mode 100644 index 0000000..a4dcecd --- /dev/null +++ b/openVulkanoCpp/Controller/ArcballCameraController.cpp @@ -0,0 +1,90 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#include "ArcballCameraController.hpp" +#include "Scene/Camera.hpp" +#include "Input/InputManager.hpp" +#include "Input/InputKey.hpp" +#include "Base/FrameMetadata.hpp" + +namespace OpenVulkano +{ + void ArcballCameraController::SetupInputActions() + { + auto input = Input::InputManager::GetInstance(); + m_actionForward = input->GetAction("forward"); + m_actionSide = input->GetAction("side"); + m_actionUp = input->GetAction("up"); + m_actionLookUp = input->GetAction("look up"); + m_actionLookSide = input->GetAction("look side"); + } + + void ArcballCameraController::Tick() + { + if (!GetCamera()) return; + auto input = Input::InputManager::GetInstance(); + Math::Vector4f_SIMD position = GetCamera()->GetPosition(); + float yaw = input->GetAxis(m_actionLookSide); + float pitch = input->GetAxis(m_actionLookUp); + + // Handle issue with camera direction being the same as the up vector + float cosAngle = dot(Math::Vector3f_SIMD(GetCamera()->GetViewDirection()), m_upVector); + if (cosAngle * Math::Utils::sign(pitch) > 0.99f) pitch = 0; + + // Rotate the camera around the pivot point + Math::Matrix4f rotationMatrixX = Math::Utils::rotate(yaw, m_upVector); + position = (rotationMatrixX * (position - m_pivotPoint)) + m_pivotPoint; + m_rightVector = Math::Vector3f_SIMD(rotationMatrixX * Math::Vector4f(m_rightVector, 0)); + Math::Matrix4f rotationMatrixY = Math::Utils::rotate(pitch, m_rightVector); + position = (rotationMatrixY * (position - m_pivotPoint)) + m_pivotPoint; + + // Move the camera and the pivot point + Math::Vector3f_SIMD vec(input->GetAxis(m_actionSide), input->GetAxis(m_actionUp), -input->GetAxis(m_actionForward)); + if (vec != Math::Vector3f_SIMD (0)) + { + if (Math::Utils::length2(vec) > 1.0f) + { + vec = Math::Utils::normalize(vec); + } + const float timeScale = CURRENT_FRAME.frameTime; //TODO + vec = vec * timeScale * 3.0f; // scale vector + vec = GetCamera()->GetRotationMatrix() * Math::Vector3f(vec); + const Math::Vector4f_SIMD movement(vec, 0); + position += movement; + m_pivotPoint += movement; + } + + // Update the camera view + GetCamera()->SetViewMatrix(Math::Utils::lookAt(reinterpret_cast(position), + reinterpret_cast(m_pivotPoint), + m_upVector)); + } + + void ArcballCameraController::SetActive() + { + m_pivotPoint = GetCamera()->GetPosition() + Math::Vector4f(GetCamera()->GetViewDirection() * 3.0f, 0); + } + + void ArcballCameraController::SetDefaultKeybindings() + { + m_actionForward->BindKey(Input::InputKey::Controller::AXIS_LEFT_Y); + m_actionForward->BindAxisButtons(Input::InputKey::Keyboard::KEY_W, Input::InputKey::Keyboard::KEY_S); + m_actionForward->BindKey(Input::InputKey::Touch::AXIS_PINCH, 0.2f); + m_actionSide->BindKey(Input::InputKey::Controller::AXIS_LEFT_X); + m_actionSide->BindAxisButtons(Input::InputKey::Keyboard::KEY_D, Input::InputKey::Keyboard::KEY_A); + m_actionSide->BindKey(Input::InputKey::Touch::AXIS_PAN_TWO_FINGERS_X, -0.03f); + m_actionUp->BindAxisButtons(Input::InputKey::Keyboard::KEY_SPACE, Input::InputKey::Keyboard::KEY_LEFT_CONTROL); + m_actionUp->BindKey(Input::InputKey::Touch::AXIS_PAN_TWO_FINGERS_Y, 0.03f); + m_actionLookUp->BindKey(Input::InputKey::Controller::AXIS_RIGHT_Y); + m_actionLookUp->BindAxisButtons(Input::InputKey::Keyboard::KEY_DOWN, Input::InputKey::Keyboard::KEY_UP); + m_actionLookUp->BindKey(Input::InputKey::Touch::AXIS_PAN_Y, 0.001f); + m_actionLookSide->BindKey(Input::InputKey::Controller::AXIS_RIGHT_X); + m_actionLookSide->BindAxisButtons(Input::InputKey::Keyboard::KEY_RIGHT, Input::InputKey::Keyboard::KEY_LEFT); + m_actionLookSide->BindKey(Input::InputKey::Touch::AXIS_PAN_X, -0.001f); + m_actionLookUp->BindKey(Input::InputKey::Mouse::AXIS_Y); + m_actionLookSide->BindKey(Input::InputKey::Mouse::AXIS_X); + } +} diff --git a/openVulkanoCpp/Controller/ArcballCameraController.hpp b/openVulkanoCpp/Controller/ArcballCameraController.hpp new file mode 100644 index 0000000..6d80263 --- /dev/null +++ b/openVulkanoCpp/Controller/ArcballCameraController.hpp @@ -0,0 +1,49 @@ +/* + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "CameraController.hpp" +#include "Math/Math.hpp" + +namespace OpenVulkano +{ + namespace Input + { + class InputAction; + } + + class ArcballCameraController final : public CameraController + { + Math::Vector3f_SIMD m_upVector{ 0, 1, 0 }, m_rightVector{ 1, 0, 0 }; + Math::Vector4f_SIMD m_pivotPoint{ 0, 0, 0, 1 }; + + Input::InputAction* m_actionForward = nullptr; + Input::InputAction* m_actionSide = nullptr; + Input::InputAction* m_actionUp = nullptr; + Input::InputAction* m_actionLookUp = nullptr; + Input::InputAction* m_actionLookSide = nullptr; + + void SetupInputActions(); + + public: + ArcballCameraController() { SetupInputActions(); } + + ArcballCameraController(Scene::Camera* camera) : CameraController(camera) { SetupInputActions(); SetActive(); } + + void Tick() override; + + [[nodiscard]] const Math::Vector4f_SIMD& GetPivotPoint() const { return m_pivotPoint; } + + void SetPivotPoint(const Math::Vector4f_SIMD& pivotPoint) { m_pivotPoint = pivotPoint; } + + void SetActive(); + + void SetDefaultKeybindings(); + + void Init(Scene::Camera *camera) override { CameraController::SetCamera(camera); SetActive(); } + }; +} From 7fa25267d5b5257b83c65eeba35197131494e0b5 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Thu, 23 May 2024 21:21:03 +0200 Subject: [PATCH 06/12] Add back check if libjpeg-turbo is available --- .gitea/workflows/build_pc.yml | 2 +- openVulkanoCpp/AR/ArRecorder.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/build_pc.yml b/.gitea/workflows/build_pc.yml index ba1fe67..341dba7 100644 --- a/.gitea/workflows/build_pc.yml +++ b/.gitea/workflows/build_pc.yml @@ -43,7 +43,7 @@ jobs: cache: true - name: Install Dev Packages if: matrix.config.os == 'ubuntu-latest' - run: sudo apt update && sudo apt install -y extra-cmake-modules libwayland-dev libxkbcommon-dev xorg-dev libarchive-dev libturbojpeg0-dev libassimp-dev ninja-build + run: sudo apt update && sudo apt install -y extra-cmake-modules libwayland-dev libxkbcommon-dev xorg-dev libarchive-dev libassimp-dev ninja-build - name: Configure CMake run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} - name: Build diff --git a/openVulkanoCpp/AR/ArRecorder.cpp b/openVulkanoCpp/AR/ArRecorder.cpp index 24f413f..4ad2092 100644 --- a/openVulkanoCpp/AR/ArRecorder.cpp +++ b/openVulkanoCpp/AR/ArRecorder.cpp @@ -16,10 +16,10 @@ #include "Image/YuvUtils.hpp" #include #include -//#if __has_include("turbojpeg.h") +#if __has_include("turbojpeg.h") #include #define TURBO_JPEG -//#endif +#endif namespace OpenVulkano::AR { From 70cd46544bceebf6e95b1289d64a19acf7029055 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Sun, 26 May 2024 23:06:17 +0200 Subject: [PATCH 07/12] Update archiving libs and their linking --- 3rdParty/CMakeLists.txt | 10 ++ 3rdParty/libarchive/CMakeLists.txt | 11 +- CMakeLists.txt | 12 +- cmake/modules/FindLZ4.cmake | 38 ++++++ cmake/modules/Findzstd.cmake | 194 +++++++++++++++++++++++++++++ 5 files changed, 255 insertions(+), 10 deletions(-) create mode 100644 cmake/modules/FindLZ4.cmake create mode 100644 cmake/modules/Findzstd.cmake diff --git a/3rdParty/CMakeLists.txt b/3rdParty/CMakeLists.txt index 0c733a3..b5dfb46 100644 --- a/3rdParty/CMakeLists.txt +++ b/3rdParty/CMakeLists.txt @@ -29,3 +29,13 @@ execute_process( list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps/INSTALL) endif() + +function(LinkLibArchive TARGET) + find_package(LibArchive REQUIRED) + set(ZLIB_USE_STATIC_LIBS ON) + find_package(ZLIB REQUIRED) + find_package(LZ4 REQUIRED) + find_package(zstd REQUIRED) + target_include_directories(${TARGET} PRIVATE ${LibArchive_INCLUDE_DIR}) + target_link_libraries(${TARGET} PRIVATE ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} ${zstd_LIBRARIES} ${LZ4_LIBRARIES}) +endfunction() \ No newline at end of file diff --git a/3rdParty/libarchive/CMakeLists.txt b/3rdParty/libarchive/CMakeLists.txt index 027d605..def6607 100644 --- a/3rdParty/libarchive/CMakeLists.txt +++ b/3rdParty/libarchive/CMakeLists.txt @@ -17,7 +17,7 @@ endif () ExternalProject_Add(zlib GIT_REPOSITORY ${ZLIB_REPO} - GIT_TAG v1.2.11 + GIT_TAG v1.3.1 GIT_SHALLOW TRUE SOURCE_DIR zlib BINARY_DIR zlib-build @@ -31,7 +31,7 @@ ExternalProject_Add(zlib ExternalProject_Add(zstd GIT_REPOSITORY ${ZSTD_REPO} - GIT_TAG v1.5.1 + GIT_TAG v1.5.6 GIT_SHALLOW TRUE SOURCE_DIR zstd SOURCE_SUBDIR build/cmake @@ -47,7 +47,7 @@ ExternalProject_Add(zstd ExternalProject_Add(lz4 GIT_REPOSITORY ${LZ4_REPO} - GIT_TAG v1.9.3 + GIT_TAG v1.9.4 GIT_SHALLOW TRUE SOURCE_DIR lz4 BINARY_DIR lz4-build @@ -55,6 +55,9 @@ ExternalProject_Add(lz4 CMAKE_GENERATOR ${CMAKE_GENERATOR} CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=OFF + -DLZ4_BUILD_CLI:BOOL=OFF + -DLZ4_BUILD_LEGACY_LZ4C:BOOL=OFF + -DLZ4_BUNDLE_MODE:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_TOOLCHAIN_FILE:FILEPATH=${TOOLCHAIN_FILE} -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/INSTALL @@ -64,7 +67,7 @@ ExternalProject_Add( libarchive DEPENDS zlib zstd lz4 GIT_REPOSITORY ${LIBARCHIVE_REPO} - GIT_TAG v3.7.0 + GIT_TAG v3.7.4 GIT_SHALLOW TRUE SOURCE_DIR libarchive BINARY_DIR libarchive-build diff --git a/CMakeLists.txt b/CMakeLists.txt index 189ab09..50870eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,11 +97,7 @@ if (IOS) target_include_directories(openVulkanoCpp PRIVATE "/opt/libjpeg-turbo-ios/include") endif () -find_package(LibArchive REQUIRED) -set(ZLIB_USE_STATIC_LIBS ON) -find_package(ZLIB REQUIRED) -target_include_directories(openVulkanoCpp PRIVATE ${LibArchive_INCLUDE_DIR}) -target_link_libraries(openVulkanoCpp PRIVATE magic_enum yaml-cpp fmt spdlog glm pugixml ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} stb eigen utf8cpp imgui_internal TracyClient stud-uuid) +target_link_libraries(openVulkanoCpp PRIVATE magic_enum yaml-cpp fmt spdlog glm pugixml stb eigen utf8cpp imgui_internal TracyClient stud-uuid) add_compile_definitions(LIBARCHIVE_STATIC) @@ -111,4 +107,8 @@ endif() SetGlmDefines(openVulkanoCpp) -LinkAssimp(openVulkanoCpp) \ No newline at end of file +LinkAssimp(openVulkanoCpp) +LinkLibArchive(openVulkanoCpp) + + +set(VS_STARTUP_PROJECT openVulkanoCpp) \ No newline at end of file diff --git a/cmake/modules/FindLZ4.cmake b/cmake/modules/FindLZ4.cmake new file mode 100644 index 0000000..8c94e3b --- /dev/null +++ b/cmake/modules/FindLZ4.cmake @@ -0,0 +1,38 @@ +find_path(LZ4_INCLUDE_DIR + NAMES lz4.h + DOC "lz4 include directory") +mark_as_advanced(LZ4_INCLUDE_DIR) +find_library(LZ4_LIBRARY + NAMES lz4 liblz4 + DOC "lz4 library") +mark_as_advanced(LZ4_LIBRARY) + +if (LZ4_INCLUDE_DIR) + file(STRINGS "${LZ4_INCLUDE_DIR}/lz4.h" _lz4_version_lines + REGEX "#define[ \t]+LZ4_VERSION_(MAJOR|MINOR|RELEASE)") + string(REGEX REPLACE ".*LZ4_VERSION_MAJOR *\([0-9]*\).*" "\\1" _lz4_version_major "${_lz4_version_lines}") + string(REGEX REPLACE ".*LZ4_VERSION_MINOR *\([0-9]*\).*" "\\1" _lz4_version_minor "${_lz4_version_lines}") + string(REGEX REPLACE ".*LZ4_VERSION_RELEASE *\([0-9]*\).*" "\\1" _lz4_version_release "${_lz4_version_lines}") + set(LZ4_VERSION "${_lz4_version_major}.${_lz4_version_minor}.${_lz4_version_release}") + unset(_lz4_version_major) + unset(_lz4_version_minor) + unset(_lz4_version_release) + unset(_lz4_version_lines) +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LZ4 + REQUIRED_VARS LZ4_LIBRARY LZ4_INCLUDE_DIR + VERSION_VAR LZ4_VERSION) + +if (LZ4_FOUND) + set(LZ4_INCLUDE_DIRS "${LZ4_INCLUDE_DIR}") + set(LZ4_LIBRARIES "${LZ4_LIBRARY}") + + if (NOT TARGET LZ4::LZ4) + add_library(LZ4::LZ4 UNKNOWN IMPORTED) + set_target_properties(LZ4::LZ4 PROPERTIES + IMPORTED_LOCATION "${LZ4_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${LZ4_INCLUDE_DIR}") + endif () +endif () diff --git a/cmake/modules/Findzstd.cmake b/cmake/modules/Findzstd.cmake new file mode 100644 index 0000000..5fcb037 --- /dev/null +++ b/cmake/modules/Findzstd.cmake @@ -0,0 +1,194 @@ +# Copyright (C) 2020 Dieter Baron and Thomas Klausner +# +# The authors can be contacted at +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# +# 3. The names of the authors may not be used to endorse or promote +# products derived from this software without specific prior +# written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#[=======================================================================[.rst: +Findzstd +------- + +Finds the Zstandard (zstd) library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``zstd::libzstd_shared`` + The shared Zstandard library +``zstd::libzstd_static`` + The shared Zstandard library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``zstd_FOUND`` + True if the system has the Zstandard library. +``zstd_VERSION`` + The version of the Zstandard library which was found. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``zstd_INCLUDE_DIR`` + The directory containing ``zstd.h``. +``zstd_STATIC_LIBRARY`` + The path to the Zstandard static library. +``zstd_SHARED_LIBRARY`` + The path to the Zstandard shared library. +``zstd_DLL`` + The path to the Zstandard DLL. + +#]=======================================================================] + +find_package(PkgConfig) +pkg_check_modules(PC_zstd QUIET libzstd) + +find_path(zstd_INCLUDE_DIR + NAMES zstd.h + HINTS ${PC_zstd_INCLUDE_DIRS} +) + +find_file(zstd_DLL + NAMES libzstd.dll zstd.dll + PATH_SUFFIXES bin + HINTS ${PC_zstd_PREFIX} +) + +# On Windows, we manually define the library names to avoid mistaking the +# implib for the static library +if(zstd_DLL) + set(_zstd_win_static_name zstd-static) + set(_zstd_win_shared_name zstd) +else() + # vcpkg removes the -static suffix in static builds + set(_zstd_win_static_name zstd zstd_static) + set(_zstd_win_shared_name) +endif() + +set(_previous_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES}) +set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".dylib" ".dll.a" ".lib") +find_library(zstd_SHARED_LIBRARY + NAMES zstd ${_zstd_win_shared_name} + HINTS ${PC_zstd_LIBDIR} +) + +set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".lib") +find_library(zstd_STATIC_LIBRARY + NAMES zstd ${_zstd_win_static_name} + HINTS ${PC_zstd_LIBDIR} +) +set(CMAKE_FIND_LIBRARY_SUFFIXES ${_previous_suffixes}) + +# Set zstd_LIBRARY to the shared library or fall back to the static library +if(zstd_SHARED_LIBRARY) + set(_zstd_LIBRARY ${zstd_SHARED_LIBRARY}) +else() + set(_zstd_LIBRARY ${zstd_STATIC_LIBRARY}) +endif() + +# Extract version information from the header file +if(zstd_INCLUDE_DIR) + file(STRINGS ${zstd_INCLUDE_DIR}/zstd.h _ver_major_line + REGEX "^#define ZSTD_VERSION_MAJOR *[0-9]+" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+" + zstd_MAJOR_VERSION "${_ver_major_line}") + file(STRINGS ${zstd_INCLUDE_DIR}/zstd.h _ver_minor_line + REGEX "^#define ZSTD_VERSION_MINOR *[0-9]+" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+" + zstd_MINOR_VERSION "${_ver_minor_line}") + file(STRINGS ${zstd_INCLUDE_DIR}/zstd.h _ver_release_line + REGEX "^#define ZSTD_VERSION_RELEASE *[0-9]+" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+" + zstd_RELEASE_VERSION "${_ver_release_line}") + set(Zstd_VERSION "${zstd_MAJOR_VERSION}.${zstd_MINOR_VERSION}.${zstd_RELEASE_VERSION}") + unset(_ver_major_line) + unset(_ver_minor_line) + unset(_ver_release_line) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(zstd + FOUND_VAR zstd_FOUND + REQUIRED_VARS + _zstd_LIBRARY + zstd_INCLUDE_DIR + VERSION_VAR zstd_VERSION +) + +if(zstd_FOUND AND zstd_SHARED_LIBRARY AND NOT TARGET zstd::libzstd_shared) + add_library(zstd::libzstd_shared SHARED IMPORTED) + if(WIN32) + set_target_properties(zstd::libzstd_shared PROPERTIES + IMPORTED_LOCATION "${zstd_DLL}" + IMPORTED_IMPLIB "${zstd_SHARED_LIBRARY}" + ) + else() + set_target_properties(zstd::libzstd_shared PROPERTIES + IMPORTED_LOCATION "${zstd_SHARED_LIBRARY}" + ) + endif() + + set_target_properties(zstd::libzstd_shared PROPERTIES + INTERFACE_COMPILE_OPTIONS "${PC_zstd_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}" + ) +endif() + +if(zstd_FOUND AND zstd_STATIC_LIBRARY AND NOT TARGET zstd::libzstd_static) + add_library(zstd::libzstd_static STATIC IMPORTED) + set_target_properties(zstd::libzstd_static PROPERTIES + IMPORTED_LOCATION "${zstd_STATIC_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_zstd_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${zstd_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced( + zstd_INCLUDE_DIR + zstd_DLL + zstd_SHARED_LIBRARY + zstd_STATIC_LIBRARY +) + +if (zstd_FOUND) + if(zstd_STATIC_LIBRARY) + set(zstd_LIBRARIES "zstd::libzstd_static") + else () + set(zstd_LIBRARIES "zstd::libzstd_shared") + endif () +endif () \ No newline at end of file From 9926cdee0b35ac9a139504e295ecf1bb0883cb9d Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Sun, 26 May 2024 23:44:31 +0200 Subject: [PATCH 08/12] Build libarchive unless USE_SYSTEM_LIB_ARCHIVE is set --- 3rdParty/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/3rdParty/CMakeLists.txt b/3rdParty/CMakeLists.txt index b5dfb46..7725616 100644 --- a/3rdParty/CMakeLists.txt +++ b/3rdParty/CMakeLists.txt @@ -17,7 +17,7 @@ add_subdirectory(tracy) add_subdirectory(libstud-uuid) add_subdirectory(rapidyaml) -if (NOT LINUX) +if (NOT USE_SYSTEM_LIB_ARCHIVE) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/deps) execute_process( COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} -DTOOLCHAIN_FILE=${TOOLCHAIN_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/libarchive @@ -26,9 +26,8 @@ execute_process( execute_process( COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/deps ) - list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps/INSTALL) -endif() +endif () function(LinkLibArchive TARGET) find_package(LibArchive REQUIRED) From ec73c7d2ca1f7837b38f7c548d4f9b57cca090d8 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Sun, 26 May 2024 23:52:27 +0200 Subject: [PATCH 09/12] Add module path --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 50870eb..b7c816f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ if(LINUX) find_package(ECM REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) endif() +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") add_subdirectory(3rdParty) @@ -111,4 +112,4 @@ LinkAssimp(openVulkanoCpp) LinkLibArchive(openVulkanoCpp) -set(VS_STARTUP_PROJECT openVulkanoCpp) \ No newline at end of file +set(VS_STARTUP_PROJECT openVulkanoCpp) From 409f679cfdb80c99fe4ee4d1dfcdc8c9852f5aeb Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Mon, 27 May 2024 08:50:31 +0200 Subject: [PATCH 10/12] Use system libarchive if available --- 3rdParty/CMakeLists.txt | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/3rdParty/CMakeLists.txt b/3rdParty/CMakeLists.txt index 7725616..2389467 100644 --- a/3rdParty/CMakeLists.txt +++ b/3rdParty/CMakeLists.txt @@ -17,24 +17,32 @@ add_subdirectory(tracy) add_subdirectory(libstud-uuid) add_subdirectory(rapidyaml) -if (NOT USE_SYSTEM_LIB_ARCHIVE) -file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/deps) -execute_process( - COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} -DTOOLCHAIN_FILE=${TOOLCHAIN_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/libarchive - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/deps -) -execute_process( - COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/deps -) -list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps/INSTALL) + +#TODO move into a different file +find_package(LibArchive QUIET) +if (NOT LibArchive_FOUND) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/deps) + execute_process( + COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} -DTOOLCHAIN_FILE=${TOOLCHAIN_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/libarchive + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/deps + ) + execute_process( + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/deps + ) + list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps/INSTALL) +else () + message("Using system LibArchive") + set(USING_SYSTEM_LIBARCHIVE ON PARENT_SCOPE) endif () function(LinkLibArchive TARGET) find_package(LibArchive REQUIRED) set(ZLIB_USE_STATIC_LIBS ON) find_package(ZLIB REQUIRED) - find_package(LZ4 REQUIRED) - find_package(zstd REQUIRED) + if (NOT USING_SYSTEM_LIBARCHIVE) + find_package(LZ4 REQUIRED) + find_package(zstd REQUIRED) + endif () target_include_directories(${TARGET} PRIVATE ${LibArchive_INCLUDE_DIR}) target_link_libraries(${TARGET} PRIVATE ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} ${zstd_LIBRARIES} ${LZ4_LIBRARIES}) endfunction() \ No newline at end of file From b462167760f96db5ab30c42e013a245697af2213 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Mon, 27 May 2024 09:06:51 +0200 Subject: [PATCH 11/12] Add BZip2 and LZMA as optional packages --- 3rdParty/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/3rdParty/CMakeLists.txt b/3rdParty/CMakeLists.txt index 2389467..69e138c 100644 --- a/3rdParty/CMakeLists.txt +++ b/3rdParty/CMakeLists.txt @@ -39,10 +39,10 @@ function(LinkLibArchive TARGET) find_package(LibArchive REQUIRED) set(ZLIB_USE_STATIC_LIBS ON) find_package(ZLIB REQUIRED) - if (NOT USING_SYSTEM_LIBARCHIVE) - find_package(LZ4 REQUIRED) - find_package(zstd REQUIRED) - endif () + find_package(LZ4 QUIET) + find_package(zstd QUIET) + find_package(BZip2 QUIET) + find_package(LibLZMA QUIET) target_include_directories(${TARGET} PRIVATE ${LibArchive_INCLUDE_DIR}) - target_link_libraries(${TARGET} PRIVATE ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} ${zstd_LIBRARIES} ${LZ4_LIBRARIES}) + target_link_libraries(${TARGET} PRIVATE ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} ${zstd_LIBRARIES} ${LZ4_LIBRARIES} ${LIBLZMA_LIBRARIES} ${BZIP2_LIBRARIES}) endfunction() \ No newline at end of file From 8875a2d4ee6287896048167b45cde7425fab3b24 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Mon, 27 May 2024 10:23:02 +0200 Subject: [PATCH 12/12] Move apple framework linking into a reusable function --- CMakeLists.txt | 28 +--------------------------- cmake/AppleHelper.cmake | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 27 deletions(-) create mode 100644 cmake/AppleHelper.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b7c816f..e9db368 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,33 +52,7 @@ if(IOS) set(CMAKE_OSX_DEPLOYMENT_TARGET "14.1") # The used ARKit features are only available starting with iOS 14 - target_link_libraries(openVulkanoCpp - PRIVATE "-framework CoreFoundation" - PRIVATE "-framework Foundation" - PRIVATE "-framework CoreImage" - PRIVATE "-framework CoreVideo" - PRIVATE "-framework Metal" - PRIVATE "-framework MetalPerformanceShaders" - PRIVATE "-framework ARKit" - PRIVATE "-lstdc++" - PRIVATE c++ - PRIVATE c - ) - - - # Locate system libraries on iOS - find_library(UIKIT UIKit) - find_library(FOUNDATION Foundation) - find_library(MOBILECORESERVICES MobileCoreServices) - find_library(CFNETWORK CFNetwork) - find_library(SYSTEMCONFIGURATION SystemConfiguration) - - # link the frameworks located above - target_link_libraries(openVulkanoCpp PRIVATE ${UIKIT}) - target_link_libraries(openVulkanoCpp PRIVATE ${FOUNDATION}) - target_link_libraries(openVulkanoCpp PRIVATE ${MOBILECORESERVICES}) - target_link_libraries(openVulkanoCpp PRIVATE ${CFNETWORK}) - target_link_libraries(openVulkanoCpp PRIVATE ${SYSTEMCONFIGURATION}) + LinkAppleFrameworks(openVulkanoCpp) endif () SetupVulkan(openVulkanoCpp) diff --git a/cmake/AppleHelper.cmake b/cmake/AppleHelper.cmake new file mode 100644 index 0000000..7ab0175 --- /dev/null +++ b/cmake/AppleHelper.cmake @@ -0,0 +1,29 @@ +function(LinkAppleFrameworks TARGET) + target_link_libraries(${TARGET} + PUBLIC "-framework CoreFoundation" + PUBLIC "-framework Foundation" + PUBLIC "-framework CoreImage" + PUBLIC "-framework CoreVideo" + PUBLIC "-framework Metal" + PUBLIC "-framework MetalPerformanceShaders" + PUBLIC "-framework ARKit" + PUBLIC "-lstdc++" + PUBLIC c++ + PUBLIC c + ) + + + # Locate system libraries on iOS + find_library(UIKIT UIKit) + find_library(FOUNDATION Foundation) + find_library(MOBILECORESERVICES MobileCoreServices) + find_library(CFNETWORK CFNetwork) + find_library(SYSTEMCONFIGURATION SystemConfiguration) + + # link the frameworks located above + target_link_libraries(${TARGET} PUBLIC ${UIKIT}) + target_link_libraries(${TARGET} PUBLIC ${FOUNDATION}) + target_link_libraries(${TARGET} PUBLIC ${MOBILECORESERVICES}) + target_link_libraries(${TARGET} PUBLIC ${CFNETWORK}) + target_link_libraries(${TARGET} PUBLIC ${SYSTEMCONFIGURATION}) +endfunction() \ No newline at end of file