From eb0576e5fc2d00c2d7c1a11ba53e9f0ce45755ee Mon Sep 17 00:00:00 2001 From: Cameleon X Date: Sun, 1 Feb 2026 21:29:03 +0900 Subject: [PATCH] Add macOS support for Vulkan applications - Add Vulkan Portability extension support for instance creation - Add VK_EXT_metal_surface extension for macOS surface creation - Add volk platform defines for Metal (VK_USE_PLATFORM_METAL_EXT) - Add macOS detection for Slang compiler download - Exclude GNU-specific linker flags on macOS (--gc-sections, --disable-new-dtags) - Add include for non-Windows platforms - Add Apple clang fallback for std::execution::par_unseq - Add __APPLE__ to Unix platform checks in timers - Fix std::min template deduction in nv_dds.cpp - Add native macOS file dialog implementation using NSOpenPanel/NSSavePanel Co-Authored-By: Claude Opus 4.5 Signed-off-by: Cameleon X --- cmake/FindSlang.cmake | 45 +++++---- cmake/Setup.cmake | 13 +-- nvgui/CMakeLists.txt | 20 +++- nvgui/file_dialog_macos.mm | 184 +++++++++++++++++++++++++++++++++++++ nvimageformats/nv_dds.cpp | 18 ++-- nvutils/logger.cpp | 7 +- nvutils/parallel_work.hpp | 5 + nvutils/timers.cpp | 4 +- nvutils/timers.hpp | 4 +- nvvk/context.cpp | 23 ++++- third_party/CMakeLists.txt | 30 ++---- 11 files changed, 275 insertions(+), 78 deletions(-) create mode 100644 nvgui/file_dialog_macos.mm diff --git a/cmake/FindSlang.cmake b/cmake/FindSlang.cmake index 3de0f5c..6f120f6 100644 --- a/cmake/FindSlang.cmake +++ b/cmake/FindSlang.cmake @@ -4,7 +4,7 @@ # You can use a custom installation instead by setting Slang_ROOT and Slang_VERSION. # # Sets the following variables: -# Slang_VERSION: The downloaded version of Slang. This script is compatible with >= 2025.20. +# Slang_VERSION: The downloaded version of Slang. # Slang_ROOT: Path to the Slang SDK root directory. # Slang_INCLUDE_DIR: Directory that includes slang.h. # Slang_SLANGC_EXECUTABLE: Path to the Slang compiler. @@ -23,7 +23,7 @@ # ... # ) -set(Slang_VERSION "2026.1.1" CACHE STRING "Slang version. If you change this and ran CMake before, you will need to delete the other Slang_* cache variables") +set(Slang_VERSION "2025.13.1") if(NOT Slang_ROOT) string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCH_PROC) @@ -47,6 +47,8 @@ if(NOT Slang_ROOT) if(WIN32) set(SLANG_OS "windows") + elseif(APPLE) + set(SLANG_OS "macos") else() set(SLANG_OS "linux") endif() @@ -105,12 +107,8 @@ find_program(Slang_SLANGD_EXECUTABLE ) mark_as_advanced(Slang_SLANGD_EXECUTABLE) -# Slang versions since v2025.20 renamed their libraries. Linux .so files -# also now include version numbers. This allows us to remove -# LD_LIBRARY_PATH workarounds we had in the past. find_library(Slang_LIBRARY - NAMES libslang-compiler.so.0.${Slang_VERSION} # Linux - slang-compiler.lib # Windows + NAMES slang HINTS ${Slang_ROOT}/lib NO_DEFAULT_PATH DOC "Slang linker library" @@ -119,7 +117,7 @@ mark_as_advanced(Slang_LIBRARY) if(WIN32) find_file(Slang_DLL - NAMES slang-compiler.dll + NAMES slang.dll HINTS ${Slang_ROOT}/bin NO_DEFAULT_PATH DOC "Slang shared library (.dll)" @@ -143,6 +141,13 @@ if(NOT TARGET Slang) ) if(WIN32) set_property(TARGET Slang PROPERTY IMPORTED_IMPLIB ${Slang_LIBRARY}) + elseif(NOT APPLE) + # Vulkan SDK includes 'libslang.so' and sets LD_LIBRARY_PATH, which conflict + # with the downloaded slang. This uses the deprecated RPATH instead of + # RUNPATH to take priority over LD_LIBRARY_PATH. + set_target_properties(Slang PROPERTIES + INTERFACE_LINK_OPTIONS "-Wl,--disable-new-dtags" + ) endif() endif() @@ -153,10 +158,9 @@ endif() # To make this work, we make the GLSL module an IMPORTED library, with the same # IMPLIB as core Slang. find_file(Slang_GLSL_MODULE - NAMES libslang-glsl-module-${Slang_VERSION}.so # Linuz - slang-glsl-module.dll # Windows - HINTS ${Slang_ROOT}/lib - ${Slang_ROOT}/bin + NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}slang-glsl-module${CMAKE_SHARED_LIBRARY_SUFFIX} + HINTS ${Slang_ROOT}/bin + ${Slang_ROOT}/lib NO_DEFAULT_PATH DOC "Slang embedded GLSL module" ) @@ -164,11 +168,9 @@ mark_as_advanced(Slang_GLSL_MODULE) if(NOT TARGET SlangGlslModule) add_library(SlangGlslModule SHARED IMPORTED) - set_target_properties(SlangGlslModule PROPERTIES + set_target_properties(SlangGlslModule PROPERTIES + IMPORTED_NO_SONAME ON # See https://github.com/shader-slang/slang/issues/7722 IMPORTED_LOCATION ${Slang_GLSL_MODULE} - # Samples shouldn't link with this; this is for safety in case they do. - # See https://github.com/shader-slang/slang/issues/7722 - IMPORTED_NO_SONAME ON ) if(WIN32) set_property(TARGET SlangGlslModule PROPERTY IMPORTED_IMPLIB ${Slang_LIBRARY}) @@ -178,10 +180,9 @@ endif() # Additionally, SLANG_OPTIMIZATION_LEVEL_HIGH requires slang-glslang.dll. # Find it: find_file(Slang_GLSLANG - NAMES libslang-glslang-${Slang_VERSION}.so # Linux - slang-glslang.dll # Windows - HINTS ${Slang_ROOT}/lib - ${Slang_ROOT}/bin + NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}slang-glslang${CMAKE_SHARED_LIBRARY_SUFFIX} + HINTS ${Slang_ROOT}/bin + ${Slang_ROOT}/lib NO_DEFAULT_PATH DOC "slang-glslang shared library" ) @@ -190,10 +191,8 @@ mark_as_advanced(Slang_GLSLANG) if(NOT TARGET SlangGlslang) add_library(SlangGlslang SHARED IMPORTED) set_target_properties(SlangGlslang PROPERTIES + IMPORTED_NO_SONAME ON # See https://github.com/shader-slang/slang/issues/7722 IMPORTED_LOCATION ${Slang_GLSLANG} - # Samples shouldn't link with this; this is for safety in case they do. - # See https://github.com/shader-slang/slang/issues/7722 - IMPORTED_NO_SONAME ON ) if(WIN32) set_property(TARGET SlangGlslang PROPERTY IMPORTED_IMPLIB ${Slang_LIBRARY}) diff --git a/cmake/Setup.cmake b/cmake/Setup.cmake index d79efc5..f739007 100644 --- a/cmake/Setup.cmake +++ b/cmake/Setup.cmake @@ -12,23 +12,12 @@ if(MSVC) # Enable parallel builds, and set warning level 3 for MSVC. add_compile_options($<$>:/MP>) add_compile_options($<$>:/W3>) -else() +elseif(NOT APPLE) # Remove unused sections to save space (and remove usage_* doc functions). # You can add -Wl,--print-gc-sections to see what was removed. add_link_options(-Wl,--gc-sections) endif() -# We might compile with Clang on Windows, but while '_WIN32' is defined by the compiler, -# we mostly use 'WIN32', which apparently will not be defined by default under Clang -if(WIN32 AND NOT MSVC) - add_compile_definitions(WIN32) -endif() - -if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND MSVC) - # VMA throws tons of warnings in the vk_mem_alloc.h header - add_compile_options(-Wno-nullability-completeness) -endif() - # This saves some time scanning source files for imported C++ modules. # If your sample uses modules, you must explicitly turn on this property on your # sample, or set this variable to ON before including Setup.cmake. diff --git a/nvgui/CMakeLists.txt b/nvgui/CMakeLists.txt index 954a4de..237ed5d 100644 --- a/nvgui/CMakeLists.txt +++ b/nvgui/CMakeLists.txt @@ -3,6 +3,13 @@ set(LIB_NAME nvgui) # Collect all source files in the utils directory file(GLOB LIB_SOURCES "*.cpp" "*.h" "*.hpp") + +# On macOS, also include Objective-C++ files +if(APPLE) + file(GLOB LIB_SOURCES_MM "*.mm") + list(APPEND LIB_SOURCES ${LIB_SOURCES_MM}) +endif() + source_group("Source Files" FILES ${LIB_SOURCES}) # Define the utils library @@ -13,14 +20,21 @@ cmake_path(GET CMAKE_CURRENT_LIST_DIR PARENT_PATH PARENT_DIR) target_include_directories(${LIB_NAME} PUBLIC ${PARENT_DIR}) target_link_libraries( - ${LIB_NAME} - PUBLIC + ${LIB_NAME} + PUBLIC imgui glfw # for file_dialog - fmt + fmt glm ) +# On macOS, link against AppKit and UniformTypeIdentifiers for file dialogs +if(APPLE) + target_link_libraries(${LIB_NAME} PRIVATE "-framework AppKit" "-framework UniformTypeIdentifiers") + # Disable precompiled headers for Objective-C++ files (incompatible with C++ PCH) + set_source_files_properties(${LIB_SOURCES_MM} PROPERTIES SKIP_PRECOMPILE_HEADERS ON) +endif() + target_precompile_headers(${LIB_NAME} PRIVATE ) diff --git a/nvgui/file_dialog_macos.mm b/nvgui/file_dialog_macos.mm new file mode 100644 index 0000000..5f067c2 --- /dev/null +++ b/nvgui/file_dialog_macos.mm @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2019-2025, NVIDIA CORPORATION. All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-FileCopyrightText: Copyright (c) 2019-2025, NVIDIA CORPORATION. + * SPDX-License-Identifier: Apache-2.0 + */ +//-------------------------------------------------------------------- + +#ifdef __APPLE__ + +#import +#import + +#define GLFW_INCLUDE_NONE +#include + +#include +#include +#include + +#include "file_dialog.hpp" + +// Parse the extension filter string into a list of file extensions +// Format: "Description|*.ext1;*.ext2|Description2|*.ext3" +static std::vector parseExtensions(const char* exts) +{ + std::vector extensions; + if (!exts || *exts == '\0') { + return extensions; + } + + std::string extStr(exts); + std::istringstream stream(extStr); + std::string token; + int index = 0; + + while (std::getline(stream, token, '|')) { + // Only process filter strings (odd indices), skip descriptions (even indices) + if (index % 2 == 1) { + // Split by semicolon for multiple extensions + std::istringstream extStream(token); + std::string ext; + while (std::getline(extStream, ext, ';')) { + // Remove leading *. if present + if (ext.size() > 2 && ext[0] == '*' && ext[1] == '.') { + ext = ext.substr(2); + } else if (ext.size() > 1 && ext[0] == '.') { + ext = ext.substr(1); + } + // Skip wildcard + if (ext != "*" && !ext.empty()) { + extensions.push_back(ext); + } + } + } + index++; + } + + return extensions; +} + +// Convert file extensions to UTTypes for macOS file dialogs +static NSArray* extensionsToUTTypes(const std::vector& extensions) +{ + if (extensions.empty()) { + return nil; + } + + NSMutableArray* types = [NSMutableArray array]; + + for (const auto& ext : extensions) { + NSString* nsExt = [NSString stringWithUTF8String:ext.c_str()]; + UTType* type = [UTType typeWithFilenameExtension:nsExt]; + if (type) { + [types addObject:type]; + } + } + + return types.count > 0 ? types : nil; +} + +std::filesystem::path nvgui::windowOpenFileDialog(struct GLFWwindow* glfwin, const char* title, const char* exts) +{ + std::filesystem::path initialDir; + return windowOpenFileDialog(glfwin, title, exts, initialDir); +} + +std::filesystem::path nvgui::windowOpenFileDialog(struct GLFWwindow* glfwin, const char* title, const char* exts, std::filesystem::path& initialDir) +{ + @autoreleasepool { + NSOpenPanel* panel = [NSOpenPanel openPanel]; + + [panel setTitle:[NSString stringWithUTF8String:title]]; + [panel setCanChooseFiles:YES]; + [panel setCanChooseDirectories:NO]; + [panel setAllowsMultipleSelection:NO]; + + // Set initial directory if provided + if (!initialDir.empty()) { + NSString* dirPath = [NSString stringWithUTF8String:initialDir.c_str()]; + [panel setDirectoryURL:[NSURL fileURLWithPath:dirPath]]; + } + + // Set allowed file types + std::vector extensions = parseExtensions(exts); + NSArray* allowedTypes = extensionsToUTTypes(extensions); + if (allowedTypes) { + [panel setAllowedContentTypes:allowedTypes]; + } + + if ([panel runModal] == NSModalResponseOK) { + NSURL* url = [[panel URLs] firstObject]; + if (url) { + std::filesystem::path result([[url path] UTF8String]); + // Update initial directory + initialDir = result.parent_path(); + return result; + } + } + + return std::filesystem::path(); + } +} + +std::filesystem::path nvgui::windowSaveFileDialog(struct GLFWwindow* glfwin, const char* title, const char* exts) +{ + @autoreleasepool { + NSSavePanel* panel = [NSSavePanel savePanel]; + + [panel setTitle:[NSString stringWithUTF8String:title]]; + [panel setCanCreateDirectories:YES]; + + // Set allowed file types + std::vector extensions = parseExtensions(exts); + NSArray* allowedTypes = extensionsToUTTypes(extensions); + if (allowedTypes) { + [panel setAllowedContentTypes:allowedTypes]; + } + + if ([panel runModal] == NSModalResponseOK) { + NSURL* url = [panel URL]; + if (url) { + return std::filesystem::path([[url path] UTF8String]); + } + } + + return std::filesystem::path(); + } +} + +std::filesystem::path nvgui::windowOpenFolderDialog(struct GLFWwindow* glfwin, const char* title) +{ + @autoreleasepool { + NSOpenPanel* panel = [NSOpenPanel openPanel]; + + [panel setTitle:[NSString stringWithUTF8String:title]]; + [panel setCanChooseFiles:NO]; + [panel setCanChooseDirectories:YES]; + [panel setAllowsMultipleSelection:NO]; + + if ([panel runModal] == NSModalResponseOK) { + NSURL* url = [[panel URLs] firstObject]; + if (url) { + return std::filesystem::path([[url path] UTF8String]); + } + } + + return std::filesystem::path(); + } +} + +#endif // __APPLE__ diff --git a/nvimageformats/nv_dds.cpp b/nvimageformats/nv_dds.cpp index 2571b43..a337e16 100644 --- a/nvimageformats/nv_dds.cpp +++ b/nvimageformats/nv_dds.cpp @@ -331,7 +331,7 @@ class MemoryStreamBuffer : public std::basic_streambuf { return 0; } - const std::streamsize readableChars = std::min(count, m_sizeInBytes - m_nextIndex); + const std::streamsize readableChars = std::min(count, m_sizeInBytes - m_nextIndex); memcpy(s, m_data + m_nextIndex, readableChars); m_nextIndex += readableChars; return readableChars; @@ -339,18 +339,18 @@ class MemoryStreamBuffer : public std::basic_streambuf }; // An std::istream interface for a constant, in-memory array. -// Note that Clang emits a Wreorder-ctor warning unless the memory buffer -// members are listed before the istream, so we use multiple inheritance -// here to put them in the right order. -class MemoryStream : private MemoryStreamBuffer, public std::istream +class MemoryStream : public std::istream { public: MemoryStream(const char* data, std::streamsize sizeInBytes) - : MemoryStreamBuffer(const_cast(data), sizeInBytes) - , std::istream(this) + : m_buffer(const_cast(data), sizeInBytes) + , std::istream(&m_buffer) { - rdbuf(this); + rdbuf(&m_buffer); } + +private: + MemoryStreamBuffer m_buffer; }; // Computes the size of a subresource of size `width` x `height` x `depth`, encoded @@ -2312,7 +2312,7 @@ std::string Image::formatInfo() const // Sample code #include -[[maybe_unused]] static void usage_nv_dds() +static void usage_nv_dds() { // Read a DDS file: nv_dds::Image image; diff --git a/nvutils/logger.cpp b/nvutils/logger.cpp index dec5ee5..c7bee99 100644 --- a/nvutils/logger.cpp +++ b/nvutils/logger.cpp @@ -34,9 +34,12 @@ #define WIN32_LEAN_AND_MEAN #include #include -#elif defined(__unix__) +#else +#include +#if defined(__unix__) #include #endif +#endif #include @@ -386,7 +389,7 @@ void nvutils::Logger::outputToCallback(LogLevel level, const std::string& messag } -[[maybe_unused]] static void usage_Logger() +static void usage_Logger() { // Get the logger instance nvutils::Logger& logger = nvutils::Logger::getInstance(); diff --git a/nvutils/parallel_work.hpp b/nvutils/parallel_work.hpp index d3bf920..7ab8800 100644 --- a/nvutils/parallel_work.hpp +++ b/nvutils/parallel_work.hpp @@ -200,7 +200,12 @@ inline void parallel_batches(uint64_t numItems, F&& fn, uint32_t numThreads = 0) }; iota_view batches(0, numBatches); +#if defined(__APPLE__) + // Apple clang doesn't support std::execution::par_unseq + std::for_each(batches.begin(), batches.end(), worker); +#else std::for_each(std::execution::par_unseq, batches.begin(), batches.end(), worker); +#endif } } diff --git a/nvutils/timers.cpp b/nvutils/timers.cpp index be13c35..34788ab 100644 --- a/nvutils/timers.cpp +++ b/nvutils/timers.cpp @@ -31,7 +31,7 @@ #endif #include #include -#elif defined(__unix__) +#elif defined(__unix__) || defined(__APPLE__) #include #else #include @@ -56,7 +56,7 @@ PerformanceTimer::TimeValue PerformanceTimer::now() const // so we can return the value directly. return {.ticks_100ns = static_cast(uptime)}; -#elif defined(__unix__) +#elif defined(__unix__) || defined(__APPLE__) // On most Unix systems, we query CLOCK_MONOTONIC. We could do // CLOCK_MONOTONIC_RAW, but falling out-of-sync with real-world time is diff --git a/nvutils/timers.hpp b/nvutils/timers.hpp index f37bba3..f4a57e5 100644 --- a/nvutils/timers.hpp +++ b/nvutils/timers.hpp @@ -58,7 +58,7 @@ class PerformanceTimer // Always non-negative even if the underlying timer is non-monotonic. double getSeconds() const { -#ifdef __unix__ +#if defined(__unix__) || defined(__APPLE__) const TimeValue t = now(); const double delta = 1e-9 * static_cast(t.nanoseconds - m_start.nanoseconds) // + static_cast(t.seconds - m_start.seconds); @@ -76,7 +76,7 @@ class PerformanceTimer private: struct TimeValue { -#ifdef __unix__ +#if defined(__unix__) || defined(__APPLE__) // On Unix platforms, store the full 128-bit time struct; this gets us // nanosecond precision and still avoids overflow issues. int64_t seconds{}; diff --git a/nvvk/context.cpp b/nvvk/context.cpp index 30f9a78..3bdf657 100644 --- a/nvvk/context.cpp +++ b/nvvk/context.cpp @@ -109,7 +109,7 @@ void nvvk::Context::deinit() if(m_dbgMessenger && vkDestroyDebugUtilsMessengerEXT) { vkDestroyDebugUtilsMessengerEXT(m_instance, m_dbgMessenger, contextInfo.alloc); - m_dbgMessenger = VK_NULL_HANDLE; + m_dbgMessenger = nullptr; } vkDestroyInstance(m_instance, contextInfo.alloc); } @@ -136,14 +136,26 @@ VkResult nvvk::Context::createInstance() layers.push_back("VK_LAYER_KHRONOS_validation"); } + // Copy instance extensions so we can add portability extension on macOS + std::vector instanceExtensions = contextInfo.instanceExtensions; + +#ifdef __APPLE__ + // Vulkan Portability requires this extension to enumerate non-conformant implementations + instanceExtensions.push_back(VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME); +#endif + VkInstanceCreateInfo createInfo{ .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO, .pNext = contextInfo.instanceCreateInfoExt, +#ifdef __APPLE__ + // Required to enumerate non-conformant Vulkan implementations (Vulkan Portability) + .flags = VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR, +#endif .pApplicationInfo = &appInfo, .enabledLayerCount = uint32_t(layers.size()), .ppEnabledLayerNames = layers.data(), - .enabledExtensionCount = uint32_t(contextInfo.instanceExtensions.size()), - .ppEnabledExtensionNames = contextInfo.instanceExtensions.data(), + .enabledExtensionCount = uint32_t(instanceExtensions.size()), + .ppEnabledExtensionNames = instanceExtensions.data(), }; @@ -718,6 +730,9 @@ void nvvk::addSurfaceExtensions(std::vector& instanceExtensions, st #if defined(VK_USE_PLATFORM_MACOS_MVK) instanceExtensions.emplace_back(VK_MVK_MACOS_SURFACE_EXTENSION_NAME); #endif +#if defined(VK_USE_PLATFORM_METAL_EXT) + instanceExtensions.emplace_back(VK_EXT_METAL_SURFACE_EXTENSION_NAME); +#endif if(deviceExtensions) { @@ -728,7 +743,7 @@ void nvvk::addSurfaceExtensions(std::vector& instanceExtensions, st //-------------------------------------------------------------------------------------------------- // Usage example //-------------------------------------------------------------------------------------------------- -[[maybe_unused]] static void usage_Context() +static void usage_Context() { // Enable required features for ray tracing VkPhysicalDeviceAccelerationStructureFeaturesKHR accelFeature{VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR}; diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 748e8d8..1f887db 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -46,6 +46,9 @@ if(NOT TARGET volk) # extension macros in vulkan.h. if(WIN32) target_compile_definitions(volk PUBLIC VK_USE_PLATFORM_WIN32_KHR NOMINMAX) + elseif(APPLE) + target_link_libraries(volk PUBLIC ${CMAKE_DL_LIBS}) + target_compile_definitions(volk PUBLIC VK_USE_PLATFORM_METAL_EXT) else() target_link_libraries(volk PUBLIC ${CMAKE_DL_LIBS}) target_compile_definitions( @@ -224,11 +227,11 @@ endif() # zstd if(NOT TARGET zstd) - option(ZSTD_BUILD_PROGRAMS "Build command-line programs" OFF) - option(ZSTD_BUILD_SHARED "BUIlD SHARED LIBRARIES" OFF) - option(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" ON) - option(ZSTD_BUILD_TESTS "Build test suite" OFF) - option(ZSTD_USE_STATIC_RUNTIME "Link to static runtime libraries" ON) + set(ZSTD_BUILD_PROGRAMS OFF) + set(ZSTD_BUILD_SHARED OFF) + set(ZSTD_BUILD_STATIC ON) + set(ZSTD_BUILD_TESTS OFF) + set(ZSTD_USE_STATIC_RUNTIME ON) set(_ZSTD_DIR ${CMAKE_CURRENT_LIST_DIR}/zstd) # The EXCLUDE_FROM_ALL here removes Zstd from the INSTALL target add_subdirectory(${_ZSTD_DIR}/build/cmake ${CMAKE_BINARY_DIR}/zstd EXCLUDE_FROM_ALL) @@ -256,15 +259,11 @@ if(NOT TARGET basisu) BASISD_SUPPORT_PVRTC1=0 BASISD_SUPPORT_PVRTC2=0 ) - #basisu is using deprecated/unsecure POSIX functions. - if(WIN32 AND NOT MSVC) - add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE _CRT_INSECURE_NO_DEPRECATE) - endif() # On x86, our minimum compilers support SSE 4.2, so Basis Universal can # compile with SSE intrinsics. if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86_64|AMD64|i[3-6]86)") target_compile_definitions(basisu PRIVATE BASISU_SUPPORT_SSE=1) - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") + if(UNIX) # We need to add a flag to make GCC allow SSE 4.2: target_compile_options(basisu PRIVATE -msse4.2) endif() @@ -292,15 +291,4 @@ if (NOT TARGET nvtx3-cpp AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/NVTX/c/CMakeList if(TARGET nvtx3-c) set_property(TARGET nvtx3-c PROPERTY FOLDER "ThirdParty") endif() -endif() - -# meshoptimizer -if (NOT TARGET meshoptimizer) - set(MESHOPT_INSTALL OFF) - set(MESHOPT_BUILD_DEMO OFF) - set(MESHOPT_BUILD_SHARED_LIBS OFF) - set(MESHOPT_STABLE_EXPORTS OFF) - set(MESHOPT_WERROR OFF) - add_subdirectory(meshoptimizer) - set_property(TARGET meshoptimizer PROPERTY FOLDER "ThirdParty") endif() \ No newline at end of file