Merge pull request 'Fixed build on windows, added libjpeg-turbo' (#21) from windows_build_fix into master
Reviewed-on: https://git.madvoxel.net/OpenVulkano/OpenVulkano/pulls/21 Reviewed-by: Georg Hagen <georg.hagen@madvoxel.com>
This commit is contained in:
16
3rdParty/CMakeLists.txt
vendored
16
3rdParty/CMakeLists.txt
vendored
@@ -1,3 +1,5 @@
|
||||
include(ExternalProject)
|
||||
|
||||
add_subdirectory(glm)
|
||||
if (NOT ANDROID AND NOT IOS)
|
||||
add_subdirectory(glfw)
|
||||
@@ -16,6 +18,7 @@ add_subdirectory(imgui)
|
||||
add_subdirectory(tracy)
|
||||
add_subdirectory(libstud-uuid)
|
||||
add_subdirectory(rapidyaml)
|
||||
add_subdirectory(libjpeg-turbo)
|
||||
|
||||
|
||||
#TODO move into a different file
|
||||
@@ -28,7 +31,12 @@ if (NOT DEFINED LibArchive_LIBRARIES)
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/deps
|
||||
RESULT_VARIABLE build_result
|
||||
)
|
||||
if (NOT ${build_result} EQUAL "0")
|
||||
message(FATAL_ERROR "Failed to build lib archive!")
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps/INSTALL)
|
||||
else ()
|
||||
message("Using system LibArchive")
|
||||
@@ -44,5 +52,11 @@ function(LinkLibArchive TARGET)
|
||||
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} ${LIBLZMA_LIBRARIES} ${BZIP2_LIBRARIES})
|
||||
target_link_libraries(${TARGET} PRIVATE ${LibArchive_LIBRARIES} ${ZLIB_LIBRARIES} ${zstd_LIBRARIES} ${LZ4_LIBRARIES})
|
||||
if (BZIP2_LIBRARIES)
|
||||
target_link_libraries(${TARGET} PRIVATE ${BZIP2_LIBRARIES})
|
||||
endif()
|
||||
if (LIBLZMA_LIBRARIES)
|
||||
target_link_libraries(${TARGET} PRIVATE ${LIBLZMA_LIBRARIES})
|
||||
endif()
|
||||
endfunction()
|
||||
7
3rdParty/assimp/CMakeLists.txt
vendored
7
3rdParty/assimp/CMakeLists.txt
vendored
@@ -1,5 +1,6 @@
|
||||
include(FetchContent)
|
||||
|
||||
unset(assimp_FOUND)
|
||||
find_package(assimp QUIET)
|
||||
if (assimp_FOUND)
|
||||
message("Using system assimp")
|
||||
@@ -25,15 +26,15 @@ elseif (USE_ASSIMP)
|
||||
|
||||
FetchContent_MakeAvailable(assimp)
|
||||
|
||||
set(assimp_FOUND ON PARENT_SCOPE)
|
||||
set(assimp_BUILT "fetched assimp found" CACHE INTERNAL ON)
|
||||
endif ()
|
||||
|
||||
|
||||
function(LinkAssimp TARGET)
|
||||
if (NOT assimp_FOUND)
|
||||
if (NOT assimp_BUILT)
|
||||
find_package(assimp QUIET)
|
||||
endif ()
|
||||
if (assimp_FOUND)
|
||||
if (assimp_FOUND OR assimp_BUILT)
|
||||
target_link_libraries(${TARGET} PUBLIC assimp)
|
||||
endif ()
|
||||
endfunction()
|
||||
2
3rdParty/libarchive/CMakeLists.txt
vendored
2
3rdParty/libarchive/CMakeLists.txt
vendored
@@ -31,7 +31,7 @@ ExternalProject_Add(zlib
|
||||
|
||||
ExternalProject_Add(zstd
|
||||
GIT_REPOSITORY ${ZSTD_REPO}
|
||||
GIT_TAG v1.5.6
|
||||
GIT_TAG v1.5.5
|
||||
GIT_SHALLOW TRUE
|
||||
SOURCE_DIR zstd
|
||||
SOURCE_SUBDIR build/cmake
|
||||
|
||||
30
3rdParty/libjpeg-turbo/CMakeLists.txt
vendored
Normal file
30
3rdParty/libjpeg-turbo/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
include(FetchContent)
|
||||
|
||||
Find_Package(libjpeg-turbo QUIET)
|
||||
if (libjpeg-turbo_FOUND)
|
||||
message("Using system libjpeg-turbo")
|
||||
else ()
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/deps_ljt)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} -DTOOLCHAIN_FILE=${TOOLCHAIN_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/ext
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/deps_ljt
|
||||
)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/deps_ljt
|
||||
RESULT_VARIABLE build_result
|
||||
)
|
||||
if (NOT ${build_result} EQUAL "0")
|
||||
message(FATAL_ERROR "Failed to build libjpeg-turbo!")
|
||||
endif()
|
||||
|
||||
set(libjpeg-turbo_BUILT "built libjpeg-turbo" CACHE INTERNAL ON)
|
||||
endif ()
|
||||
|
||||
|
||||
function(LinkLibJpegTurbo TARGET)
|
||||
if (libjpeg-turbo_BUILT)
|
||||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps_ljt/INSTALL/lib/cmake)
|
||||
endif()
|
||||
find_package(libjpeg-turbo REQUIRED)
|
||||
target_link_libraries(${TARGET} PUBLIC libjpeg-turbo::turbojpeg-static)
|
||||
endfunction()
|
||||
22
3rdParty/libjpeg-turbo/ext/CMakeLists.txt
vendored
Normal file
22
3rdParty/libjpeg-turbo/ext/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(build_libjpeg-turbo)
|
||||
include(ExternalProject)
|
||||
|
||||
if(NOT DEFINED LIBJPEGTURBO_REPO)
|
||||
set(LIBJPEGTURBO_REPO https://github.com/libjpeg-turbo/libjpeg-turbo.git)
|
||||
endif ()
|
||||
|
||||
ExternalProject_Add(libjpegturbo
|
||||
GIT_REPOSITORY ${LIBJPEGTURBO_REPO}
|
||||
GIT_TAG 3.0.3
|
||||
GIT_SHALLOW TRUE
|
||||
SOURCE_DIR libjpegturbo
|
||||
BINARY_DIR libjpegturbo-build
|
||||
CMAKE_GENERATOR ${CMAKE_GENERATOR}
|
||||
CMAKE_ARGS
|
||||
-DBUILD_SHARED_LIBS:BOOL=OFF
|
||||
-DENABLE_SHARED:BOOL=OFF
|
||||
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${TOOLCHAIN_FILE}
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_BINARY_DIR}/INSTALL
|
||||
-DCMAKE_BUILD_TYPE:STRING=Release
|
||||
)
|
||||
@@ -55,26 +55,45 @@ if(IOS)
|
||||
LinkAppleFrameworks(openVulkanoCpp)
|
||||
endif ()
|
||||
|
||||
if (WIN32)
|
||||
# Ws2
|
||||
target_link_libraries(openVulkanoCpp PRIVATE Ws2_32)
|
||||
|
||||
file(GLOB_RECURSE DLLS "${CMAKE_BINARY_DIR}/*.dll")
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(EXE_OUTPUT_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}" )
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
||||
set(EXE_OUTPUT_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL}" )
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
|
||||
set(EXE_OUTPUT_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO}" )
|
||||
elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(EXE_OUTPUT_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}" )
|
||||
else ()
|
||||
set(EXE_OUTPUT_DIR "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" )
|
||||
endif()
|
||||
|
||||
foreach(DLL ${DLLS})
|
||||
add_custom_command(TARGET openVulkanoCpp POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${DLL} ${EXE_OUTPUT_DIR}
|
||||
)
|
||||
endforeach()
|
||||
endif ()
|
||||
|
||||
SetupVulkan(openVulkanoCpp)
|
||||
|
||||
if (NOT ANDROID AND NOT IOS)
|
||||
Find_Package(libjpeg-turbo)
|
||||
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 ftxui::screen ftxui::dom ftxui::component)
|
||||
endif()
|
||||
|
||||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/deps/INSTALL)
|
||||
if (IOS)
|
||||
target_link_libraries(openVulkanoCpp PRIVATE "/opt/libjpeg-turbo-ios/lib/libturbojpeg.a")
|
||||
target_include_directories(openVulkanoCpp PRIVATE "/opt/libjpeg-turbo-ios/include")
|
||||
endif ()
|
||||
|
||||
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)
|
||||
add_compile_definitions(NOMINMAX)
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
add_compile_definitions(DEBUG)
|
||||
@@ -84,6 +103,6 @@ SetGlmDefines(openVulkanoCpp)
|
||||
|
||||
LinkAssimp(openVulkanoCpp)
|
||||
LinkLibArchive(openVulkanoCpp)
|
||||
|
||||
LinkLibJpegTurbo(openVulkanoCpp)
|
||||
|
||||
set(VS_STARTUP_PROJECT openVulkanoCpp)
|
||||
|
||||
@@ -6,6 +6,10 @@ openVulkano is a simple Vulkan rendering engine which is capable of recording co
|
||||
* Git
|
||||
* CMake
|
||||
* C++ 17 compatible compiler
|
||||
### Required dependencies on linux
|
||||
```bash
|
||||
sudo apt install extra-cmake-modules libarchive-dev libeigen3-dev
|
||||
```
|
||||
|
||||
### Build from source:
|
||||
```bash
|
||||
|
||||
@@ -160,11 +160,11 @@ namespace OpenVulkano::AR
|
||||
{
|
||||
if (!m_colorWriter)
|
||||
{
|
||||
m_colorWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path, "color_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true);
|
||||
m_depthWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path, "depth_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true);
|
||||
m_confidenceWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path, "confidence_{:05d}.tar.gz", ArchiveConfig::TAR_GZ, m_settings.archiveSize, true);
|
||||
m_metadataWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path, "meta_{:05d}.tar.gz", ArchiveConfig::TAR_GZ, m_settings.archiveSize, true);
|
||||
m_highResWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path, "highres_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true);
|
||||
m_colorWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path.string(), "color_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true);
|
||||
m_depthWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path.string(), "depth_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true);
|
||||
m_confidenceWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path.string(), "confidence_{:05d}.tar.gz", ArchiveConfig::TAR_GZ, m_settings.archiveSize, true);
|
||||
m_metadataWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path.string(), "meta_{:05d}.tar.gz", ArchiveConfig::TAR_GZ, m_settings.archiveSize, true);
|
||||
m_highResWriter = std::make_unique<MultiPartArchiveWriter>(m_settings.path.string(), "highres_{:05d}.tar", ArchiveConfig::TAR, m_settings.archiveSize, true);
|
||||
|
||||
std::ofstream platformInfoStream(m_settings.path / RECORDING_METADATA_FILENAME);
|
||||
platformInfoStream << m_session->GetSessionMetadata().ToXML();
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenVulkano
|
||||
{
|
||||
if (numberStr.empty()) return 0;
|
||||
int tmp = 0;
|
||||
std::from_chars(numberStr.begin(), numberStr.end(), tmp);
|
||||
std::from_chars(numberStr.data(), numberStr.data() + numberStr.size(), tmp);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "Data/Containers/Array.hpp"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
|
||||
@@ -13,6 +13,10 @@
|
||||
#include <Winsock.h>
|
||||
#include <Winbase.h>
|
||||
|
||||
// NOTE(vb): Windows defines macros like GetUserName that are used to automatically select the appropriate function version (GetUserNameA for ANSI and GetUserNameW for Unicode)
|
||||
// based on whether the _UNICODE macro is defined, so we manually undefine these macros to avoid naming collisions.
|
||||
#undef GetUserName
|
||||
|
||||
namespace OpenVulkano
|
||||
{
|
||||
namespace
|
||||
@@ -44,7 +48,7 @@ namespace OpenVulkano
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case APP_MEM_TYPE::VM_MAX return counters.PeakWorkingSetSize;
|
||||
case APP_MEM_TYPE::VM_MAX: return counters.PeakWorkingSetSize;
|
||||
case APP_MEM_TYPE::USED: return counters.PrivateUsage;
|
||||
}
|
||||
}
|
||||
@@ -55,12 +59,12 @@ namespace OpenVulkano
|
||||
|
||||
size_t SystemInfo::GetSystemRam()
|
||||
{
|
||||
return ReadSystemMemInfo(MEM_TYPE::TOTAL_PHYS);
|
||||
return ReadSystemMemInfo(SYS_MEM_TYPE::TOTAL_PHYS);
|
||||
}
|
||||
|
||||
size_t SystemInfo::GetSystemRamAvailable()
|
||||
{
|
||||
return ReadSystemMemInfo(MEM_TYPE::AVAIL_PHYS);
|
||||
return ReadSystemMemInfo(SYS_MEM_TYPE::AVAIL_PHYS);
|
||||
}
|
||||
|
||||
size_t SystemInfo::GetAppRamMax()
|
||||
@@ -87,7 +91,7 @@ namespace OpenVulkano
|
||||
{
|
||||
char username[UNLEN+1];
|
||||
DWORD username_len = UNLEN+1;
|
||||
GetUserName(username, &username_len);
|
||||
::GetUserNameA(username, &username_len);
|
||||
return username;
|
||||
}
|
||||
|
||||
@@ -121,21 +125,21 @@ namespace OpenVulkano
|
||||
return "Windows";
|
||||
}
|
||||
|
||||
Version SystemInfo::GetOsVersion()
|
||||
OsVersion SystemInfo::GetOsVersion()
|
||||
{
|
||||
OSVERSIONINFOEX info;
|
||||
ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
GetVersionEx(&info);
|
||||
return { info.dwMajorVersion, info.dwMinorVersion, 0, info.dwBuildNumber };
|
||||
OSVERSIONINFOA info;
|
||||
ZeroMemory(&info, sizeof(OSVERSIONINFOA));
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOA);
|
||||
GetVersionExA(&info);
|
||||
return { (int)info.dwMajorVersion, (int)info.dwMinorVersion, 0, (int)info.dwBuildNumber };
|
||||
}
|
||||
|
||||
std::string SystemInfo::GetOsNameHumanReadable()
|
||||
{
|
||||
OSVERSIONINFOEX info;
|
||||
ZeroMemory(&info, sizeof(OSVERSIONINFOEX));
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
GetVersionEx(&info);
|
||||
OSVERSIONINFOEXA info;
|
||||
ZeroMemory(&info, sizeof(OSVERSIONINFOEXA));
|
||||
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXA);
|
||||
GetVersionEx((OSVERSIONINFOA *)&info);
|
||||
if (info.wProductType == VER_NT_WORKSTATION)
|
||||
{
|
||||
if (info.dwMajorVersion == 10)
|
||||
@@ -151,7 +155,7 @@ namespace OpenVulkano
|
||||
}
|
||||
}
|
||||
|
||||
return "Windows " + std::string(info.dwMajorVersion) + "." + std::string(info.dwMinorVersion);
|
||||
return "Windows " + std::to_string(info.dwMajorVersion) + "." + std::to_string(info.dwMinorVersion);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -168,7 +172,7 @@ namespace OpenVulkano
|
||||
}
|
||||
}
|
||||
|
||||
return "Windows Server " + std::string(info.dwMajorVersion) + "." + std::string(info.dwMinorVersion);
|
||||
return "Windows Server " + std::to_string(info.dwMajorVersion) + "." + std::to_string(info.dwMinorVersion);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace OpenVulkano
|
||||
CloseHandle(fileHandle);
|
||||
return;
|
||||
}
|
||||
size = fileSize;
|
||||
size = fileSize.QuadPart;
|
||||
|
||||
fileMappingHandle = CreateFileMapping(
|
||||
fileHandle,
|
||||
@@ -85,7 +85,7 @@ namespace OpenVulkano
|
||||
|
||||
~Internal()
|
||||
{
|
||||
UnmapViewOfFile(lpMapAddress);
|
||||
UnmapViewOfFile(address);
|
||||
CloseHandle(fileMappingHandle);
|
||||
CloseHandle(fileHandle);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ namespace OpenVulkano
|
||||
|
||||
MemMappedFile::MemMappedFile(const std::filesystem::path& path, FileMode fileMode)
|
||||
{
|
||||
m_internal = std::make_shared<Internal>(path.c_str(), fileMode);
|
||||
m_internal = std::make_shared<Internal>(path.string().c_str(), fileMode);
|
||||
m_data = m_internal->address;
|
||||
m_size = (m_data) ? m_internal->size : 0;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#ifdef _WIN32
|
||||
# undef TRANSPARENT
|
||||
#endif
|
||||
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
class Node;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
namespace OpenVulkano::Scene
|
||||
{
|
||||
class Geometry;
|
||||
class Material;
|
||||
struct Material;
|
||||
|
||||
class SimpleDrawable final : public Drawable
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user