From c42eec2ffca8217fc4323818adf8ada2d4fc2b44 Mon Sep 17 00:00:00 2001 From: kindem Date: Wed, 26 Nov 2025 19:29:59 +0800 Subject: [PATCH 01/44] feat: support export targets from cmake binary tree --- CMake/Target.cmake | 10 +++ Editor/CMakeLists.txt | 95 ++++++++++++---------- Engine/Source/Common/CMakeLists.txt | 8 +- Engine/Source/Core/CMakeLists.txt | 8 +- Engine/Source/Launch/CMakeLists.txt | 4 +- Engine/Source/Mirror/CMakeLists.txt | 8 +- Engine/Source/RHI-DirectX12/CMakeLists.txt | 4 +- Engine/Source/RHI-Dummy/CMakeLists.txt | 4 +- Engine/Source/RHI-Vulkan/CMakeLists.txt | 12 +-- Engine/Source/RHI/CMakeLists.txt | 4 +- Engine/Source/Render/CMakeLists.txt | 12 +-- Engine/Source/Runtime/CMakeLists.txt | 8 +- Sample/CMakeLists.txt | 40 ++++----- ThirdParty/CMakeLists.txt | 86 ++++++++++---------- Tool/MirrorTool/CMakeLists.txt | 8 +- 15 files changed, 163 insertions(+), 148 deletions(-) diff --git a/CMake/Target.cmake b/CMake/Target.cmake index 97e9dc4d..5b883de9 100644 --- a/CMake/Target.cmake +++ b/CMake/Target.cmake @@ -336,6 +336,11 @@ function(exp_add_executable) EXPORT ${SUB_PROJECT_NAME}Targets RUNTIME DESTINATION ${SUB_PROJECT_NAME}/Binaries ) + export( + TARGETS ${arg_NAME} + NAMESPACE ${SUB_PROJECT_NAME}:: + APPEND FILE ${CMAKE_BINARY_DIR}/${SUB_PROJECT_NAME}Targets.cmake + ) if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") install(CODE "execute_process(COMMAND install_name_tool -add_rpath @executable_path ${CMAKE_INSTALL_PREFIX}/${SUB_PROJECT_NAME}/Binaries/$)") @@ -513,6 +518,11 @@ function(exp_add_library) LIBRARY DESTINATION ${SUB_PROJECT_NAME}/Target/${arg_NAME}/Lib RUNTIME DESTINATION ${SUB_PROJECT_NAME}/Binaries ) + export( + TARGETS ${arg_NAME} + NAMESPACE ${SUB_PROJECT_NAME}:: + APPEND FILE ${CMAKE_BINARY_DIR}/${SUB_PROJECT_NAME}Targets.cmake + ) if ("${arg_TYPE}" STREQUAL "SHARED") install( FILES $ diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 0b51913c..4d236277 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -8,18 +8,18 @@ find_package( qt_standard_project_setup(REQUIRES ${QT_VERSION}) if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(PLATFORM_EXECUTABLE_HINT MACOSX_BUNDLE) - set(BUNDLE_INSTALL_DESTINATION BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX}/${ENGINE_SUB_PROJECT_NAME}/Binaries) - set(PLATFORM_FRAMEWORK_DIR ${QT_LIB_PREFIX}/lib) + set(platform_executable_hint MACOSX_BUNDLE) + set(bundle_install_dest BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX}/${ENGINE_SUB_PROJECT_NAME}/Binaries) + set(platform_fwk_dir ${QT_LIB_PREFIX}/lib) endif () -set(EDITOR_INCLUDES Include) -set(EDITOR_QT_LIBS Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Quick Qt6::WebEngineWidgets) -set(EDITOR_LIBS Core RHI Runtime cpp-httplib ${EDITOR_QT_LIBS}) +set(editor_includes Include) +set(editor_qt_libs Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Quick Qt6::WebEngineWidgets) +set(editor_libs Core RHI Runtime cpp-httplib ${editor_qt_libs}) -foreach (QT_LIB ${EDITOR_QT_LIBS}) +foreach (QT_LIB ${editor_qt_libs}) string(REPLACE "::" "" QT_RAW_LIB ${QT_LIB}) - list(APPEND EDITOR_INCLUDES ${${QT_RAW_LIB}_INCLUDE_DIRS}) + list(APPEND editor_includes ${${QT_RAW_LIB}_INCLUDE_DIRS}) endforeach () exp_add_mirror_info_source_generation_target( @@ -27,13 +27,13 @@ exp_add_mirror_info_source_generation_target( OUTPUT_SRC EDITOR_MIRROR_GENERATED_SRC OUTPUT_TARGET_NAME EDITOR_MIRROR_GENERATED_TARGET SEARCH_DIR Include - PRIVATE_INC ${EDITOR_INCLUDES} - LIB ${EDITOR_LIBS} - FRAMEWORK_DIR ${PLATFORM_FRAMEWORK_DIR} + PRIVATE_INC ${editor_includes} + LIB ${editor_libs} + FRAMEWORK_DIR ${platform_fwk_dir} ) file(GLOB_RECURSE SOURCES Src/*.cpp) -qt_add_executable(Editor ${PLATFORM_EXECUTABLE_HINT} ${SOURCES} ${EDITOR_MIRROR_GENERATED_SRC}) +qt_add_executable(Editor ${platform_executable_hint} ${SOURCES} ${EDITOR_MIRROR_GENERATED_SRC}) get_cmake_property(GENERATOR_IS_MULTI_CONFIG GENERATOR_IS_MULTI_CONFIG) if (${GENERATOR_IS_MULTI_CONFIG}) @@ -48,8 +48,8 @@ else () ) endif () -target_include_directories(Editor PRIVATE ${EDITOR_INCLUDES}) -target_link_libraries(Editor PRIVATE ${EDITOR_LIBS}) +target_include_directories(Editor PRIVATE ${editor_includes}) +target_link_libraries(Editor PRIVATE ${editor_libs}) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(RHI_DEP_TARGETS RHI-DirectX12 RHI-Vulkan) @@ -64,11 +64,16 @@ exp_process_runtime_dependencies( install( TARGETS Editor RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${ENGINE_SUB_PROJECT_NAME}/Binaries - ${BUNDLE_INSTALL_DESTINATION} + ${bundle_install_dest} +) +export( + TARGETS Editor + NAMESPACE ${SUB_PROJECT_NAME}:: + APPEND FILE ${CMAKE_BINARY_DIR}/${SUB_PROJECT_NAME}Targets.cmake ) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - set(QT_WIN_DEPLOY_EXECUTABLE ${QT_LIB_PREFIX}/bin/windeployqt.exe) + set(qt_win_deploy_executable ${QT_LIB_PREFIX}/bin/windeployqt.exe) add_custom_command( TARGET Editor POST_BUILD # ++ QT 6.9.1 Temporal Fix Start @@ -83,75 +88,75 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_resources_100p.pak $/resources/qtwebengine_resources_100p.pak COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_resources_200p.pak $/resources/qtwebengine_resources_200p.pak # -- QT 6.9.1 Temporal Fix End - COMMAND ${QT_WIN_DEPLOY_EXECUTABLE} $ + COMMAND ${qt_win_deploy_executable} $ ) install( - CODE "execute_process(COMMAND ${QT_WIN_DEPLOY_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${ENGINE_SUB_PROJECT_NAME}/Binaries/$)" + CODE "execute_process(COMMAND ${qt_win_deploy_executable} ${CMAKE_INSTALL_PREFIX}/${ENGINE_SUB_PROJECT_NAME}/Binaries/$)" ) elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(QT_MAC_DEPLOY_EXECUTABLE ${QT_LIB_PREFIX}/bin/macdeployqt) + set(qt_mac_deploy_executable ${QT_LIB_PREFIX}/bin/macdeployqt) add_custom_command( TARGET Editor POST_BUILD - COMMAND ${QT_MAC_DEPLOY_EXECUTABLE} $/Editor.app -no-strip + COMMAND ${qt_mac_deploy_executable} $/Editor.app -no-strip ) install( - CODE "execute_process(COMMAND ${QT_MAC_DEPLOY_EXECUTABLE} ${CMAKE_INSTALL_PREFIX}/${ENGINE_SUB_PROJECT_NAME}/Binaries/Editor.app -no-strip)" + CODE "execute_process(COMMAND ${qt_mac_deploy_executable} ${CMAKE_INSTALL_PREFIX}/${ENGINE_SUB_PROJECT_NAME}/Binaries/Editor.app -no-strip)" ) endif () if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - foreach (RHI_DEP_TARGET ${RHI_DEP_TARGETS}) - list(APPEND RHI_DEP_TARGET_COPY_COMMANDS COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $/../Frameworks/$) + foreach (rhi_dep_target ${RHI_DEP_TARGETS}) + list(APPEND rhi_dep_target_copy_commands COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $/../Frameworks/$) endforeach () add_custom_command( TARGET Editor POST_BUILD - ${RHI_DEP_TARGET_COPY_COMMANDS} + ${rhi_dep_target_copy_commands} ) endif () # ---- begin shaders --------------------------------------------------------------------------------- -get_engine_shader_resources(OUTPUT EDITOR_RESOURCES) +get_engine_shader_resources(OUTPUT editor_resources) -file(GLOB_RECURSE SHADERS Shader/*.es*) -foreach (SHADER ${SHADERS}) - get_filename_component(SHADER_ABSOLUTE ${SHADER} ABSOLUTE) - string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/Shader ../Shader/Editor COPY_DST ${SHADER_ABSOLUTE}) - list(APPEND EDITOR_RESOURCES ${SHADER}->${COPY_DST}) +file(GLOB_RECURSE shaders Shader/*.es*) +foreach (shader ${shaders}) + get_filename_component(shader_absolute ${shader} ABSOLUTE) + string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/Shader ../Shader/Editor copy_dst ${shader_absolute}) + list(APPEND editor_resources ${shader}->${copy_dst}) endforeach () -file(GLOB_RECURSE RESOURCES Resource/*) -foreach (RESOURCE ${RESOURCES}) - get_filename_component(RESOURCE_ABSOLUTE ${RESOURCE} ABSOLUTE) - string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/Resource ../Resource/Editor COPY_DST ${RESOURCE_ABSOLUTE}) - list(APPEND EDITOR_RESOURCES ${RESOURCE}->${COPY_DST}) +file(GLOB_RECURSE resources Resource/*) +foreach (resource ${resources}) + get_filename_component(resource_absolute ${resource} ABSOLUTE) + string(REPLACE ${CMAKE_CURRENT_SOURCE_DIR}/Resource ../Resource/Editor copy_dst ${resource_absolute}) + list(APPEND editor_resources ${resource}->${copy_dst}) endforeach () exp_add_resources_copy_command( NAME Editor - RES ${EDITOR_RESOURCES} + RES ${editor_resources} ) # ---- end shaders ----------------------------------------------------------------------------------- # ---- begin web project ----------------------------------------------------------------------------- -find_program(NPM_EXECUTABLE NAMES npm.cmd npm REQUIRED NO_CACHE) +find_program(npm_executable NAMES npm.cmd npm REQUIRED NO_CACHE) message("Perform web project npm install......") execute_process( - COMMAND ${CMAKE_COMMAND} -E env ${NPM_EXECUTABLE} install --no-fund --registry=https://registry.npmmirror.com + COMMAND ${CMAKE_COMMAND} -E env ${npm_executable} install --no-fund --registry=https://registry.npmmirror.com WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Web - RESULT_VARIABLE NPM_INSTALL_RESULT - OUTPUT_VARIABLE NPM_INSTALL_OUTPUT - ERROR_VARIABLE NPM_INSTALL_ERROR + RESULT_VARIABLE npm_install_result + OUTPUT_VARIABLE npm_install_output + ERROR_VARIABLE npm_install_error ) -if (${NPM_INSTALL_RESULT} STREQUAL "0") - message(${NPM_INSTALL_OUTPUT}) +if (${npm_install_result} STREQUAL "0") + message(${npm_install_output}) else () - message(FATAL_ERROR ${NPM_INSTALL_ERROR}) + message(FATAL_ERROR ${npm_install_error}) endif () add_custom_target( Editor.Web - COMMAND ${CMAKE_COMMAND} -E env ${NPM_EXECUTABLE} run build + COMMAND ${CMAKE_COMMAND} -E env ${npm_executable} run build WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Web VERBATIM ) diff --git a/Engine/Source/Common/CMakeLists.txt b/Engine/Source/Common/CMakeLists.txt index 674e6a9e..7df3b82e 100644 --- a/Engine/Source/Common/CMakeLists.txt +++ b/Engine/Source/Common/CMakeLists.txt @@ -1,16 +1,16 @@ -file(GLOB_RECURSE SOURCES Src/*.cpp) +file(GLOB_RECURSE sources Src/*.cpp) exp_add_library( NAME Common TYPE STATIC - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include PUBLIC_MERGE_LIB rapidjson debugbreak cityhash taskflow ) -file(GLOB TEST_SOURCES Test/*.cpp) +file(GLOB test_sources Test/*.cpp) exp_add_test( NAME Common.Test INC Test - SRC ${TEST_SOURCES} + SRC ${test_sources} LIB Common ) diff --git a/Engine/Source/Core/CMakeLists.txt b/Engine/Source/Core/CMakeLists.txt index cc02b910..22de49fc 100644 --- a/Engine/Source/Core/CMakeLists.txt +++ b/Engine/Source/Core/CMakeLists.txt @@ -1,16 +1,16 @@ -file(GLOB SOURCES Src/*.cpp) +file(GLOB sources Src/*.cpp) exp_add_library( NAME Core TYPE SHARED - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Common PUBLIC_MERGE_LIB clipp ) -file(GLOB TEST_SOURCES Test/*.cpp) +file(GLOB test_sources Test/*.cpp) exp_add_test( NAME Core.Test - SRC ${TEST_SOURCES} + SRC ${test_sources} LIB Core ) diff --git a/Engine/Source/Launch/CMakeLists.txt b/Engine/Source/Launch/CMakeLists.txt index 857208f4..0ca13e99 100644 --- a/Engine/Source/Launch/CMakeLists.txt +++ b/Engine/Source/Launch/CMakeLists.txt @@ -1,8 +1,8 @@ -file(GLOB_RECURSE SOURCES Src/*.cpp) +file(GLOB_RECURSE sources Src/*.cpp) exp_add_library( NAME Launch TYPE STATIC - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Runtime PUBLIC_MERGE_LIB glfw diff --git a/Engine/Source/Mirror/CMakeLists.txt b/Engine/Source/Mirror/CMakeLists.txt index 240bfb2f..74ec4d02 100644 --- a/Engine/Source/Mirror/CMakeLists.txt +++ b/Engine/Source/Mirror/CMakeLists.txt @@ -1,16 +1,16 @@ -file(GLOB SOURCES Src/*.cpp) +file(GLOB sources Src/*.cpp) exp_add_library( NAME Mirror TYPE SHARED - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Common ) -file(GLOB TEST_SOURCES Test/*.cpp) +file(GLOB test_sources Test/*.cpp) exp_add_test( NAME Mirror.Test - SRC ${TEST_SOURCES} + SRC ${test_sources} LIB Mirror INC Test REFLECT Test diff --git a/Engine/Source/RHI-DirectX12/CMakeLists.txt b/Engine/Source/RHI-DirectX12/CMakeLists.txt index 9b5c29b2..c7d29740 100644 --- a/Engine/Source/RHI-DirectX12/CMakeLists.txt +++ b/Engine/Source/RHI-DirectX12/CMakeLists.txt @@ -1,8 +1,8 @@ -file(GLOB SOURCES Src/*.cpp) +file(GLOB sources Src/*.cpp) exp_add_library( NAME RHI-DirectX12 TYPE SHARED - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include PUBLIC_LIB RHI d3d12 PUBLIC_MERGE_LIB DirectXHeaders dxgi d3dcompiler diff --git a/Engine/Source/RHI-Dummy/CMakeLists.txt b/Engine/Source/RHI-Dummy/CMakeLists.txt index 23b290d6..74b4e71b 100644 --- a/Engine/Source/RHI-Dummy/CMakeLists.txt +++ b/Engine/Source/RHI-Dummy/CMakeLists.txt @@ -1,8 +1,8 @@ -file(GLOB SOURCES Src/*.cpp) +file(GLOB sources Src/*.cpp) exp_add_library( NAME RHI-Dummy TYPE SHARED - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include PUBLIC_LIB RHI ) diff --git a/Engine/Source/RHI-Vulkan/CMakeLists.txt b/Engine/Source/RHI-Vulkan/CMakeLists.txt index 3dedd5fc..416fc8d1 100644 --- a/Engine/Source/RHI-Vulkan/CMakeLists.txt +++ b/Engine/Source/RHI-Vulkan/CMakeLists.txt @@ -1,10 +1,10 @@ -file(GLOB SOURCES Src/*.cpp) +file(GLOB sources Src/*.cpp) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - set(PLATFORM_SOURCES Src/Platform/Win32Surface.cpp) + set(platform_sources Src/Platform/Win32Surface.cpp) elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(PLATFORM_SOURCES Src/Platform/MacosSurface.mm) - set(PLATFORM_EXT_LIBS + set(platform_sources Src/Platform/MacosSurface.mm) + set(platform_ext_libs "-framework Cocoa" "-framework IOKit" "-framework CoreFoundation") @@ -13,9 +13,9 @@ endif() exp_add_library( NAME RHI-Vulkan TYPE SHARED - SRC ${SOURCES} ${PLATFORM_SOURCES} + SRC ${sources} ${platform_sources} PUBLIC_INC Include - PUBLIC_LIB RHI ${PLATFORM_EXT_LIBS} + PUBLIC_LIB RHI ${platform_ext_libs} PUBLIC_MERGE_LIB VulkanSDK spirv-cross VulkanMemoryAllocator ) diff --git a/Engine/Source/RHI/CMakeLists.txt b/Engine/Source/RHI/CMakeLists.txt index 55dc88ff..5b7d83f9 100644 --- a/Engine/Source/RHI/CMakeLists.txt +++ b/Engine/Source/RHI/CMakeLists.txt @@ -1,8 +1,8 @@ -file(GLOB SOURCES Src/*.cpp) +file(GLOB sources Src/*.cpp) exp_add_library( NAME RHI TYPE STATIC - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Core ) diff --git a/Engine/Source/Render/CMakeLists.txt b/Engine/Source/Render/CMakeLists.txt index fbd8cd6e..0a187690 100644 --- a/Engine/Source/Render/CMakeLists.txt +++ b/Engine/Source/Render/CMakeLists.txt @@ -2,28 +2,28 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") set(platform_libs VulkanSDK) endif() -file(GLOB SOURCES Src/*.cpp) +file(GLOB sources Src/*.cpp) exp_add_library( NAME Render.Static TYPE STATIC - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Core RHI PUBLIC_MERGE_LIB dxc spirv-cross ${platform_libs} ) -file(GLOB SHARED_SOURCES SharedSrc/*.cpp) +file(GLOB shader_sources SharedSrc/*.cpp) exp_add_library( NAME Render TYPE SHARED - SRC ${SHARED_SOURCES} + SRC ${shader_sources} PUBLIC_LIB Render.Static ) -file(GLOB TEST_SOURCES Test/*.cpp) +file(GLOB test_sources Test/*.cpp) exp_add_test( NAME Render.Test - SRC ${TEST_SOURCES} + SRC ${test_sources} LIB RHI Render.Static DEP_TARGET RHI-Dummy ) diff --git a/Engine/Source/Runtime/CMakeLists.txt b/Engine/Source/Runtime/CMakeLists.txt index 8c102a2f..fb9e838e 100644 --- a/Engine/Source/Runtime/CMakeLists.txt +++ b/Engine/Source/Runtime/CMakeLists.txt @@ -1,18 +1,18 @@ -file(GLOB_RECURSE SOURCES Src/*.cpp) +file(GLOB_RECURSE sources Src/*.cpp) exp_add_library( NAME Runtime TYPE SHARED - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include REFLECT Include PUBLIC_LIB Core Mirror Render PUBLIC_MERGE_LIB assimp-lib ) -file(GLOB TEST_SOURCES Test/*.cpp) +file(GLOB test_sources Test/*.cpp) exp_add_test( NAME Runtime.Test - SRC ${TEST_SOURCES} + SRC ${test_sources} LIB Runtime INC Test REFLECT Test diff --git a/Sample/CMakeLists.txt b/Sample/CMakeLists.txt index 71d6c2f7..e6383687 100644 --- a/Sample/CMakeLists.txt +++ b/Sample/CMakeLists.txt @@ -40,43 +40,43 @@ function(add_sample) endfunction() if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(PLATFORM_EXT_LIBS + set(platform_ext_libs "-framework Cocoa" "-framework IOKit" "-framework CoreFoundation") endif() -file(GLOB SOURCES Base/*.cpp) +file(GLOB sources Base/*.cpp) exp_add_library( NAME Sample-Base - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Base - PUBLIC_LIB RHI ${PLATFORM_EXT_LIBS} Render.Static + PUBLIC_LIB RHI ${platform_ext_libs} Render.Static PUBLIC_MERGE_LIB glfw clipp stb assimp-lib NOT_INSTALL ) -file(GLOB SOURCES RHI-Triangle/*.cpp) +file(GLOB sources RHI-Triangle/*.cpp) add_sample( NAME RHISample-Triangle - SRC ${SOURCES} + SRC ${sources} INC RHI-Triangle SHADER RHI-Triangle/Triangle.esl ) -file(GLOB SOURCES RHI-TexSampling/*.cpp) +file(GLOB sources RHI-TexSampling/*.cpp) add_sample( NAME RHISample-TexSampling - SRC ${SOURCES} + SRC ${sources} INC RHI-TexSampling SHADER RHI-TexSampling/TexSampling.esl IMAGE RHI-TexSampling/Awesomeface.png ) -file(GLOB SOURCES RHI-SSAO/*.cpp) +file(GLOB sources RHI-SSAO/*.cpp) add_sample( NAME RHISample-SSAO - SRC ${SOURCES} + SRC ${sources} INC RHI-SSAO SHADER RHI-SSAO/Shader/Gbuffer.esl @@ -87,28 +87,28 @@ add_sample( RHI-SSAO/Model/Voyager.gltf ) -file(GLOB SOURCES RHI-ParallelCompute/*.cpp) +file(GLOB sources RHI-ParallelCompute/*.cpp) add_sample( NAME RHISample-ParallelCompute - SRC ${SOURCES} + SRC ${sources} SHADER RHI-ParallelCompute/Compute.esl ) -file(GLOB SOURCES Rendering-Triangle/*.cpp) +file(GLOB sources Rendering-Triangle/*.cpp) add_sample( NAME RenderingSample-Triangle - SRC ${SOURCES} + SRC ${sources} INC Rendering-Triangle SHADER Rendering-Triangle/Triangle.esl ) -file(GLOB SOURCES Rendering-BaseTexture/*.cpp) +file(GLOB sources Rendering-BaseTexture/*.cpp) add_sample( - NAME Rendering-BaseTexture - SRC ${SOURCES} - INC Rendering-BaseTexture - SHADER Rendering-BaseTexture/BaseTexture.esl - IMAGE Rendering-BaseTexture/Awesomeface.png + NAME Rendering-BaseTexture + SRC ${sources} + INC Rendering-BaseTexture + SHADER Rendering-BaseTexture/BaseTexture.esl + IMAGE Rendering-BaseTexture/Awesomeface.png ) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index f06dc4cc..2d608c60 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -100,73 +100,73 @@ if (${VulkanSDK_READY}) if (NOT ${CI}) #see https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderLayerInterface.md if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - execute_process(COMMAND reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers" OUTPUT_VARIABLE LAYERS) - string(REGEX MATCH "VkLayer_khronos_validation\.json" MATCH_RESULT ${LAYERS}) - list(LENGTH MATCH_RESULT MATCH_RESULT_LENGTH) + execute_process(COMMAND reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers" OUTPUT_VARIABLE layers) + string(REGEX MATCH "VkLayer_khronos_validation\.json" match_result ${layers}) + list(LENGTH match_result match_result_length) - if (${MATCH_RESULT_LENGTH} GREATER 0) + if (${match_result_length} GREATER 0) message("Used registered validation layer in HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers") else () - set(VALIDATION_LAYER_JSON ${3RD_SOURCE_DIR}/VulkanSDK-Windows-${VULKAN_SDK_VERSION}/Bin/VkLayer_khronos_validation.json) - message("Found no registered validation layer, will register ${VALIDATION_LAYER_JSON} to reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers") - string(REPLACE "/" "\\" VALIDATION_LAYER_JSON ${VALIDATION_LAYER_JSON}) - execute_process(COMMAND PowerShell -Command "Start-Process reg -ArgumentList 'add HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers /v ${VALIDATION_LAYER_JSON} /t REG_DWORD /d 0' -Verb RunAs") + set(validation_layer_json ${3RD_SOURCE_DIR}/VulkanSDK-Windows-${VULKAN_SDK_VERSION}/Bin/VkLayer_khronos_validation.json) + message("Found no registered validation layer, will register ${validation_layer_json} to reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers") + string(REPLACE "/" "\\" validation_layer_json ${validation_layer_json}) + execute_process(COMMAND PowerShell -Command "Start-Process reg -ArgumentList 'add HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers /v ${validation_layer_json} /t REG_DWORD /d 0' -Verb RunAs") endif () else (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") # new version of vulkaninfo application use volk to perform dynamic loading, which need libvulkan.dylib in working directory or system, # so if vulkaninfo print initialized failed, we need copy vulkan dynamic lib to working directory - set(PLATFORM_VULKAN_SDK_DIR ${CMAKE_SOURCE_DIR}/ThirdParty/Lib/VulkanSDK-Darwin-${VULKAN_SDK_VERSION}/macOS) - execute_process(COMMAND ${PLATFORM_VULKAN_SDK_DIR}/bin/vulkaninfo WORKING_DIRECTORY ${PLATFORM_VULKAN_SDK_DIR}/bin OUTPUT_VARIABLE VULKAN_INFO ERROR_VARIABLE VULKAN_INFO) - string(REGEX MATCH "Failed to initialize" MATCH_RESULT ${VULKAN_INFO}) - list(LENGTH MATCH_RESULT MATCH_RESULT_LENGTH) - if (${MATCH_RESULT_LENGTH} GREATER 0) - set(SRC_FILE ${PLATFORM_VULKAN_SDK_DIR}/lib/libvulkan.dylib) - set(DST_FILE ${PLATFORM_VULKAN_SDK_DIR}/bin/libvulkan.dylib) - message("vulkaninfo initialized failed, perform vulkan dynamic library copy: ${SRC_FILE} -> ${DST_FILE}") - file(COPY_FILE ${SRC_FILE} ${DST_FILE} ONLY_IF_DIFFERENT) + set(platform_vulkan_sdk_dir ${CMAKE_SOURCE_DIR}/ThirdParty/Lib/VulkanSDK-Darwin-${VULKAN_SDK_VERSION}/macOS) + execute_process(COMMAND ${platform_vulkan_sdk_dir}/bin/vulkaninfo WORKING_DIRECTORY ${platform_vulkan_sdk_dir}/bin OUTPUT_VARIABLE vulkan_info ERROR_VARIABLE vulkan_info) + string(REGEX MATCH "Failed to initialize" match_result ${vulkan_info}) + list(LENGTH match_result match_result_length) + if (${match_result_length} GREATER 0) + set(src_file ${platform_vulkan_sdk_dir}/lib/libvulkan.dylib) + set(dst_file ${platform_vulkan_sdk_dir}/bin/libvulkan.dylib) + message("vulkaninfo initialized failed, perform vulkan dynamic library copy: ${src_file} -> ${dst_file}") + file(COPY_FILE ${src_file} ${dst_file} ONLY_IF_DIFFERENT) else () message("vulkaninfo test success") endif () # check drivers - execute_process(COMMAND ${PLATFORM_VULKAN_SDK_DIR}/bin/vulkaninfo WORKING_DIRECTORY ${PLATFORM_VULKAN_SDK_DIR}/bin OUTPUT_VARIABLE VULKAN_INFO ERROR_VARIABLE VULKAN_INFO) - string(REGEX MATCH "ERROR_INCOMPATIBLE_DRIVER" MATCH_RESULT ${VULKAN_INFO}) - list(LENGTH MATCH_RESULT MATCH_RESULT_LENGTH) - if (${MATCH_RESULT_LENGTH} GREATER 0) + execute_process(COMMAND ${platform_vulkan_sdk_dir}/bin/vulkaninfo WORKING_DIRECTORY ${platform_vulkan_sdk_dir}/bin OUTPUT_VARIABLE vulkan_info ERROR_VARIABLE vulkan_info) + string(REGEX MATCH "ERROR_INCOMPATIBLE_DRIVER" match_result ${vulkan_info}) + list(LENGTH match_result match_result_length) + if (${match_result_length} GREATER 0) message("there is no drivers found for vulkan, copy and rewrite driver files to ~/.config/vulkan/icd.d") - get_filename_component(DRIVERS_DIR_ABSOLUTE ~/.config/vulkan/icd.d ABSOLUTE) - if (NOT EXISTS ${DRIVERS_DIR_ABSOLUTE}) - file(MAKE_DIRECTORY ${DRIVERS_DIR_ABSOLUTE}) + get_filename_component(drivers_dir_absolute ~/.config/vulkan/icd.d ABSOLUTE) + if (NOT EXISTS ${drivers_dir_absolute}) + file(MAKE_DIRECTORY ${drivers_dir_absolute}) endif () - file(GLOB DRIVER_FILES ${PLATFORM_VULKAN_SDK_DIR}/share/vulkan/icd.d/*.json) - foreach (DRIVER_FILE ${DRIVER_FILES}) - file(READ ${DRIVER_FILE} FILE_CONTENT) - string(REPLACE "../../../lib" "${PLATFORM_VULKAN_SDK_DIR}/lib" FILE_CONTENT ${FILE_CONTENT}) - get_filename_component(FILE_NAME ${DRIVER_FILE} NAME) - file(WRITE ${DRIVERS_DIR_ABSOLUTE}/${FILE_NAME} ${FILE_CONTENT}) + file(GLOB driver_files ${platform_vulkan_sdk_dir}/share/vulkan/icd.d/*.json) + foreach (driver_file ${driver_files}) + file(READ ${driver_file} file_content) + string(REPLACE "../../../lib" "${platform_vulkan_sdk_dir}/lib" file_content ${file_content}) + get_filename_component(file_name ${driver_file} NAME) + file(WRITE ${drivers_dir_absolute}/${file_name} ${file_content}) endforeach () else () message("found vulkan drivers installed in system, will use it") endif () # check layers - execute_process(COMMAND ${PLATFORM_VULKAN_SDK_DIR}/bin/vulkaninfo WORKING_DIRECTORY ${PLATFORM_VULKAN_SDK_DIR}/bin OUTPUT_VARIABLE VULKAN_INFO ERROR_VARIABLE VULKAN_INFO) - string(REGEX MATCH "Layers:\n=======" MATCH_RESULT ${VULKAN_INFO}) - list(LENGTH MATCH_RESULT MATCH_RESULT_LENGTH) - if (${MATCH_RESULT_LENGTH} GREATER 0) + execute_process(COMMAND ${platform_vulkan_sdk_dir}/bin/vulkaninfo WORKING_DIRECTORY ${platform_vulkan_sdk_dir}/bin OUTPUT_VARIABLE vulkan_info ERROR_VARIABLE vulkan_info) + string(REGEX MATCH "Layers:\n=======" match_result ${vulkan_info}) + list(LENGTH match_result match_result_length) + if (${match_result_length} GREATER 0) message("there is no layers found for vulkan, copy and rewrite layer files to ~/.config/vulkan/explicit_layer.d") - get_filename_component(LAYERS_DIR_ABSOLUTE ~/.config/vulkan/explicit_layer.d ABSOLUTE) - if (NOT EXISTS ${LAYERS_DIR_ABSOLUTE}) - file(MAKE_DIRECTORY ${LAYERS_DIR_ABSOLUTE}) + get_filename_component(layers_dir_absolute ~/.config/vulkan/explicit_layer.d ABSOLUTE) + if (NOT EXISTS ${layers_dir_absolute}) + file(MAKE_DIRECTORY ${layers_dir_absolute}) endif () - file(GLOB LAYER_FILES ${PLATFORM_VULKAN_SDK_DIR}/share/vulkan/explicit_layer.d/*.json) - foreach (LAYER_FILE ${LAYER_FILES}) - file(READ ${LAYER_FILE} FILE_CONTENT) - string(REPLACE "../../../lib" "${PLATFORM_VULKAN_SDK_DIR}/lib" FILE_CONTENT ${FILE_CONTENT}) - get_filename_component(FILE_NAME ${LAYER_FILE} NAME) - file(WRITE ${LAYERS_DIR_ABSOLUTE}/${FILE_NAME} ${FILE_CONTENT}) + file(GLOB layer_files ${platform_vulkan_sdk_dir}/share/vulkan/explicit_layer.d/*.json) + foreach (layer_file ${layer_files}) + file(READ ${layer_file} file_content) + string(REPLACE "../../../lib" "${platform_vulkan_sdk_dir}/lib" file_content ${file_content}) + get_filename_component(file_name ${layer_file} NAME) + file(WRITE ${layers_dir_absolute}/${file_name} ${file_content}) endforeach () else () message("found vulkan layers installed in system, will use it") diff --git a/Tool/MirrorTool/CMakeLists.txt b/Tool/MirrorTool/CMakeLists.txt index af9a5f68..9f05edf6 100644 --- a/Tool/MirrorTool/CMakeLists.txt +++ b/Tool/MirrorTool/CMakeLists.txt @@ -1,17 +1,17 @@ -file(GLOB SOURCES Src/*.cpp) +file(GLOB sources Src/*.cpp) exp_add_library( NAME MirrorTool.Static - SRC ${SOURCES} + SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Mirror PUBLIC_MERGE_LIB llvm-clang clipp NOT_INSTALL ) -file(GLOB EXE_SOURCES ExeSrc/*.cpp) +file(GLOB exe_sources ExeSrc/*.cpp) exp_add_executable( NAME MirrorTool - SRC ${EXE_SOURCES} + SRC ${exe_sources} INC Include LIB MirrorTool.Static ) From d75488b0d125c2c98904959255657f858fdc35f3 Mon Sep 17 00:00:00 2001 From: kindem Date: Wed, 26 Nov 2025 19:34:10 +0800 Subject: [PATCH 02/44] refactor: gather include dir for mirror tool in a new way --- CMake/Target.cmake | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/CMake/Target.cmake b/CMake/Target.cmake index 5b883de9..1b50c40f 100644 --- a/CMake/Target.cmake +++ b/CMake/Target.cmake @@ -135,32 +135,32 @@ function(exp_add_resources_copy_command) add_dependencies(${arg_NAME} ${copy_res_target_name}) endfunction() -function(exp_gather_target_include_dirs) +function(exp_gather_target_libs) set(options "") set(singleValueArgs NAME OUTPUT) set(multiValueArgs "") cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - if (NOT (TARGET ${arg_NAME})) - return() - endif() - - get_target_property(target_incs ${arg_NAME} INTERFACE_INCLUDE_DIRECTORIES) - if (NOT ("${target_incs}" STREQUAL "target_incs-NOTFOUND")) - foreach(target_inc ${target_incs}) - list(APPEND result ${target_inc}) - endforeach() - endif() + string(REGEX MATCH "\\$\\" match ${arg_NAME}) + if (match) + set(${arg_OUTPUT} "" PARENT_SCOPE) + endif () get_target_property(target_libs ${arg_NAME} LINK_LIBRARIES) if (NOT ("${target_libs}" STREQUAL "target_libs-NOTFOUND")) foreach(target_lib ${target_libs}) - exp_gather_target_include_dirs( + string(REGEX MATCH "\\$\\" match ${target_lib}) + if (match) + continue() + endif () + + list(APPEND result ${target_lib}) + exp_gather_target_libs( NAME ${target_lib} - OUTPUT lib_incs + OUTPUT libs ) - foreach(lib_inc ${lib_incs}) - list(APPEND result ${lib_inc}) + foreach(lib ${libs}) + list(APPEND result ${lib}) endforeach() endforeach() endif() @@ -189,12 +189,12 @@ function(exp_add_mirror_info_source_generation_target) endif() if (DEFINED arg_LIB) foreach (l ${arg_LIB}) - exp_gather_target_include_dirs( + exp_gather_target_libs( NAME ${l} - OUTPUT target_incs + OUTPUT target_libs ) - foreach (i ${target_incs}) - list(APPEND inc ${i}) + foreach (l ${target_libs}) + list(APPEND inc $) endforeach () endforeach() endif() From afe45560d881b91f3efab8caef73ddf477287347 Mon Sep 17 00:00:00 2001 From: kindem Date: Thu, 27 Nov 2025 21:13:44 +0800 Subject: [PATCH 03/44] feat: use conan to manage some third party packages --- CMake/Target.cmake | 14 +- CMakeLists.txt | 8 + Editor/CMakeLists.txt | 2 +- Engine/Source/Common/CMakeLists.txt | 2 +- Engine/Source/Common/Test/HashTest.cpp | 2 +- Engine/Source/RHI-DirectX12/CMakeLists.txt | 2 +- Engine/Source/Test/CMakeLists.txt | 2 +- README.md | 3 + Sample/CMakeLists.txt | 2 +- ThirdParty/CMakeLists.txt | 128 +--- Tool/MirrorTool/ExeSrc/Main.cpp | 51 +- conan_provider.cmake | 706 +++++++++++++++++++++ conanfile.txt | 11 + 13 files changed, 796 insertions(+), 137 deletions(-) create mode 100644 conan_provider.cmake create mode 100644 conanfile.txt diff --git a/CMake/Target.cmake b/CMake/Target.cmake index 1b50c40f..c775dd3e 100644 --- a/CMake/Target.cmake +++ b/CMake/Target.cmake @@ -189,12 +189,13 @@ function(exp_add_mirror_info_source_generation_target) endif() if (DEFINED arg_LIB) foreach (l ${arg_LIB}) + list(APPEND inc $) exp_gather_target_libs( NAME ${l} OUTPUT target_libs ) - foreach (l ${target_libs}) - list(APPEND inc $) + foreach (tl ${target_libs}) + list(APPEND inc $) endforeach () endforeach() endif() @@ -415,8 +416,13 @@ function(exp_add_library) endforeach () foreach (inc ${public_inc}) - get_filename_component(absolute_inc ${inc} ABSOLUTE) - list(APPEND public_build_inc $) + string(REGEX MATCH "\\$\\<.+\\>" match ${inc}) + if (match) + list(APPEND public_build_inc $) + else () + get_filename_component(absolute_inc ${inc} ABSOLUTE) + list(APPEND public_build_inc $) + endif () endforeach () target_include_directories( ${arg_NAME} diff --git a/CMakeLists.txt b/CMakeLists.txt index 201559d9..52f1712b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,12 @@ cmake_minimum_required(VERSION 3.25) + +get_cmake_property(generator_is_multi_config GENERATOR_IS_MULTI_CONFIG) +if (${generator_is_multi_config}) + # TODO only install release config, need some deals in exp_add_library + set(CONAN_INSTALL_BUILD_CONFIGURATIONS "Debug;Release;RelWithDebInfo" CACHE STRING "" FORCE) +endif () +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES ${CMAKE_SOURCE_DIR}/conan_provider.cmake CACHE PATH "" FORCE) + project(Explosion) option(BUILD_EDITOR "Build Explosion editor" ON) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 4d236277..2c116b85 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -15,7 +15,7 @@ endif () set(editor_includes Include) set(editor_qt_libs Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Quick Qt6::WebEngineWidgets) -set(editor_libs Core RHI Runtime cpp-httplib ${editor_qt_libs}) +set(editor_libs Core RHI Runtime httplib::httplib ${editor_qt_libs}) foreach (QT_LIB ${editor_qt_libs}) string(REPLACE "::" "" QT_RAW_LIB ${QT_LIB}) diff --git a/Engine/Source/Common/CMakeLists.txt b/Engine/Source/Common/CMakeLists.txt index 7df3b82e..278f299d 100644 --- a/Engine/Source/Common/CMakeLists.txt +++ b/Engine/Source/Common/CMakeLists.txt @@ -4,7 +4,7 @@ exp_add_library( TYPE STATIC SRC ${sources} PUBLIC_INC Include - PUBLIC_MERGE_LIB rapidjson debugbreak cityhash taskflow + PUBLIC_MERGE_LIB rapidjson debugbreak cityhash::cityhash Taskflow::Taskflow ) file(GLOB test_sources Test/*.cpp) diff --git a/Engine/Source/Common/Test/HashTest.cpp b/Engine/Source/Common/Test/HashTest.cpp index 1e0f3dc7..532085fc 100644 --- a/Engine/Source/Common/Test/HashTest.cpp +++ b/Engine/Source/Common/Test/HashTest.cpp @@ -11,7 +11,7 @@ TEST(HashTest, CityHashTest) { constexpr std::string_view testString = "Hello, World"; - ASSERT_EQ(4508847345234768385, Common::HashUtils::CityHash(testString.data(), testString.size())); + ASSERT_EQ(7750308374451649530, Common::HashUtils::CityHash(testString.data(), testString.size())); } TEST(HashTest, StrCrc32Test) diff --git a/Engine/Source/RHI-DirectX12/CMakeLists.txt b/Engine/Source/RHI-DirectX12/CMakeLists.txt index c7d29740..e42791ca 100644 --- a/Engine/Source/RHI-DirectX12/CMakeLists.txt +++ b/Engine/Source/RHI-DirectX12/CMakeLists.txt @@ -5,5 +5,5 @@ exp_add_library( SRC ${sources} PUBLIC_INC Include PUBLIC_LIB RHI d3d12 - PUBLIC_MERGE_LIB DirectXHeaders dxgi d3dcompiler + PUBLIC_MERGE_LIB Microsoft::DirectX-Headers dxgi d3dcompiler ) diff --git a/Engine/Source/Test/CMakeLists.txt b/Engine/Source/Test/CMakeLists.txt index 1cf82677..b1a388f5 100644 --- a/Engine/Source/Test/CMakeLists.txt +++ b/Engine/Source/Test/CMakeLists.txt @@ -4,5 +4,5 @@ exp_add_library( SRC Src/Main.cpp PUBLIC_INC Include PUBLIC_LIB Core - PUBLIC_MERGE_LIB googletest + PUBLIC_MERGE_LIB GTest::gtest ) \ No newline at end of file diff --git a/README.md b/README.md index ec3ab662..722ce1f0 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,9 @@ Explosion is a cross-platform C++ game engine, based on modern graphics api (aka You need install those tools to system by yourself and add them to path: * [Python3](https://www.python.org/downloads/) +* [Conan](https://github.com/conan-io/conan) * [CMake](https://cmake.org/download/) +* [Ninja](https://github.com/ninja-build/ninja) * [Node.js](https://nodejs.org/en/download) build steps of engine may use them. @@ -110,6 +112,7 @@ sudo xcode-select -s /Library/Developer/CommandLineTools Thanks all those following projects: +* [Conan](https://github.com/conan-io/conan) * [DirectX-Headers](https://github.com/microsoft/DirectX-Headers) * [Vulkan](https://www.vulkan.org/) * [DirectXShaderCompiler](https://github.com/microsoft/DirectXShaderCompiler) diff --git a/Sample/CMakeLists.txt b/Sample/CMakeLists.txt index e6383687..3539d89b 100644 --- a/Sample/CMakeLists.txt +++ b/Sample/CMakeLists.txt @@ -52,7 +52,7 @@ exp_add_library( SRC ${sources} PUBLIC_INC Base PUBLIC_LIB RHI ${platform_ext_libs} Render.Static - PUBLIC_MERGE_LIB glfw clipp stb assimp-lib + PUBLIC_MERGE_LIB glfw clipp stb::stb assimp-lib NOT_INSTALL ) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 2d608c60..0df238a5 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -58,21 +58,6 @@ function(should_setup_3rd_package) set(${arg_NAME}_READY FALSE PARENT_SCOPE) endfunction() -# DirectX 12 Headers -download_and_setup_3rd_package( - NAME DirectXHeaders - PLATFORM Windows - VERSION 1.4.9 - HASH 0313c5145214dda2a183af97212878482aafbb2433d4f0ec0a2efeec7cc9ef2a -) -if (${DirectXHeaders_READY}) - exp_add_3rd_header_only_package( - NAME DirectXHeaders - SOURCE_DIR ${DirectXHeaders_SOURCE_DIR} - INCLUDE $/include - ) -endif () - # VulkanSDK set(VULKAN_SDK_VERSION 1.3.296.0) download_and_setup_3rd_package( @@ -208,26 +193,6 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") endif () endif () -# GLFW -download_and_setup_3rd_package( - NAME glfw - PLATFORM All - VERSION 4.0 - HASH 2483836f085d616acaa48f6dc8efec5239f6a538c3a25d13fdc6a7afb2cce1d4 -) -if (${glfw_READY}) - exp_add_3rd_cmake_package( - NAME glfw - SOURCE_DIR ${glfw_SOURCE_DIR} - BINARY_DIR ${glfw_BINARY_DIR} - INSTALL_DIR ${glfw_INSTALL_DIR} - CMAKE_ARG -DUSE_MSVC_RUNTIME_LIBRARY_DLL=OFF -DGLFW_BUILD_EXAMPLES=OFF -DGLFW_BUILD_TESTS=OFF -DGLFW_BUILD_DOCS=OFF - INCLUDE $/include - LINK $/lib - LIB glfw3 - ) -endif () - # clipp download_and_setup_3rd_package( NAME clipp @@ -284,77 +249,6 @@ if (${llvm-clang_READY}) ) endif () -# Google Test -download_and_setup_3rd_package( - NAME googletest - PLATFORM All - VERSION 1.11.0 - HASH bb1146f051868868b96fa83069d4d05f0e05216b5c3f697859c591fd73b93a86 -) -if (${googletest_READY}) - exp_add_3rd_cmake_package( - NAME googletest - SOURCE_DIR ${googletest_SOURCE_DIR} - BINARY_DIR ${googletest_BINARY_DIR} - INSTALL_DIR ${googletest_INSTALL_DIR} - CMAKE_ARG -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -Dgtest_force_shared_crt=ON - INCLUDE $/include - LINK $/lib - LIB gtest$,d,> gmock$,d,> - ) -endif () - -# TaskFlow -download_and_setup_3rd_package( - NAME taskflow - PLATFORM All - VERSION 3.4.0 - HASH 774e23d5b6be17a5482d70ffd76ba4ccfd8821c86b7c3f0bcdcd5d96bc264041 -) -if (${taskflow_READY}) - exp_add_3rd_header_only_package( - NAME taskflow - SOURCE_DIR ${taskflow_SOURCE_DIR} - INSTALL_DIR ${taskflow_INSTALL_DIR} - INSTALL_FILES taskflow - INCLUDE $ - ) -endif () - -# CityHash -download_and_setup_3rd_package( - NAME cityhash - PLATFORM All - VERSION forked-2f248cfbf88d0895d069258e4971b5f2fc3a9f19 - HASH 5acf325794585578915dfa7fbac9eb2ca436ffe4831b05c40d1f286b68d7ac20 -) -if (${cityhash_READY}) - exp_add_3rd_cmake_package( - NAME cityhash - SOURCE_DIR ${cityhash_SOURCE_DIR} - BINARY_DIR ${cityhash_BINARY_DIR} - INSTALL_DIR ${cityhash_INSTALL_DIR} - INCLUDE $/include - LINK $/lib - LIB city - ) -endif () - -# stb-image -download_and_setup_3rd_package( - NAME stb - PLATFORM All - VERSION master-8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55 - HASH 32e28f89a85b3bb6749e8caed9eb5226f7f5956769005d2b5a41d48d9481d90c -) -if (${stb_READY}) - exp_add_3rd_header_only_package( - NAME stb - SOURCE_DIR ${stb_SOURCE_DIR} - INCLUDE $ - ) -endif () - # spirv-cross download_and_setup_3rd_package( NAME spirv-cross @@ -452,17 +346,13 @@ if (${rapidjson_READY}) ) endif () -# cpp-httplib -download_and_setup_3rd_package( - NAME cpp-httplib - PLATFORM All - VERSION 0.24.0 - HASH a0320b106f4a8f945ec2556e62fffab05b068f2ddfff99c6a367b2e16c14bde1 -) -if (${cpp-httplib_READY}) - exp_add_3rd_header_only_package( - NAME cpp-httplib - SOURCE_DIR ${cpp-httplib_SOURCE_DIR} - INCLUDE $ - ) +# conan managed +find_package(httplib REQUIRED GLOBAL) +find_package(glfw3 REQUIRED GLOBAL) +find_package(stb REQUIRED GLOBAL) +find_package(cityhash REQUIRED GLOBAL) +find_package(GTest REQUIRED GLOBAL) +find_package(Taskflow REQUIRED GLOBAL) +if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + find_package(DirectX-Headers REQUIRED GLOBAL) endif () diff --git a/Tool/MirrorTool/ExeSrc/Main.cpp b/Tool/MirrorTool/ExeSrc/Main.cpp index 5c0e0965..855a5382 100644 --- a/Tool/MirrorTool/ExeSrc/Main.cpp +++ b/Tool/MirrorTool/ExeSrc/Main.cpp @@ -9,15 +9,32 @@ #include #include #include +#include #include #define OUTPUT_FULL_CMDLINE 0 +static std::vector ProcessHeaderDirs(const std::vector& headerDirs) +{ + std::unordered_set duplicated; + std::vector result; + for (const auto& headerDir : headerDirs) { + for (auto splitHeaderDirs = Common::StringUtils::Split(headerDir, ";"); + const auto& splitHeaderDir : splitHeaderDirs) { + if (duplicated.contains(splitHeaderDir)) { + continue; + } + result.emplace_back(splitHeaderDir); + duplicated.emplace(splitHeaderDir); + } + } + return result; +} + int main(int argc, char* argv[]) // NOLINT { AutoCoutFlush; -#if OUTPUT_FULL_CMDLINE std::stringstream fullCmdline; for (auto i = 0; i < argc; i++) { fullCmdline << argv[i]; @@ -25,8 +42,7 @@ int main(int argc, char* argv[]) // NOLINT fullCmdline << " "; } } - std::cout << fullCmdline.str() << std::endl; -#endif + const std::string fullCmdLineStr = fullCmdline.str(); std::string inputFile; std::string outputFile; @@ -50,28 +66,47 @@ int main(int argc, char* argv[]) // NOLINT for (auto& headerDir : headerDirs) { headerDir = Common::Path(headerDir).String(); } + headerDirs = ProcessHeaderDirs(headerDirs); + + auto outputErrorWithDebugContext = [fullCmdLineStr, inputFile, outputFile, headerDirs, frameworkDirs, dynamic](const std::string& error) -> void { + std::cout << "MirrorTool fatal error:" << Common::newline; + std::cout << error << Common::newline; + std::cout << "MirrorTool debug context: " << Common::newline; + std::cout << "[fullCmdLine] " << fullCmdLineStr << Common::newline; + std::cout << "[dynamic] " << dynamic << Common::newline; + std::cout << "[inputFile] " << inputFile << Common::newline; + std::cout << "[outputFile] " << outputFile << Common::newline; + std::cout << "[headerDirs]" << Common::newline; + for (const auto& headerDir : headerDirs) { + std::cout << headerDir << Common::newline; + } + std::cout << "[frameworkDirs]" << Common::newline; + for (const auto& frameworkDir : frameworkDirs) { + std::cout << frameworkDir << Common::newline; + } + std::cout << Common::newline; + }; if (!inputFile.ends_with(".h")) { - std::cout << "input header file must ends with .h" << Common::newline; + outputErrorWithDebugContext("input header file must ends with .h"); return 1; } if (!outputFile.ends_with(".cpp")) { - std::cout << "output file must ends with .cpp" << Common::newline; + outputErrorWithDebugContext("output file must ends with .cpp"); return 1; } MirrorTool::Parser parser(inputFile, headerDirs, frameworkDirs); auto [parseSuccess, parseResultOrError] = parser.Parse(); - if (!parseSuccess) { - std::cout << std::get(parseResultOrError) << Common::newline; + outputErrorWithDebugContext(std::get(parseResultOrError)); return 1; } MirrorTool::Generator generator(inputFile, outputFile, headerDirs, std::get(parseResultOrError), dynamic); if (auto [generateSuccess, generateError] = generator.Generate(); !generateSuccess) { - std::cout << generateError << Common::newline; + outputErrorWithDebugContext(generateError); return 1; } return 0; diff --git a/conan_provider.cmake b/conan_provider.cmake new file mode 100644 index 00000000..2d9f4e7f --- /dev/null +++ b/conan_provider.cmake @@ -0,0 +1,706 @@ +# The MIT License (MIT) +# +# Copyright (c) 2024 JFrog +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +set(CONAN_MINIMUM_VERSION 2.0.5) + +# Create a new policy scope and set the minimum required cmake version so the +# features behind a policy setting like if(... IN_LIST ...) behaves as expected +# even if the parent project does not specify a minimum cmake version or a minimum +# version less than this module requires (e.g. 3.0) before the first project() call. +# (see: https://cmake.org/cmake/help/latest/variable/CMAKE_PROJECT_TOP_LEVEL_INCLUDES.html) +# +# The policy-affecting calls like cmake_policy(SET...) or `cmake_minimum_required` only +# affects the current policy scope, i.e. between the PUSH and POP in this case. +# +# https://cmake.org/cmake/help/book/mastering-cmake/chapter/Policies.html#the-policy-stack +cmake_policy(PUSH) +cmake_minimum_required(VERSION 3.24) + + +function(detect_os os os_api_level os_sdk os_subsystem os_version) + # it could be cross compilation + message(STATUS "CMake-Conan: cmake_system_name=${CMAKE_SYSTEM_NAME}") + if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic") + if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(${os} Macos PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX") + set(${os} Neutrino PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "CYGWIN") + set(${os} Windows PARENT_SCOPE) + set(${os_subsystem} cygwin PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME MATCHES "^MSYS") + set(${os} Windows PARENT_SCOPE) + set(${os_subsystem} msys2 PARENT_SCOPE) + elseif(CMAKE_SYSTEM_NAME STREQUAL "Emscripten") + # https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L17C1-L17C34 + set(${os} Emscripten PARENT_SCOPE) + else() + set(${os} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Android") + if(DEFINED ANDROID_PLATFORM) + string(REGEX MATCH "[0-9]+" _os_api_level ${ANDROID_PLATFORM}) + elseif(DEFINED CMAKE_SYSTEM_VERSION) + set(_os_api_level ${CMAKE_SYSTEM_VERSION}) + endif() + message(STATUS "CMake-Conan: android api level=${_os_api_level}") + set(${os_api_level} ${_os_api_level} PARENT_SCOPE) + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS") + # CMAKE_OSX_SYSROOT contains the full path to the SDK for MakeFile/Ninja + # generators, but just has the original input string for Xcode. + if(NOT IS_DIRECTORY ${CMAKE_OSX_SYSROOT}) + set(_os_sdk ${CMAKE_OSX_SYSROOT}) + else() + if(CMAKE_OSX_SYSROOT MATCHES Simulator) + set(apple_platform_suffix simulator) + else() + set(apple_platform_suffix os) + endif() + if(CMAKE_OSX_SYSROOT MATCHES AppleTV) + set(_os_sdk "appletv${apple_platform_suffix}") + elseif(CMAKE_OSX_SYSROOT MATCHES iPhone) + set(_os_sdk "iphone${apple_platform_suffix}") + elseif(CMAKE_OSX_SYSROOT MATCHES Watch) + set(_os_sdk "watch${apple_platform_suffix}") + endif() + endif() + if(DEFINED os_sdk) + message(STATUS "CMake-Conan: cmake_osx_sysroot=${CMAKE_OSX_SYSROOT}") + set(${os_sdk} ${_os_sdk} PARENT_SCOPE) + endif() + if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET) + message(STATUS "CMake-Conan: cmake_osx_deployment_target=${CMAKE_OSX_DEPLOYMENT_TARGET}") + set(${os_version} ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE) + endif() + endif() + endif() +endfunction() + + +function(detect_arch arch) + # CMAKE_OSX_ARCHITECTURES can contain multiple architectures, but Conan only supports one. + # Therefore this code only finds one. If the recipes support multiple architectures, the + # build will work. Otherwise, there will be a linker error for the missing architecture(s). + if(DEFINED CMAKE_OSX_ARCHITECTURES) + string(REPLACE " " ";" apple_arch_list "${CMAKE_OSX_ARCHITECTURES}") + list(LENGTH apple_arch_list apple_arch_count) + if(apple_arch_count GREATER 1) + message(WARNING "CMake-Conan: Multiple architectures detected, this will only work if Conan recipe(s) produce fat binaries.") + endif() + endif() + if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS" AND NOT CMAKE_OSX_ARCHITECTURES STREQUAL "") + set(host_arch ${CMAKE_OSX_ARCHITECTURES}) + elseif(MSVC) + set(host_arch ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}) + else() + set(host_arch ${CMAKE_SYSTEM_PROCESSOR}) + endif() + if(host_arch MATCHES "aarch64|arm64|ARM64") + set(_arch armv8) + elseif(host_arch MATCHES "armv7|armv7-a|armv7l|ARMV7") + set(_arch armv7) + elseif(host_arch MATCHES armv7s) + set(_arch armv7s) + elseif(host_arch MATCHES "i686|i386|X86") + set(_arch x86) + elseif(host_arch MATCHES "AMD64|amd64|x86_64|x64") + set(_arch x86_64) + endif() + if(EMSCRIPTEN) + # https://github.com/emscripten-core/emscripten/blob/4.0.6/cmake/Modules/Platform/Emscripten.cmake#L294C1-L294C80 + set(_arch wasm) + endif() + message(STATUS "CMake-Conan: cmake_system_processor=${_arch}") + set(${arch} ${_arch} PARENT_SCOPE) +endfunction() + + +function(detect_cxx_standard cxx_standard) + set(${cxx_standard} ${CMAKE_CXX_STANDARD} PARENT_SCOPE) + if(CMAKE_CXX_EXTENSIONS) + set(${cxx_standard} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE) + endif() +endfunction() + + +macro(detect_gnu_libstdcxx) + # _conan_is_gnu_libstdcxx true if GNU libstdc++ + check_cxx_source_compiles(" + #include + #if !defined(__GLIBCXX__) && !defined(__GLIBCPP__) + static_assert(false); + #endif + int main(){}" _conan_is_gnu_libstdcxx) + + # _conan_gnu_libstdcxx_is_cxx11_abi true if C++11 ABI + check_cxx_source_compiles(" + #include + static_assert(sizeof(std::string) != sizeof(void*), \"using libstdc++\"); + int main () {}" _conan_gnu_libstdcxx_is_cxx11_abi) + + set(_conan_gnu_libstdcxx_suffix "") + if(_conan_gnu_libstdcxx_is_cxx11_abi) + set(_conan_gnu_libstdcxx_suffix "11") + endif() + unset (_conan_gnu_libstdcxx_is_cxx11_abi) +endmacro() + + +macro(detect_libcxx) + # _conan_is_libcxx true if LLVM libc++ + check_cxx_source_compiles(" + #include + #if !defined(_LIBCPP_VERSION) + static_assert(false); + #endif + int main(){}" _conan_is_libcxx) +endmacro() + + +function(detect_lib_cxx lib_cxx) + if(CMAKE_SYSTEM_NAME STREQUAL "Android") + message(STATUS "CMake-Conan: android_stl=${CMAKE_ANDROID_STL_TYPE}") + set(${lib_cxx} ${CMAKE_ANDROID_STL_TYPE} PARENT_SCOPE) + return() + endif() + + include(CheckCXXSourceCompiles) + + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + detect_gnu_libstdcxx() + set(${lib_cxx} "libstdc++${_conan_gnu_libstdcxx_suffix}" PARENT_SCOPE) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "AppleClang") + set(${lib_cxx} "libc++" PARENT_SCOPE) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows") + # Check for libc++ + detect_libcxx() + if(_conan_is_libcxx) + set(${lib_cxx} "libc++" PARENT_SCOPE) + return() + endif() + + # Check for libstdc++ + detect_gnu_libstdcxx() + if(_conan_is_gnu_libstdcxx) + set(${lib_cxx} "libstdc++${_conan_gnu_libstdcxx_suffix}" PARENT_SCOPE) + return() + endif() + + # TODO: it would be an error if we reach this point + elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + # Do nothing - compiler.runtime and compiler.runtime_type + # should be handled separately: https://github.com/conan-io/cmake-conan/pull/516 + return() + else() + # TODO: unable to determine, ask user to provide a full profile file instead + endif() +endfunction() + + +function(detect_compiler compiler compiler_version compiler_runtime compiler_runtime_type) + if(DEFINED CMAKE_CXX_COMPILER_ID) + set(_compiler ${CMAKE_CXX_COMPILER_ID}) + set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION}) + else() + if(NOT DEFINED CMAKE_C_COMPILER_ID) + message(FATAL_ERROR "C or C++ compiler not defined") + endif() + set(_compiler ${CMAKE_C_COMPILER_ID}) + set(_compiler_version ${CMAKE_C_COMPILER_VERSION}) + endif() + + message(STATUS "CMake-Conan: CMake compiler=${_compiler}") + message(STATUS "CMake-Conan: CMake compiler version=${_compiler_version}") + + if(_compiler MATCHES MSVC) + set(_compiler "msvc") + string(SUBSTRING ${MSVC_VERSION} 0 3 _compiler_version) + # Configure compiler.runtime and compiler.runtime_type settings for MSVC + if(CMAKE_MSVC_RUNTIME_LIBRARY) + set(_msvc_runtime_library ${CMAKE_MSVC_RUNTIME_LIBRARY}) + else() + set(_msvc_runtime_library MultiThreaded$<$:Debug>DLL) # default value documented by CMake + endif() + + set(_KNOWN_MSVC_RUNTIME_VALUES "") + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded MultiThreadedDLL) + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreadedDebug MultiThreadedDebugDLL) + list(APPEND _KNOWN_MSVC_RUNTIME_VALUES MultiThreaded$<$:Debug> MultiThreaded$<$:Debug>DLL) + + # only accept the 6 possible values, otherwise we don't don't know to map this + if(NOT _msvc_runtime_library IN_LIST _KNOWN_MSVC_RUNTIME_VALUES) + message(FATAL_ERROR "CMake-Conan: unable to map MSVC runtime: ${_msvc_runtime_library} to Conan settings") + endif() + + # Runtime is "dynamic" in all cases if it ends in DLL + if(_msvc_runtime_library MATCHES ".*DLL$") + set(_compiler_runtime "dynamic") + else() + set(_compiler_runtime "static") + endif() + message(STATUS "CMake-Conan: CMake compiler.runtime=${_compiler_runtime}") + + # Only define compiler.runtime_type when explicitly requested + # If a generator expression is used, let Conan handle it conditional on build_type + if(NOT _msvc_runtime_library MATCHES ":Debug>") + if(_msvc_runtime_library MATCHES "Debug") + set(_compiler_runtime_type "Debug") + else() + set(_compiler_runtime_type "Release") + endif() + message(STATUS "CMake-Conan: CMake compiler.runtime_type=${_compiler_runtime_type}") + endif() + + unset(_KNOWN_MSVC_RUNTIME_VALUES) + + elseif(_compiler MATCHES AppleClang) + set(_compiler "apple-clang") + string(REPLACE "." ";" VERSION_LIST ${_compiler_version}) + list(GET VERSION_LIST 0 _compiler_version) + elseif(_compiler MATCHES Clang) + set(_compiler "clang") + string(REPLACE "." ";" VERSION_LIST ${_compiler_version}) + list(GET VERSION_LIST 0 _compiler_version) + elseif(_compiler MATCHES GNU) + set(_compiler "gcc") + string(REPLACE "." ";" VERSION_LIST ${_compiler_version}) + list(GET VERSION_LIST 0 _compiler_version) + endif() + + message(STATUS "CMake-Conan: [settings] compiler=${_compiler}") + message(STATUS "CMake-Conan: [settings] compiler.version=${_compiler_version}") + if (_compiler_runtime) + message(STATUS "CMake-Conan: [settings] compiler.runtime=${_compiler_runtime}") + endif() + if (_compiler_runtime_type) + message(STATUS "CMake-Conan: [settings] compiler.runtime_type=${_compiler_runtime_type}") + endif() + + set(${compiler} ${_compiler} PARENT_SCOPE) + set(${compiler_version} ${_compiler_version} PARENT_SCOPE) + set(${compiler_runtime} ${_compiler_runtime} PARENT_SCOPE) + set(${compiler_runtime_type} ${_compiler_runtime_type} PARENT_SCOPE) +endfunction() + + +function(detect_build_type build_type) + get_property(multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + if(NOT multiconfig_generator) + # Only set when we know we are in a single-configuration generator + # Note: we may want to fail early if `CMAKE_BUILD_TYPE` is not defined + set(${build_type} ${CMAKE_BUILD_TYPE} PARENT_SCOPE) + endif() +endfunction() + + +macro(set_conan_compiler_if_appleclang lang command output_variable) + if(CMAKE_${lang}_COMPILER_ID STREQUAL "AppleClang") + execute_process(COMMAND xcrun --find ${command} + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE) + cmake_path(GET _xcrun_out PARENT_PATH _xcrun_toolchain_path) + cmake_path(GET CMAKE_${lang}_COMPILER PARENT_PATH _compiler_parent_path) + if ("${_xcrun_toolchain_path}" STREQUAL "${_compiler_parent_path}") + set(${output_variable} "") + endif() + unset(_xcrun_out) + unset(_xcrun_toolchain_path) + unset(_compiler_parent_path) + endif() +endmacro() + + +macro(append_compiler_executables_configuration) + set(_conan_c_compiler "") + set(_conan_cpp_compiler "") + set(_conan_rc_compiler "") + set(_conan_compilers_list "") + if(CMAKE_C_COMPILER) + set(_conan_c_compiler "\"c\":\"${CMAKE_C_COMPILER}\"") + set_conan_compiler_if_appleclang(C cc _conan_c_compiler) + list(APPEND _conan_compilers_list ${_conan_c_compiler}) + else() + message(WARNING "CMake-Conan: The C compiler is not defined. " + "Please define CMAKE_C_COMPILER or enable the C language.") + endif() + if(CMAKE_CXX_COMPILER) + set(_conan_cpp_compiler "\"cpp\":\"${CMAKE_CXX_COMPILER}\"") + set_conan_compiler_if_appleclang(CXX c++ _conan_cpp_compiler) + list(APPEND _conan_compilers_list ${_conan_cpp_compiler}) + else() + message(WARNING "CMake-Conan: The C++ compiler is not defined. " + "Please define CMAKE_CXX_COMPILER or enable the C++ language.") + endif() + if(CMAKE_RC_COMPILER) + set(_conan_rc_compiler "\"rc\":\"${CMAKE_RC_COMPILER}\"") + list(APPEND _conan_compilers_list ${_conan_rc_compiler}) + # Not necessary to warn if RC not defined + endif() + if(NOT "x${_conan_compilers_list}" STREQUAL "x") + string(REPLACE ";" "," _conan_compilers_list "${_conan_compilers_list}") + string(APPEND profile "tools.build:compiler_executables={${_conan_compilers_list}}\n") + endif() + unset(_conan_c_compiler) + unset(_conan_cpp_compiler) + unset(_conan_rc_compiler) + unset(_conan_compilers_list) +endmacro() + + +function(detect_host_profile output_file) + detect_os(os os_api_level os_sdk os_subsystem os_version) + detect_arch(arch) + detect_compiler(compiler compiler_version compiler_runtime compiler_runtime_type) + detect_cxx_standard(compiler_cppstd) + detect_lib_cxx(compiler_libcxx) + detect_build_type(build_type) + + set(profile "") + string(APPEND profile "[settings]\n") + if(arch) + string(APPEND profile arch=${arch} "\n") + endif() + if(os) + string(APPEND profile os=${os} "\n") + endif() + if(os_api_level) + string(APPEND profile os.api_level=${os_api_level} "\n") + endif() + if(os_version) + string(APPEND profile os.version=${os_version} "\n") + endif() + if(os_sdk) + string(APPEND profile os.sdk=${os_sdk} "\n") + endif() + if(os_subsystem) + string(APPEND profile os.subsystem=${os_subsystem} "\n") + endif() + if(compiler) + string(APPEND profile compiler=${compiler} "\n") + endif() + if(compiler_version) + string(APPEND profile compiler.version=${compiler_version} "\n") + endif() + if(compiler_runtime) + string(APPEND profile compiler.runtime=${compiler_runtime} "\n") + endif() + if(compiler_runtime_type) + string(APPEND profile compiler.runtime_type=${compiler_runtime_type} "\n") + endif() + if(compiler_cppstd) + string(APPEND profile compiler.cppstd=${compiler_cppstd} "\n") + endif() + if(compiler_libcxx) + string(APPEND profile compiler.libcxx=${compiler_libcxx} "\n") + endif() + if(build_type) + string(APPEND profile "build_type=${build_type}\n") + endif() + + if(NOT DEFINED output_file) + set(file_name "${CMAKE_BINARY_DIR}/profile") + else() + set(file_name ${output_file}) + endif() + + string(APPEND profile "[conf]\n") + string(APPEND profile "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}\n") + + # propagate compilers via profile + append_compiler_executables_configuration() + + if(os STREQUAL "Android") + string(APPEND profile "tools.android:ndk_path=${CMAKE_ANDROID_NDK}\n") + endif() + + message(STATUS "CMake-Conan: Creating profile ${file_name}") + file(WRITE ${file_name} ${profile}) + message(STATUS "CMake-Conan: Profile: \n${profile}") +endfunction() + + +function(conan_profile_detect_default) + message(STATUS "CMake-Conan: Checking if a default profile exists") + execute_process(COMMAND ${CONAN_COMMAND} profile path default + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + ECHO_OUTPUT_VARIABLE + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + if(NOT ${return_code} EQUAL "0") + message(STATUS "CMake-Conan: The default profile doesn't exist, detecting it.") + execute_process(COMMAND ${CONAN_COMMAND} profile detect + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + ECHO_OUTPUT_VARIABLE + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() +endfunction() + + +function(conan_install) + set(conan_output_folder ${CMAKE_BINARY_DIR}/conan) + # Invoke "conan install" with the provided arguments + set(conan_args -of=${conan_output_folder}) + message(STATUS "CMake-Conan: conan install ${CMAKE_SOURCE_DIR} ${conan_args} ${ARGN}") + + + # In case there was not a valid cmake executable in the PATH, we inject the + # same we used to invoke the provider to the PATH + if(DEFINED PATH_TO_CMAKE_BIN) + set(old_path $ENV{PATH}) + set(ENV{PATH} "$ENV{PATH}:${PATH_TO_CMAKE_BIN}") + endif() + + execute_process(COMMAND ${CONAN_COMMAND} install ${CMAKE_SOURCE_DIR} ${conan_args} ${ARGN} --format=json + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_stdout + ERROR_VARIABLE conan_stderr + ECHO_ERROR_VARIABLE # show the text output regardless + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + if(DEFINED PATH_TO_CMAKE_BIN) + set(ENV{PATH} "${old_path}") + endif() + + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan install failed='${return_code}'") + endif() + + # the files are generated in a folder that depends on the layout used, if + # one is specified, but we don't know a priori where this is. + # TODO: this can be made more robust if Conan can provide this in the json output + string(JSON conan_generators_folder GET "${conan_stdout}" graph nodes 0 generators_folder) + cmake_path(CONVERT ${conan_generators_folder} TO_CMAKE_PATH_LIST conan_generators_folder) + + message(STATUS "CMake-Conan: CONAN_GENERATORS_FOLDER=${conan_generators_folder}") + set_property(GLOBAL PROPERTY CONAN_GENERATORS_FOLDER "${conan_generators_folder}") + # reconfigure on conanfile changes + string(JSON conanfile GET "${conan_stdout}" graph nodes 0 label) + message(STATUS "CMake-Conan: CONANFILE=${CMAKE_SOURCE_DIR}/${conanfile}") + set_property(DIRECTORY ${CMAKE_SOURCE_DIR} APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/${conanfile}") + # success + set_property(GLOBAL PROPERTY CONAN_INSTALL_SUCCESS TRUE) + +endfunction() + + +function(conan_get_version conan_command conan_current_version) + execute_process( + COMMAND ${conan_command} --version + OUTPUT_VARIABLE conan_output + RESULT_VARIABLE conan_result + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(conan_result) + message(FATAL_ERROR "CMake-Conan: Error when trying to run Conan") + endif() + + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" conan_version ${conan_output}) + set(${conan_current_version} ${conan_version} PARENT_SCOPE) +endfunction() + + +function(conan_version_check) + set(options ) + set(one_value_args MINIMUM CURRENT) + set(multi_value_args ) + cmake_parse_arguments(conan_version_check + "${options}" "${one_value_args}" "${multi_value_args}" ${ARGN}) + + if(NOT conan_version_check_MINIMUM) + message(FATAL_ERROR "CMake-Conan: Required parameter MINIMUM not set!") + endif() + if(NOT conan_version_check_CURRENT) + message(FATAL_ERROR "CMake-Conan: Required parameter CURRENT not set!") + endif() + + if(conan_version_check_CURRENT VERSION_LESS conan_version_check_MINIMUM) + message(FATAL_ERROR "CMake-Conan: Conan version must be ${conan_version_check_MINIMUM} or later") + endif() +endfunction() + + +macro(construct_profile_argument argument_variable profile_list) + set(${argument_variable} "") + if("${profile_list}" STREQUAL "CONAN_HOST_PROFILE") + set(_arg_flag "--profile:host=") + elseif("${profile_list}" STREQUAL "CONAN_BUILD_PROFILE") + set(_arg_flag "--profile:build=") + endif() + + set(_profile_list "${${profile_list}}") + list(TRANSFORM _profile_list REPLACE "auto-cmake" "${CMAKE_BINARY_DIR}/conan_host_profile") + list(TRANSFORM _profile_list PREPEND ${_arg_flag}) + set(${argument_variable} ${_profile_list}) + + unset(_arg_flag) + unset(_profile_list) +endmacro() + + +macro(conan_provide_dependency method package_name) + set_property(GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED TRUE) + get_property(_conan_install_success GLOBAL PROPERTY CONAN_INSTALL_SUCCESS) + if(NOT _conan_install_success) + find_program(CONAN_COMMAND "conan" REQUIRED) + conan_get_version(${CONAN_COMMAND} CONAN_CURRENT_VERSION) + conan_version_check(MINIMUM ${CONAN_MINIMUM_VERSION} CURRENT ${CONAN_CURRENT_VERSION}) + message(STATUS "CMake-Conan: first find_package() found. Installing dependencies with Conan") + if("default" IN_LIST CONAN_HOST_PROFILE OR "default" IN_LIST CONAN_BUILD_PROFILE) + conan_profile_detect_default() + endif() + if("auto-cmake" IN_LIST CONAN_HOST_PROFILE) + detect_host_profile(${CMAKE_BINARY_DIR}/conan_host_profile) + endif() + construct_profile_argument(_host_profile_flags CONAN_HOST_PROFILE) + construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE) + if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py") + file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile) + if(NOT "${outfile}" MATCHES ".*CMakeDeps.*") + message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile") + endif() + set(generator "") + elseif (EXISTS "${CMAKE_SOURCE_DIR}/conanfile.txt") + file(READ "${CMAKE_SOURCE_DIR}/conanfile.txt" outfile) + if(NOT "${outfile}" MATCHES ".*CMakeDeps.*") + message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile. " + "Please define the generator as it will be mandatory in the future") + endif() + set(generator "-g;CMakeDeps") + endif() + + get_property(_multiconfig_generator GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + + if(DEFINED CONAN_INSTALL_BUILD_CONFIGURATIONS) + # Configurations are specified by the project or user + set(_build_configs "${CONAN_INSTALL_BUILD_CONFIGURATIONS}") + list(LENGTH _build_configs _build_configs_length) + if(NOT _multiconfig_generator AND _build_configs_length GREATER 1) + message(FATAL_ERROR "cmake-conan: when using a single-config CMake generator, " + "please only specify a single configuration in CONAN_INSTALL_BUILD_CONFIGURATIONS") + endif() + unset(_build_configs_length) + else() + # No configuration overrides, provide sensible defaults + if(_multiconfig_generator) + set(_build_configs Release Debug) + else() + set(_build_configs ${CMAKE_BUILD_TYPE}) + endif() + + endif() + list(JOIN _build_configs ", " _build_configs_msg) + message(STATUS "CMake-Conan: Installing configuration(s): ${_build_configs_msg}") + foreach(_build_config IN LISTS _build_configs) + set(_self_build_config "") + if(NOT _multiconfig_generator AND NOT _build_config STREQUAL "${CMAKE_BUILD_TYPE}") + set(_self_build_config -s &:build_type=${CMAKE_BUILD_TYPE}) + endif() + conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} ${_self_build_config} ${CONAN_INSTALL_ARGS} ${generator}) + endforeach() + unset(_self_build_config) + unset(_multiconfig_generator) + unset(_build_configs) + unset(_build_configs_msg) + unset(_host_profile_flags) + unset(_build_profile_flags) + unset(_conan_install_success) + else() + message(STATUS "CMake-Conan: find_package(${ARGV1}) found, 'conan install' already ran") + unset(_conan_install_success) + endif() + + get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER) + + # Ensure that we consider Conan-provided packages ahead of any other, + # irrespective of other settings that modify the search order or search paths + # This follows the guidelines from the find_package documentation + # (https://cmake.org/cmake/help/latest/command/find_package.html): + # find_package ( PATHS paths... NO_DEFAULT_PATH) + # find_package () + + # Filter out `REQUIRED` from the argument list, as the first call may fail + set(_find_args_${package_name} "${ARGN}") + list(REMOVE_ITEM _find_args_${package_name} "REQUIRED") + if(NOT "MODULE" IN_LIST _find_args_${package_name}) + find_package(${package_name} ${_find_args_${package_name}} BYPASS_PROVIDER PATHS "${_conan_generators_folder}" NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH) + unset(_find_args_${package_name}) + endif() + + # Invoke find_package a second time - if the first call succeeded, + # this will simply reuse the result. If not, fall back to CMake default search + # behaviour, also allowing modules to be searched. + if(NOT ${package_name}_FOUND) + list(FIND CMAKE_MODULE_PATH "${_conan_generators_folder}" _index) + if(_index EQUAL -1) + list(PREPEND CMAKE_MODULE_PATH "${_conan_generators_folder}") + endif() + unset(_index) + find_package(${package_name} ${ARGN} BYPASS_PROVIDER) + list(REMOVE_ITEM CMAKE_MODULE_PATH "${_conan_generators_folder}") + endif() +endmacro() + + +cmake_language( + SET_DEPENDENCY_PROVIDER conan_provide_dependency + SUPPORTED_METHODS FIND_PACKAGE +) + + +macro(conan_provide_dependency_check) + set(_conan_provide_dependency_invoked FALSE) + get_property(_conan_provide_dependency_invoked GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED) + if(NOT _conan_provide_dependency_invoked) + message(WARNING "Conan is correctly configured as dependency provider, " + "but Conan has not been invoked. Please add at least one " + "call to `find_package()`.") + if(DEFINED CONAN_COMMAND) + # supress warning in case `CONAN_COMMAND` was specified but unused. + set(_conan_command ${CONAN_COMMAND}) + unset(_conan_command) + endif() + endif() + unset(_conan_provide_dependency_invoked) +endmacro() + + +# Add a deferred call at the end of processing the top-level directory +# to check if the dependency provider was invoked at all. +cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" CALL conan_provide_dependency_check) + +# Configurable variables for Conan profiles +set(CONAN_HOST_PROFILE "default;auto-cmake" CACHE STRING "Conan host profile") +set(CONAN_BUILD_PROFILE "default" CACHE STRING "Conan build profile") +set(CONAN_INSTALL_ARGS "--build=missing" CACHE STRING "Command line arguments for conan install") + +find_program(_cmake_program NAMES cmake NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) +if(NOT _cmake_program) + get_filename_component(PATH_TO_CMAKE_BIN "${CMAKE_COMMAND}" DIRECTORY) + set(PATH_TO_CMAKE_BIN "${PATH_TO_CMAKE_BIN}" CACHE INTERNAL "Path where the CMake executable is") +endif() + +cmake_policy(POP) diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 00000000..c858ec05 --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,11 @@ +[requires] +cpp-httplib/0.27.0 +glfw/3.4 +stb/cci.20240531 +cityhash/1.0.1 +gtest/1.17.0 +directx-headers/1.610.2 +taskflow/3.10.0 + +[generators] +CMakeDeps From f0f8c6ad3e6bef863c2537adc69e0387cc269f4a Mon Sep 17 00:00:00 2001 From: kindem Date: Fri, 28 Nov 2025 19:56:52 +0800 Subject: [PATCH 04/44] fix: conan with multi config generator --- CMakeLists.txt | 6 ++++-- conan_provider.cmake | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 52f1712b..49fcfecb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,11 @@ cmake_minimum_required(VERSION 3.25) get_cmake_property(generator_is_multi_config GENERATOR_IS_MULTI_CONFIG) +set(CONAN_INSTALL_BUILD_CONFIGURATIONS "Release" CACHE STRING "" FORCE) if (${generator_is_multi_config}) - # TODO only install release config, need some deals in exp_add_library - set(CONAN_INSTALL_BUILD_CONFIGURATIONS "Debug;Release;RelWithDebInfo" CACHE STRING "" FORCE) + set(CONAN_INSTALL_SELF_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES} CACHE STRING "" FORCE) +else () + set(CONAN_INSTALL_SELF_CONFIGURATIONS ${CMAKE_BUILD_TYPE} CACHE STRING "" FORCE) endif () set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES ${CMAKE_SOURCE_DIR}/conan_provider.cmake CACHE PATH "" FORCE) diff --git a/conan_provider.cmake b/conan_provider.cmake index 2d9f4e7f..b4389e45 100644 --- a/conan_provider.cmake +++ b/conan_provider.cmake @@ -619,7 +619,15 @@ macro(conan_provide_dependency method package_name) if(NOT _multiconfig_generator AND NOT _build_config STREQUAL "${CMAKE_BUILD_TYPE}") set(_self_build_config -s &:build_type=${CMAKE_BUILD_TYPE}) endif() - conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} ${_self_build_config} ${CONAN_INSTALL_ARGS} ${generator}) + # ++[kindem] + if(DEFINED CONAN_INSTALL_SELF_CONFIGURATIONS) + foreach(_self_config ${CONAN_INSTALL_SELF_CONFIGURATIONS}) + conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} -s &:build_type=${_self_config} ${CONAN_INSTALL_ARGS} ${generator}) + endforeach() + else() + conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} ${_self_build_config} ${CONAN_INSTALL_ARGS} ${generator}) + endif() + # --[kindem] endforeach() unset(_self_build_config) unset(_multiconfig_generator) From d4e2e4a583cde4aec900fe67bca406822f6a99d2 Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 30 Nov 2025 16:51:04 +0800 Subject: [PATCH 05/44] fix: dx headers build --- Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Common.h | 2 +- Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Instance.h | 2 +- Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Queue.h | 2 +- .../Source/RHI-DirectX12/Include/RHI/DirectX12/ShaderModule.h | 1 - Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Synchronous.h | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Common.h b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Common.h index 417a297f..9feae4cc 100644 --- a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Common.h +++ b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Common.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Instance.h b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Instance.h index 224c232a..304de00c 100644 --- a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Instance.h +++ b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Instance.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Queue.h b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Queue.h index 78492471..f2b165d9 100644 --- a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Queue.h +++ b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Queue.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include diff --git a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/ShaderModule.h b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/ShaderModule.h index 83c5a612..45e082e2 100644 --- a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/ShaderModule.h +++ b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/ShaderModule.h @@ -4,7 +4,6 @@ #pragma once -#include #include #include diff --git a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Synchronous.h b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Synchronous.h index d8012546..0f131802 100644 --- a/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Synchronous.h +++ b/Engine/Source/RHI-DirectX12/Include/RHI/DirectX12/Synchronous.h @@ -8,7 +8,7 @@ #include #include -#include +#include using namespace Microsoft::WRL; #include From afbd00132a85985e76abc1f7e858fdf2b43f9363 Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 30 Nov 2025 17:27:58 +0800 Subject: [PATCH 06/44] feat: add qt in conan file (WIP) --- Editor/CMakeLists.txt | 4 ++-- ThirdParty/CMakeLists.txt | 22 +--------------------- conanfile.txt | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 2c116b85..a12ff197 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -1,7 +1,7 @@ set(CMAKE_PREFIX_PATH ${QT_LIB_PREFIX}) find_package( Qt6 ${QT_VERSION} - COMPONENTS Core Gui Widgets Quick WebEngineWidgets + COMPONENTS Core Gui Widgets WebEngineWidgets REQUIRED ) @@ -14,7 +14,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") endif () set(editor_includes Include) -set(editor_qt_libs Qt6::Core Qt6::Gui Qt6::Widgets Qt6::Quick Qt6::WebEngineWidgets) +set(editor_qt_libs Qt6::Core Qt6::Gui Qt6::Widgets Qt6::WebEngineWidgets) set(editor_libs Core RHI Runtime httplib::httplib ${editor_qt_libs}) foreach (QT_LIB ${editor_qt_libs}) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 0df238a5..f7ed1d55 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -310,27 +310,6 @@ if (${VulkanMemoryAllocator_READY}) ) endif () -# Qt6 -set(QT_VERSION "6.9.1" CACHE STRING "" FORCE) -download_and_setup_3rd_package( - NAME Qt - PLATFORM Windows Darwin - VERSION ${QT_VERSION} - HASH - Windows 9cd849f79784fda5436b0da3b7625b4530a77b93c5e80ea9a2d8a95060c174b6 - Darwin 3938c6156228fcf63c33029067bd4b6dd333ed284e069198b85d92de3d9b3e13 -) -if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - set(QT_LIB_PREFIX ${Qt_SOURCE_DIR}/${QT_VERSION}/msvc2022_64 CACHE PATH "" FORCE) -elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(QT_LIB_PREFIX ${Qt_SOURCE_DIR}/${QT_VERSION}/macos CACHE PATH "" FORCE) - - # NOTICE: Fix Qt 6.9.1 build on macOS 26, #see https://codereview.qt-project.org/c/qt/qtbase/+/652022/3/cmake/FindWrapOpenGL.cmake#b50 - if (QT_VERSION STREQUAL "6.9.1") - file(COPY_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Patch/Qt-Darwin-6.9.1-FindWrapOpenGL.cmake ${QT_LIB_PREFIX}/lib/cmake/Qt6/FindWrapOpenGL.cmake) - endif () -endif () - # rapidjson download_and_setup_3rd_package( NAME rapidjson @@ -356,3 +335,4 @@ find_package(Taskflow REQUIRED GLOBAL) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) endif () +set(QT_VERSION "6.8.3" CACHE STRING "" FORCE) diff --git a/conanfile.txt b/conanfile.txt index c858ec05..3e95f0b5 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -6,6 +6,24 @@ cityhash/1.0.1 gtest/1.17.0 directx-headers/1.610.2 taskflow/3.10.0 +qt/6.8.3 [generators] CMakeDeps + +[options] +qt/*:shared=True +qt/*:gui=True +qt/*:qtdeclarative=True +qt/*:qtlocation=True +qt/*:qtmultimedia=True +qt/*:qtquickcontrols2=True +qt/*:qtscxml=True +qt/*:qtsvg=True +qt/*:qtwebchannel=True +qt/*:qtwebengine=True +qt/*:qtwebsockets=True +qt/*:qtwebview=True +qt/*:qtxmlpatterns=True +qt/*:qtimageformats=True +qt/*:qt5compat=True From 3b5f29560de6622aa90ce298b65138dc433b5095 Mon Sep 17 00:00:00 2001 From: kindem Date: Mon, 1 Dec 2025 21:13:26 +0800 Subject: [PATCH 07/44] feat: update README for conan --- README.md | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 722ce1f0..e039a8bf 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,39 @@ build steps of engine may use them. # Build +## Configure Conan Remote + +Some third-party libraries managed by Conan may need to be downloaded and installed from our private repository. Please configure Conan's remote first: + +```shell +conan remote add explosion https://kindem.online/artifactory/api/conan/conan +``` + +## macOS Notice +If you have not installed xcode command line tools, you need install it: + +```shell +xcode-select --install +``` + +If xcode app or xcode command line tools installed on you system, you need check xcode path set to command line tools path, continue with this command: + +```shell +xcode-select -p +``` + +if the command print is not `/Library/Developer/CommandLineTools`, use this command to reset it: + +```shell +sudo xcode-select -s /Library/Developer/CommandLineTools +``` + +## Windows Notice + +Some third-party libraries managed by conan may fail to install or compile on Windows due to excessively long build tree paths. So you need to configure the environment variable `CONAN_HOME` and set it to a relatively short path, such as `C:\t` + +## Build Project + The following table contains supported platform, toolchain and generator: @@ -89,25 +122,6 @@ The parameters' meaning: After build the project, you can get all dist binaries in `/dist`. -## macOS Notice -If you have not installed xcode command line tools, you need install it: - -```shell -xcode-select --install -``` - -If xcode app or xcode command line tools installed on you system, you need check xcode path set to command line tools path, continue with this command: - -```shell -xcode-select -p -``` - -if the command print is not `/Library/Developer/CommandLineTools`, use this command to reset it: - -```shell -sudo xcode-select -s /Library/Developer/CommandLineTools -``` - # Third Party Project Usage Thanks all those following projects: From 1eb7c77ac94779256279cae9e27427e44b8f9faa Mon Sep 17 00:00:00 2001 From: kindem Date: Mon, 1 Dec 2025 21:58:30 +0800 Subject: [PATCH 08/44] feat: update conan file for qt web engine --- README.md | 8 +++++++- conanfile.txt | 13 +++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e039a8bf..7590421f 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ build steps of engine may use them. # Build -## Configure Conan Remote +## Configure Conan Some third-party libraries managed by Conan may need to be downloaded and installed from our private repository. Please configure Conan's remote first: @@ -38,6 +38,12 @@ Some third-party libraries managed by Conan may need to be downloaded and instal conan remote add explosion https://kindem.online/artifactory/api/conan/conan ``` +Additionally, to ensure the qt-webengine module builds successfully, you need to install html5lib in python: + +```shell +pip3 install html5lib +``` + ## macOS Notice If you have not installed xcode command line tools, you need install it: diff --git a/conanfile.txt b/conanfile.txt index 3e95f0b5..85edbd05 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -14,16 +14,9 @@ CMakeDeps [options] qt/*:shared=True qt/*:gui=True -qt/*:qtdeclarative=True -qt/*:qtlocation=True -qt/*:qtmultimedia=True -qt/*:qtquickcontrols2=True -qt/*:qtscxml=True -qt/*:qtsvg=True +qt/*:qttools=True +qt/*:qtshadertools=True +qt/*:qtpositioning=True qt/*:qtwebchannel=True qt/*:qtwebengine=True qt/*:qtwebsockets=True -qt/*:qtwebview=True -qt/*:qtxmlpatterns=True -qt/*:qtimageformats=True -qt/*:qt5compat=True From b95bccc6f73374312c751a6c31e11b9f6d3f8315 Mon Sep 17 00:00:00 2001 From: kindem Date: Tue, 2 Dec 2025 22:50:59 +0800 Subject: [PATCH 09/44] fix: qt build after use conan --- Editor/CMakeLists.txt | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index a12ff197..d430e3b5 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -1,16 +1,16 @@ -set(CMAKE_PREFIX_PATH ${QT_LIB_PREFIX}) find_package( Qt6 ${QT_VERSION} COMPONENTS Core Gui Widgets WebEngineWidgets REQUIRED ) +set(QT_ROOT ${_Qt6_COMPONENT_PATH}/../..) qt_standard_project_setup(REQUIRES ${QT_VERSION}) if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") set(platform_executable_hint MACOSX_BUNDLE) set(bundle_install_dest BUNDLE DESTINATION ${CMAKE_INSTALL_PREFIX}/${ENGINE_SUB_PROJECT_NAME}/Binaries) - set(platform_fwk_dir ${QT_LIB_PREFIX}/lib) + set(platform_fwk_dir ${QT_ROOT}/lib) endif () set(editor_includes Include) @@ -73,28 +73,16 @@ export( ) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - set(qt_win_deploy_executable ${QT_LIB_PREFIX}/bin/windeployqt.exe) + set(qt_win_deploy_executable ${QT_ROOT}/bin/windeployqt.exe) add_custom_command( TARGET Editor POST_BUILD - # ++ QT 6.9.1 Temporal Fix Start - # #see https://bugreports.qt.io/browse/QTBUG-137542 - # NOTICE: seems cause some error on debug config, like render process crash after hover a remote link, please use DebugWithRelease before official fix at 6.9.2 - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_devtools_resources.pak ${QT_LIB_PREFIX}/resources/qtwebengine_devtools_resources.debug.pak - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_resources.pak ${QT_LIB_PREFIX}/resources/qtwebengine_resources.debug.pak - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_resources_100p.pak ${QT_LIB_PREFIX}/resources/qtwebengine_resources_100p.debug.pak - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_resources_200p.pak ${QT_LIB_PREFIX}/resources/qtwebengine_resources_200p.debug.pak - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_devtools_resources.pak $/resources/qtwebengine_devtools_resources.pak - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_resources.pak $/resources/qtwebengine_resources.pak - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_resources_100p.pak $/resources/qtwebengine_resources_100p.pak - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_LIB_PREFIX}/resources/qtwebengine_resources_200p.pak $/resources/qtwebengine_resources_200p.pak - # -- QT 6.9.1 Temporal Fix End COMMAND ${qt_win_deploy_executable} $ ) install( CODE "execute_process(COMMAND ${qt_win_deploy_executable} ${CMAKE_INSTALL_PREFIX}/${ENGINE_SUB_PROJECT_NAME}/Binaries/$)" ) elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(qt_mac_deploy_executable ${QT_LIB_PREFIX}/bin/macdeployqt) + set(qt_mac_deploy_executable ${QT_ROOT}/bin/macdeployqt) add_custom_command( TARGET Editor POST_BUILD COMMAND ${qt_mac_deploy_executable} $/Editor.app -no-strip From 9008f74e66c670fab64d680f19f16671ff248cff Mon Sep 17 00:00:00 2001 From: kindem Date: Tue, 2 Dec 2025 23:06:16 +0800 Subject: [PATCH 10/44] fix: force debug config use release 3rd builds --- CMake/Common.cmake | 2 +- CMake/Target.cmake | 7 ------- CMake/ThirdParty.cmake | 6 +++--- ThirdParty/CMakeLists.txt | 12 ++++++------ 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/CMake/Common.cmake b/CMake/Common.cmake index 70614f2f..27f0ddf2 100644 --- a/CMake/Common.cmake +++ b/CMake/Common.cmake @@ -25,7 +25,7 @@ add_definitions(-DCOMPILER_APPLE_CLANG=$,1,0>) add_definitions(-DCOMPILER_GCC=$,1,0>) if (${MSVC}) - add_compile_options(/bigobj) + add_compile_options(/bigobj /MD) add_definitions(-D_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS=1) add_definitions(-DWIN32_LEAN_AND_MEAN) add_definitions(-DNOMINMAX=1) diff --git a/CMake/Target.cmake b/CMake/Target.cmake index c775dd3e..75d994fc 100644 --- a/CMake/Target.cmake +++ b/CMake/Target.cmake @@ -479,13 +479,6 @@ function(exp_add_library) ) endif () - if (${MSVC}) - target_compile_options( - ${arg_NAME} - PRIVATE /MD$<$:d> - ) - endif() - if ("${arg_TYPE}" STREQUAL "SHARED") string(TOUPPER ${arg_NAME}_API api_name) string(REPLACE "-" "/" api_dir ${arg_NAME}) diff --git a/CMake/ThirdParty.cmake b/CMake/ThirdParty.cmake index 1d3716b7..4b86cd4c 100644 --- a/CMake/ThirdParty.cmake +++ b/CMake/ThirdParty.cmake @@ -236,7 +236,7 @@ function(exp_add_3rd_cmake_package) cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) if (NOT ${generator_is_multi_config}) - set(build_type_args -DCMAKE_BUILD_TYPE=$) + set(build_type_args -DCMAKE_BUILD_TYPE=Release) endif () ExternalProject_Add( @@ -244,8 +244,8 @@ function(exp_add_3rd_cmake_package) SOURCE_DIR ${arg_SOURCE_DIR} BINARY_DIR ${arg_BINARY_DIR} CMAKE_ARGS ${build_type_args} -DCMAKE_INSTALL_PREFIX=${arg_INSTALL_DIR} ${arg_CMAKE_ARG} - BUILD_COMMAND ${CMAKE_COMMAND} --build --config $ -j 16 - INSTALL_COMMAND ${CMAKE_COMMAND} --install --config $ + BUILD_COMMAND ${CMAKE_COMMAND} --build --config Release -j 16 + INSTALL_COMMAND ${CMAKE_COMMAND} --install --config Release ) add_library(${arg_NAME} INTERFACE) add_dependencies(${arg_NAME} ${arg_NAME}.External) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index f7ed1d55..1aecb584 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -265,9 +265,9 @@ if (${spirv-cross_READY}) CMAKE_ARG -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DSPIRV_CROSS_CLI=OFF -DSPIRV_CROSS_ENABLE_C_API=OFF -DSPIRV_CROSS_ENABLE_TESTS=OFF INCLUDE $/include LINK $/lib - LIB spirv-cross-core$,$>,d,> - spirv-cross-msl$,$>,d,> - spirv-cross-glsl$,$>,d,> + LIB spirv-cross-core + spirv-cross-msl + spirv-cross-glsl ) endif () @@ -288,10 +288,10 @@ if (${assimp-lib_READY}) INCLUDE $/include LINK $/lib LIB - Windows "assimp-vc${MSVC_TOOLSET_VERSION}-mt$,d,>" - Darwin "assimp$,d,>" + Windows "assimp-vc${MSVC_TOOLSET_VERSION}-mt" + Darwin "assimp" RUNTIME_DEP - Windows "$/bin/assimp-vc${MSVC_TOOLSET_VERSION}-mt$,d,>.dll" + Windows "$/bin/assimp-vc${MSVC_TOOLSET_VERSION}-mt.dll" ) endif () From f65cb92256a84d4e7b9aefd971fbb5572c6ddd90 Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 7 Dec 2025 13:17:58 +0800 Subject: [PATCH 11/44] refactor: use conan to manage libclang lib --- ThirdParty/CMakeLists.txt | 26 ++------------------------ Tool/MirrorTool/CMakeLists.txt | 2 +- conanfile.txt | 1 + 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 1aecb584..1bdd1b67 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -225,30 +225,6 @@ if (${debugbreak_READY}) ) endif () -# LLVM-Clang -download_and_setup_3rd_package( - NAME llvm-clang - PLATFORM Windows Darwin - VERSION 19.1.6 - HASH - Windows f68b922c87a99b22c0b53a5cbd55db86bd3870c16c4e9060efaecfb9ce49e726 - Darwin 08fdf1b6208823acadc23027fda1f12e5171101ec05fa526b545088be31fe19d -) -if (${llvm-clang_READY}) - exp_add_3rd_binary_package( - NAME llvm-clang - SOURCE_DIR ${llvm-clang_SOURCE_DIR} - INCLUDE $/include - LINK $/lib - LIB - Windows libclang - Darwin clang - RUNTIME_DEP - Windows $/bin/libclang.dll - Darwin $/lib/libclang.dylib - ) -endif () - # spirv-cross download_and_setup_3rd_package( NAME spirv-cross @@ -332,7 +308,9 @@ find_package(stb REQUIRED GLOBAL) find_package(cityhash REQUIRED GLOBAL) find_package(GTest REQUIRED GLOBAL) find_package(Taskflow REQUIRED GLOBAL) +find_package(libclang REQUIRED GLOBAL) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) + set_target_properties(libclang::libclang PROPERTIES RUNTIME_DEP "${libclang_INCLUDE_DIR}/../bin/libclang.dll") endif () set(QT_VERSION "6.8.3" CACHE STRING "" FORCE) diff --git a/Tool/MirrorTool/CMakeLists.txt b/Tool/MirrorTool/CMakeLists.txt index 9f05edf6..6e0abbb0 100644 --- a/Tool/MirrorTool/CMakeLists.txt +++ b/Tool/MirrorTool/CMakeLists.txt @@ -4,7 +4,7 @@ exp_add_library( SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Mirror - PUBLIC_MERGE_LIB llvm-clang clipp + PUBLIC_MERGE_LIB libclang::libclang clipp NOT_INSTALL ) diff --git a/conanfile.txt b/conanfile.txt index 85edbd05..d1e90f4c 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -7,6 +7,7 @@ gtest/1.17.0 directx-headers/1.610.2 taskflow/3.10.0 qt/6.8.3 +libclang/21.1.7-exp [generators] CMakeDeps From 286891e4ccbe171422a67c992e5cb4d37ed5529b Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 7 Dec 2025 14:22:39 +0800 Subject: [PATCH 12/44] refactor: use conanfile.py instead of conanfile.txt for platform requirements control --- conanfile.py | 29 +++++++++++++++++++++++++++++ conanfile.txt | 23 ----------------------- 2 files changed, 29 insertions(+), 23 deletions(-) create mode 100644 conanfile.py delete mode 100644 conanfile.txt diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 00000000..f6c6bf37 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,29 @@ +from conan import ConanFile + +class ExplosionConan(ConanFile): + generators = "CMakeDeps" + settings = "os", "compiler", "build_type", "arch" + + def requirements(self): + self.requires("cpp-httplib/0.27.0") + self.requires("glfw/3.4") + self.requires("stb/cci.20240531") + self.requires("cityhash/1.0.1") + self.requires("gtest/1.17.0") + self.requires("taskflow/3.10.0") + self.requires("qt/6.8.3", options={ + "shared": True, + "gui": True, + "qttools": True, + "qtshadertools": True, + "qtpositioning": True, + "qtwebchannel": True, + "qtwebengine": True, + "qtwebsockets": True + }) + + if self.settings.os == "Windows": + self.requires("directx-headers/1.610.2") + + # private repo + self.requires("libclang/21.1.7-exp") diff --git a/conanfile.txt b/conanfile.txt deleted file mode 100644 index d1e90f4c..00000000 --- a/conanfile.txt +++ /dev/null @@ -1,23 +0,0 @@ -[requires] -cpp-httplib/0.27.0 -glfw/3.4 -stb/cci.20240531 -cityhash/1.0.1 -gtest/1.17.0 -directx-headers/1.610.2 -taskflow/3.10.0 -qt/6.8.3 -libclang/21.1.7-exp - -[generators] -CMakeDeps - -[options] -qt/*:shared=True -qt/*:gui=True -qt/*:qttools=True -qt/*:qtshadertools=True -qt/*:qtpositioning=True -qt/*:qtwebchannel=True -qt/*:qtwebengine=True -qt/*:qtwebsockets=True From 77bce426d1cb0ea7595172ccfe5120a51acc1332 Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 7 Dec 2025 15:00:19 +0800 Subject: [PATCH 13/44] refactor: use conan to manage assimp lib --- Engine/Source/Runtime/CMakeLists.txt | 2 +- Sample/CMakeLists.txt | 2 +- ThirdParty/CMakeLists.txt | 29 ++++------------------------ conanfile.py | 5 ++++- 4 files changed, 10 insertions(+), 28 deletions(-) diff --git a/Engine/Source/Runtime/CMakeLists.txt b/Engine/Source/Runtime/CMakeLists.txt index fb9e838e..6acf4247 100644 --- a/Engine/Source/Runtime/CMakeLists.txt +++ b/Engine/Source/Runtime/CMakeLists.txt @@ -6,7 +6,7 @@ exp_add_library( PUBLIC_INC Include REFLECT Include PUBLIC_LIB Core Mirror Render - PUBLIC_MERGE_LIB assimp-lib + PUBLIC_MERGE_LIB assimp::assimp ) file(GLOB test_sources Test/*.cpp) diff --git a/Sample/CMakeLists.txt b/Sample/CMakeLists.txt index 3539d89b..db33ac05 100644 --- a/Sample/CMakeLists.txt +++ b/Sample/CMakeLists.txt @@ -52,7 +52,7 @@ exp_add_library( SRC ${sources} PUBLIC_INC Base PUBLIC_LIB RHI ${platform_ext_libs} Render.Static - PUBLIC_MERGE_LIB glfw clipp stb::stb assimp-lib + PUBLIC_MERGE_LIB glfw clipp stb::stb assimp::assimp NOT_INSTALL ) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 1bdd1b67..c8cc6f47 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -247,30 +247,6 @@ if (${spirv-cross_READY}) ) endif () -# assimp -download_and_setup_3rd_package( - NAME assimp-lib - PLATFORM All - VERSION 5.2.5 - HASH ae55d305a607ad8cc598c306663796dbf6e50a3cb0b952fe1ea3175f0f342ad9 -) -if (${assimp-lib_READY}) - exp_add_3rd_cmake_package( - NAME assimp-lib - SOURCE_DIR ${assimp-lib_SOURCE_DIR} - BINARY_DIR ${assimp-lib_BINARY_DIR} - INSTALL_DIR ${assimp-lib_INSTALL_DIR} - CMAKE_ARG -DASSIMP_BUILD_TESTS=OFF -DASSIMP_WARNINGS_AS_ERRORS=OFF -DASSIMP_INSTALL_PDB=OFF - INCLUDE $/include - LINK $/lib - LIB - Windows "assimp-vc${MSVC_TOOLSET_VERSION}-mt" - Darwin "assimp" - RUNTIME_DEP - Windows "$/bin/assimp-vc${MSVC_TOOLSET_VERSION}-mt.dll" - ) -endif () - # vma download_and_setup_3rd_package( NAME VulkanMemoryAllocator @@ -309,8 +285,11 @@ find_package(cityhash REQUIRED GLOBAL) find_package(GTest REQUIRED GLOBAL) find_package(Taskflow REQUIRED GLOBAL) find_package(libclang REQUIRED GLOBAL) +find_package(assimp REQUIRED GLOBAL) + +set(QT_VERSION "6.8.3" CACHE STRING "" FORCE) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) + set_target_properties(assimp::assimp PROPERTIES RUNTIME_DEP "${assimp_INCLUDE_DIR}/../bin/assimp-vc${MSVC_TOOLSET_VERSION}-mt.dll") set_target_properties(libclang::libclang PROPERTIES RUNTIME_DEP "${libclang_INCLUDE_DIR}/../bin/libclang.dll") endif () -set(QT_VERSION "6.8.3" CACHE STRING "" FORCE) diff --git a/conanfile.py b/conanfile.py index f6c6bf37..5faeb570 100644 --- a/conanfile.py +++ b/conanfile.py @@ -7,10 +7,13 @@ class ExplosionConan(ConanFile): def requirements(self): self.requires("cpp-httplib/0.27.0") self.requires("glfw/3.4") - self.requires("stb/cci.20240531") + self.requires("stb/cci.20230920") self.requires("cityhash/1.0.1") self.requires("gtest/1.17.0") self.requires("taskflow/3.10.0") + self.requires("assimp/6.0.2", options={ + "shared": True + }) self.requires("qt/6.8.3", options={ "shared": True, "gui": True, From b1fefcc6ca2f0f93ee81d05ca0c2678b5571f085 Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Sun, 7 Dec 2025 15:44:15 +0800 Subject: [PATCH 14/44] feat: update README --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7590421f..9279187d 100644 --- a/README.md +++ b/README.md @@ -45,19 +45,19 @@ pip3 install html5lib ``` ## macOS Notice -If you have not installed xcode command line tools, you need install it: +If you have not installed xcode and xcode command line tool, you need install them, xcode can be downloaded from app store, and xcode command line tool can be installed with: ```shell xcode-select --install ``` -If xcode app or xcode command line tools installed on you system, you need check xcode path set to command line tools path, continue with this command: +In cmake configure stage, if package with your compiler and os info not be cached in our repo, conan will build qt locally, which need set xcode path to app path to make qt build success: -```shell -xcode-select -p +```cpp +sudo xcode-select -s /Applications/Xcode.app/Contents/Developer ``` -if the command print is not `/Library/Developer/CommandLineTools`, use this command to reset it: +But in explosion project build stage, we use command line tool path instead, so you need switch it: ```shell sudo xcode-select -s /Library/Developer/CommandLineTools From 38f3ddb084e9f5270c8a7cbdc91482f272eb5265 Mon Sep 17 00:00:00 2001 From: kindem Date: Thu, 11 Dec 2025 21:45:14 +0800 Subject: [PATCH 15/44] feat: add libclang and qt conan recipes --- .gitignore | 2 + ThirdParty/ConanRecipes/README.md | 38 ++++++++ .../ConanRecipes/libclang/conandata.yml | 3 + ThirdParty/ConanRecipes/libclang/conanfile.py | 65 +++++++++++++ .../libclang/test_package/CMakeLists.txt | 7 ++ .../libclang/test_package/conanfile.py | 25 +++++ .../libclang/test_package/test_package.cpp | 7 ++ ThirdParty/ConanRecipes/qt/conandata.yml | 23 +++++ ThirdParty/ConanRecipes/qt/conanfile.py | 93 +++++++++++++++++++ ThirdParty/ConanRecipes/qt/debug.py | 7 ++ .../qt/test_package/CMakeLists.txt | 28 ++++++ .../ConanRecipes/qt/test_package/conanfile.py | 25 +++++ .../qt/test_package/test_package.cpp | 15 +++ 13 files changed, 338 insertions(+) create mode 100644 ThirdParty/ConanRecipes/README.md create mode 100644 ThirdParty/ConanRecipes/libclang/conandata.yml create mode 100644 ThirdParty/ConanRecipes/libclang/conanfile.py create mode 100644 ThirdParty/ConanRecipes/libclang/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/libclang/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/libclang/test_package/test_package.cpp create mode 100644 ThirdParty/ConanRecipes/qt/conandata.yml create mode 100644 ThirdParty/ConanRecipes/qt/conanfile.py create mode 100644 ThirdParty/ConanRecipes/qt/debug.py create mode 100644 ThirdParty/ConanRecipes/qt/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/qt/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/qt/test_package/test_package.cpp diff --git a/.gitignore b/.gitignore index 806a6774..de0c570e 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ build* # 3rd ThirdParty/Zip ThirdParty/Lib +ThirdParty/ConanRecipes/**/src +ThirdParty/ConanRecipes/**/build diff --git a/ThirdParty/ConanRecipes/README.md b/ThirdParty/ConanRecipes/README.md new file mode 100644 index 00000000..01132454 --- /dev/null +++ b/ThirdParty/ConanRecipes/README.md @@ -0,0 +1,38 @@ +# ConanRecipes + +This repository stores all private Conan recipes used by the explosion game engine. Typically, you don't need to build them separately, as all recipes and precompiled binaries have been uploaded to our private artifact repository at [https://kindem.online/artifactory/api/conan/conan](https://kindem.online/artifactory/api/conan/conan) +. The CMake scripts in the explosion game engine will automatically download and install all dependencies from this repository. + +If you have extremely poor network connectivity, you may use these Conan recipes to locally build the required third-party dependencies for the engine. + +Here is a simple example: + +```shell +cd ThirdParty/ConanRecipes +conan create qt/conanfile.py --version="6.10.1-exp" +``` + +For explosion engine developers, those commands may help to debug conan recipes: + +```shell +cd ThirdParty/ConanRecipes +# source stage +conan source qt/conanfile.py --version="6.10.1-exp" +# build stage +conan build qt/conanfile.py --version="6.10.1-exp" +# export stage +conan export-pkg qt/conanfile.py --version="6.10.1-exp" +# test stage +conan test qt/test_package qt/6.10.1-exp +``` + +# Windows User Notice +In windows, some lib may build failed with long build tree path in development mode (like qt-webengine), in this case, you can use the commands to map conan recipes working directory as a driver and execute all conan commands in the driver root: + +```shell +# map +subst z: path/to/engine/ThirdParty/ConanRecipes + +# unmap +subst z: /d +``` diff --git a/ThirdParty/ConanRecipes/libclang/conandata.yml b/ThirdParty/ConanRecipes/libclang/conandata.yml new file mode 100644 index 00000000..10e8b049 --- /dev/null +++ b/ThirdParty/ConanRecipes/libclang/conandata.yml @@ -0,0 +1,3 @@ +sources: + "21.1.7-exp": + url: "https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-21.1.7.tar.gz" diff --git a/ThirdParty/ConanRecipes/libclang/conanfile.py b/ThirdParty/ConanRecipes/libclang/conanfile.py new file mode 100644 index 00000000..07f3f43b --- /dev/null +++ b/ThirdParty/ConanRecipes/libclang/conanfile.py @@ -0,0 +1,65 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, get, copy +import os + +required_conan_version = ">=2.0.9" + +class LibclangConan(ConanFile): + name = "libclang" + description = "llvm - libclang" + license = "https://github.com/llvm/llvm-project/blob/main/LICENSE.TXT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/llvm/llvm-project" + topics = ("llvm", "tool") + package_type = "shared-library" + settings = "os", "arch", "compiler", "build_type" + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + check_min_cppstd(self, 17) + + def build_requirements(self): + self.tool_requires("ninja/[>=1.12]") + self.tool_requires("cmake/[>=3.16]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) + + def generate(self): + cmake_toolchain = CMakeToolchain(self, generator="Ninja") + cmake_toolchain.cache_variables["LLVM_ENABLE_PROJECTS"] = "clang" + cmake_toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + install_folder = os.path.join(self.build_folder, "installed") + cmake.configure(build_script_folder=os.path.join(self.source_folder, "llvm"), cli_args=[f"-DCMAKE_INSTALL_PREFIX={install_folder}"]) + cmake.build(target="libclang") + cmake.build(target="install-libclang") + cmake.build(target="install-libclang-headers") + + def package(self): + copy(self, "*", os.path.join(self.build_folder, "installed"), self.package_folder) + + def package_info(self): + self.cpp_info.includedirs = ["include"] + self.cpp_info.libdirs = ["lib"] + if self.settings.os == "Windows": + self.cpp_info.libs = ["libclang"] + self.cpp_info.bindirs = ["bin"] + else: + self.cpp_info.libs = ["clang"] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/libclang/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/libclang/test_package/CMakeLists.txt new file mode 100644 index 00000000..95d446f1 --- /dev/null +++ b/ThirdParty/ConanRecipes/libclang/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(libclang REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE libclang::libclang) diff --git a/ThirdParty/ConanRecipes/libclang/test_package/conanfile.py b/ThirdParty/ConanRecipes/libclang/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/libclang/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/libclang/test_package/test_package.cpp b/ThirdParty/ConanRecipes/libclang/test_package/test_package.cpp new file mode 100644 index 00000000..5485d219 --- /dev/null +++ b/ThirdParty/ConanRecipes/libclang/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include + +int main(void) { + CXIndex index = clang_createIndex(0, 0); + CXTranslationUnit translationUnit = clang_parseTranslationUnit(index, nullptr, nullptr, 0, nullptr, 0, CXTranslationUnit_None); + return 0; +} diff --git a/ThirdParty/ConanRecipes/qt/conandata.yml b/ThirdParty/ConanRecipes/qt/conandata.yml new file mode 100644 index 00000000..a244b59c --- /dev/null +++ b/ThirdParty/ConanRecipes/qt/conandata.yml @@ -0,0 +1,23 @@ +sources: + "6.10.1-exp": + url: + - "https://mirrors.cloud.tencent.com/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://download.qt.io/official_releases/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://download.qt.io/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://mirrors.ukfast.co.uk/sites/qt.io/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://mirrors.20i.com/pub/qt.io/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://ftp.nluug.nl/languages/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://mirror.netcologne.de/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://qt-mirror.dannhauer.de/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://ftp.fau.de/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://mirrors.dotsrc.org/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://ftp.icm.edu.pl/packages/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://ftp.acc.umu.se/mirror/qt.io/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://www.nic.funet.fi/pub/mirrors/download.qt-project.org/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://qt.mirror.constant.com/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://mirrors.sau.edu.cn/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://mirror.bjtu.edu.cn/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://mirrors.sjtug.sjtu.edu.cn/qt/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://ftp.jaist.ac.jp/pub/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + - "https://ftp.yz.yamagata-u.ac.jp/pub/qtproject/archive/qt/6.10/6.10.1/single/qt-everywhere-src-6.10.1.tar.xz" + sha256: "0ed08b079719394303cd2054b66b2dc0c5895ceeb88fb6131c18991c980bf00f" diff --git a/ThirdParty/ConanRecipes/qt/conanfile.py b/ThirdParty/ConanRecipes/qt/conanfile.py new file mode 100644 index 00000000..c0f1e29a --- /dev/null +++ b/ThirdParty/ConanRecipes/qt/conanfile.py @@ -0,0 +1,93 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, get, copy +from pip._internal import main as pip_main +import os + +required_conan_version = ">=2.0.9" + +class QtConan(ConanFile): + name = "qt" + description = "qt" + license = "https://github.com/qt/qt5/tree/dev/LICENSES" + url = "https://github.com/qt/qt5" + homepage = "https://github.com/qt/qt5" + topics = ("gui", "tool") + package_type = "shared-library" + settings = "os", "arch", "compiler", "build_type" + options = {} + default_options = {} + + __enabled_projects = ( + "qtbase", "qtdeclarative", "qttools", "qtshadertools", "qtpositioning", "qtwebchannel", "qtwebengine", "qtwebsockets" + ) + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + check_min_cppstd(self, 17) + + def build_requirements(self): + self.tool_requires("ninja/[>=1.12]") + self.tool_requires("cmake/[>=3.16]") + + # for qtwebengine + self.tool_requires("nodejs/22.20.0") + self.tool_requires("gperf/3.1") + if self.settings.os == "Windows": + self.tool_requires("winflexbison/2.5.25") + else: + self.tool_requires("bison/3.8.2") + self.tool_requires("flex/2.6.4") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) + + def generate(self): + # for qtwebengine + print("enabled projects contains qtwebengine, checking html5lib installed...") + try: + import html5lib + print("html5lib import test is OK") + except ImportError: + print("html5lib not installed, try pip install") + pip_main(["install", "html5lib"]) + try: + import html5lib + except ImportError: + raise RuntimeError("failed to import html5lib") + + cmake_toolchain = CMakeToolchain(self, generator="Ninja") + cmake_toolchain.cache_variables["QT_AUTODETECT_ANDROID"] = "" + cmake_toolchain.cache_variables["QT_GENERATE_SBOM"] = "OFF" + for entry in os.listdir(self.source_folder): + if not os.path.isdir(entry) and not entry.startswith('qt'): + continue + cmake_toolchain.cache_variables[f"BUILD_{entry}"] = "ON" if entry in self.__enabled_projects else "OFF" + cmake_toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = [] + self.cpp_info.builddirs = [os.path.join("lib", "cmake")] + self.cpp_info.set_property("cmake_find_mode", "none") + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/qt/debug.py b/ThirdParty/ConanRecipes/qt/debug.py new file mode 100644 index 00000000..9d99c2ec --- /dev/null +++ b/ThirdParty/ConanRecipes/qt/debug.py @@ -0,0 +1,7 @@ +from conan.api.conan_api import ConanAPI +from conan.cli.cli import Cli + +if __name__ == '__main__': + api = ConanAPI() + api.command = Cli(api) + api.command.run(["build", ".\conanfile.py", "--version=\"6.10.1-exp\""]) diff --git a/ThirdParty/ConanRecipes/qt/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/qt/test_package/CMakeLists.txt new file mode 100644 index 00000000..a19c5038 --- /dev/null +++ b/ThirdParty/ConanRecipes/qt/test_package/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(Qt6 COMPONENTS Core Gui Widgets WebEngineWidgets REQUIRED) +set(QT_ROOT ${_Qt6_COMPONENT_PATH}/../..) + +qt_standard_project_setup() + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(platform_executable_hint MACOSX_BUNDLE) +endif () + +qt_add_executable(${PROJECT_NAME} ${platform_executable_hint} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets Qt6::WebEngineWidgets) + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + set(qt_win_deploy_executable ${QT_ROOT}/bin/windeployqt.exe) + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${qt_win_deploy_executable} $ + ) +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(qt_mac_deploy_executable ${QT_ROOT}/bin/macdeployqt) + add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${qt_mac_deploy_executable} $/${PROJECT_NAME}.app -no-strip + ) +endif () diff --git a/ThirdParty/ConanRecipes/qt/test_package/conanfile.py b/ThirdParty/ConanRecipes/qt/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/qt/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/qt/test_package/test_package.cpp b/ThirdParty/ConanRecipes/qt/test_package/test_package.cpp new file mode 100644 index 00000000..81075255 --- /dev/null +++ b/ThirdParty/ConanRecipes/qt/test_package/test_package.cpp @@ -0,0 +1,15 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QWebEngineView view; + view.load(QUrl("https://qt-project.org/")); + view.resize(1024, 768); + + QTimer::singleShot(100, []() -> void { QApplication::quit(); }); + return app.exec(); +} \ No newline at end of file From a22441c6eeaba3031c43e6aab95bb1775b2bcdff Mon Sep 17 00:00:00 2001 From: kindem Date: Sat, 13 Dec 2025 00:18:21 +0800 Subject: [PATCH 16/44] feat: use new private qt 6.10.1 package --- Editor/CMakeLists.txt | 3 ++- conanfile.py | 11 +---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index d430e3b5..d9d646cd 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -1,8 +1,9 @@ find_package( - Qt6 ${QT_VERSION} + Qt6 COMPONENTS Core Gui Widgets WebEngineWidgets REQUIRED ) +# TODO check this set(QT_ROOT ${_Qt6_COMPONENT_PATH}/../..) qt_standard_project_setup(REQUIRES ${QT_VERSION}) diff --git a/conanfile.py b/conanfile.py index 5faeb570..8faa15b9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -14,19 +14,10 @@ def requirements(self): self.requires("assimp/6.0.2", options={ "shared": True }) - self.requires("qt/6.8.3", options={ - "shared": True, - "gui": True, - "qttools": True, - "qtshadertools": True, - "qtpositioning": True, - "qtwebchannel": True, - "qtwebengine": True, - "qtwebsockets": True - }) if self.settings.os == "Windows": self.requires("directx-headers/1.610.2") # private repo self.requires("libclang/21.1.7-exp") + self.requires("qt/6.10.1-exp") From 113c0e01f629c7641e92e6da2853858d6bae42f1 Mon Sep 17 00:00:00 2001 From: kindem Date: Sat, 13 Dec 2025 13:03:44 +0800 Subject: [PATCH 17/44] feat: use new conan CMakeConfigDeps generator --- CMake/Target.cmake | 7 +------ CMakeLists.txt | 10 ++++------ Editor/CMakeLists.txt | 3 +-- conan_provider.cmake | 27 ++++++++++++++++----------- conanfile.py | 2 +- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/CMake/Target.cmake b/CMake/Target.cmake index 75d994fc..456e5193 100644 --- a/CMake/Target.cmake +++ b/CMake/Target.cmake @@ -406,12 +406,7 @@ function(exp_add_library) endforeach () foreach (lib ${arg_PUBLIC_MERGE_LIB}) if (TARGET ${lib}) - get_target_property(target_incs ${lib} INTERFACE_INCLUDE_DIRECTORIES) - if (NOT ("${target_incs}" STREQUAL "target_incs-NOTFOUND")) - foreach(target_inc ${target_incs}) - list(APPEND public_inc ${target_inc}) - endforeach() - endif() + list(APPEND public_inc $) endif () endforeach () diff --git a/CMakeLists.txt b/CMakeLists.txt index 49fcfecb..0f9bf25a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,6 @@ cmake_minimum_required(VERSION 3.25) -get_cmake_property(generator_is_multi_config GENERATOR_IS_MULTI_CONFIG) set(CONAN_INSTALL_BUILD_CONFIGURATIONS "Release" CACHE STRING "" FORCE) -if (${generator_is_multi_config}) - set(CONAN_INSTALL_SELF_CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES} CACHE STRING "" FORCE) -else () - set(CONAN_INSTALL_SELF_CONFIGURATIONS ${CMAKE_BUILD_TYPE} CACHE STRING "" FORCE) -endif () set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES ${CMAKE_SOURCE_DIR}/conan_provider.cmake CACHE PATH "" FORCE) project(Explosion) @@ -17,6 +11,10 @@ option(CI "Build in CI" OFF) set(SUB_PROJECT_NAME "Engine" CACHE STRING "" FORCE) set(ENGINE_SUB_PROJECT_NAME "Engine" CACHE STRING "" FORCE) +set(CMAKE_MAP_IMPORTED_CONFIG_DEBUG "Release" CACHE STRING "" FORCE) +set(CMAKE_MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release" CACHE STRING "" FORCE) +set(CMAKE_MAP_IMPORTED_CONFIG_MINSIZEREL "Release" CACHE STRING "" FORCE) + add_definitions(-DBUILD_EDITOR=$) include(CMake/Common.cmake) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index d9d646cd..3494b7fa 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -3,8 +3,7 @@ find_package( COMPONENTS Core Gui Widgets WebEngineWidgets REQUIRED ) -# TODO check this -set(QT_ROOT ${_Qt6_COMPONENT_PATH}/../..) +set(QT_ROOT ${QT6_INSTALL_PREFIX}) qt_standard_project_setup(REQUIRES ${QT_VERSION}) diff --git a/conan_provider.cmake b/conan_provider.cmake index b4389e45..d9f11413 100644 --- a/conan_provider.cmake +++ b/conan_provider.cmake @@ -579,7 +579,9 @@ macro(conan_provide_dependency method package_name) construct_profile_argument(_build_profile_flags CONAN_BUILD_PROFILE) if(EXISTS "${CMAKE_SOURCE_DIR}/conanfile.py") file(READ "${CMAKE_SOURCE_DIR}/conanfile.py" outfile) - if(NOT "${outfile}" MATCHES ".*CMakeDeps.*") + # ++[kindem] + if(NOT "${outfile}" MATCHES ".*CMakeDeps.*" AND NOT "${outfile}" MATCHES ".*CMakeConfigDeps.*") + # --[kindem] message(WARNING "Cmake-conan: CMakeDeps generator was not defined in the conanfile") endif() set(generator "") @@ -619,16 +621,17 @@ macro(conan_provide_dependency method package_name) if(NOT _multiconfig_generator AND NOT _build_config STREQUAL "${CMAKE_BUILD_TYPE}") set(_self_build_config -s &:build_type=${CMAKE_BUILD_TYPE}) endif() - # ++[kindem] - if(DEFINED CONAN_INSTALL_SELF_CONFIGURATIONS) - foreach(_self_config ${CONAN_INSTALL_SELF_CONFIGURATIONS}) - conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} -s &:build_type=${_self_config} ${CONAN_INSTALL_ARGS} ${generator}) - endforeach() - else() - conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} ${_self_build_config} ${CONAN_INSTALL_ARGS} ${generator}) - endif() - # --[kindem] + conan_install(${_host_profile_flags} ${_build_profile_flags} -s build_type=${_build_config} ${_self_build_config} ${CONAN_INSTALL_ARGS} ${generator}) endforeach() + # ++[kindem] + get_property(_conan_generators_folder GLOBAL PROPERTY CONAN_GENERATORS_FOLDER) + if(EXISTS "${_conan_generators_folder}/conan_cmakedeps_paths.cmake") + message(STATUS "CMake-Conan: Loading conan_cmakedeps_paths.cmake file") + include(${_conan_generators_folder}/conan_cmakedeps_paths.cmake) + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} CACHE STRING "" FORCE) + set(CMAKE_PREFIX_PATH ${CMAKE_MODULE_PATH} CACHE STRING "" FORCE) + endif() + # --[kindem] unset(_self_build_config) unset(_multiconfig_generator) unset(_build_configs) @@ -703,7 +706,9 @@ cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" CALL conan_provide_dependen # Configurable variables for Conan profiles set(CONAN_HOST_PROFILE "default;auto-cmake" CACHE STRING "Conan host profile") set(CONAN_BUILD_PROFILE "default" CACHE STRING "Conan build profile") -set(CONAN_INSTALL_ARGS "--build=missing" CACHE STRING "Command line arguments for conan install") +# ++[kindem] +set(CONAN_INSTALL_ARGS "--build=missing;-c;tools.cmake.cmakedeps:new=will_break_next" CACHE STRING "Command line arguments for conan install") +# --[kindem] find_program(_cmake_program NAMES cmake NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) if(NOT _cmake_program) diff --git a/conanfile.py b/conanfile.py index 8faa15b9..526b1f44 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,7 +1,7 @@ from conan import ConanFile class ExplosionConan(ConanFile): - generators = "CMakeDeps" + generators = "CMakeConfigDeps" settings = "os", "compiler", "build_type", "arch" def requirements(self): From 2135a448ad09088bcf466751c29a377a64b8648e Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Sun, 14 Dec 2025 02:01:25 +0800 Subject: [PATCH 18/44] fix: pip install in qt conanfile in macos --- ThirdParty/ConanRecipes/qt/conanfile.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ThirdParty/ConanRecipes/qt/conanfile.py b/ThirdParty/ConanRecipes/qt/conanfile.py index c0f1e29a..9344b834 100644 --- a/ThirdParty/ConanRecipes/qt/conanfile.py +++ b/ThirdParty/ConanRecipes/qt/conanfile.py @@ -55,7 +55,10 @@ def generate(self): print("html5lib import test is OK") except ImportError: print("html5lib not installed, try pip install") - pip_main(["install", "html5lib"]) + if self.settings.os == "Windows": + pip_main(["install", "html5lib"]) + else: + pip_main(["install", "html5lib", "--break-system-packages"]) try: import html5lib except ImportError: From 5e734b0bf41123e4d83aca1b8fa943c47d8e0685 Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Sun, 14 Dec 2025 12:15:06 +0800 Subject: [PATCH 19/44] fix: macos qt conanfile --- .gitignore | 1 + ThirdParty/ConanRecipes/qt/test_package/CMakeLists.txt | 2 +- ThirdParty/ConanRecipes/qt/test_package/conanfile.py | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index de0c570e..7ac52f19 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ ThirdParty/Zip ThirdParty/Lib ThirdParty/ConanRecipes/**/src ThirdParty/ConanRecipes/**/build +ThirdParty/ConanRecipes/**/CMakeUserPresets.json diff --git a/ThirdParty/ConanRecipes/qt/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/qt/test_package/CMakeLists.txt index a19c5038..1e97895f 100644 --- a/ThirdParty/ConanRecipes/qt/test_package/CMakeLists.txt +++ b/ThirdParty/ConanRecipes/qt/test_package/CMakeLists.txt @@ -23,6 +23,6 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") set(qt_mac_deploy_executable ${QT_ROOT}/bin/macdeployqt) add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${qt_mac_deploy_executable} $/${PROJECT_NAME}.app -no-strip + COMMAND ${qt_mac_deploy_executable} $ -no-strip ) endif () diff --git a/ThirdParty/ConanRecipes/qt/test_package/conanfile.py b/ThirdParty/ConanRecipes/qt/test_package/conanfile.py index 2e77b424..04c30ffc 100644 --- a/ThirdParty/ConanRecipes/qt/test_package/conanfile.py +++ b/ThirdParty/ConanRecipes/qt/test_package/conanfile.py @@ -22,4 +22,7 @@ def build(self): def test(self): if can_run(self): bin_path = os.path.join(self.cpp.build.bindir, "test_package") - self.run(bin_path, env="conanrun") + if self.settings.os == "Macos": + self.run(f"open {bin_path}.app", env="conanrun") + else: + self.run(bin_path, env="conanrun") From fd3e78aa81f6fd487d4afab76f6d583de1298ccd Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Sun, 14 Dec 2025 12:43:04 +0800 Subject: [PATCH 20/44] fix: dummy opengl link on macos for glfw --- ThirdParty/CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index c8cc6f47..f2022e57 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -278,6 +278,10 @@ if (${rapidjson_READY}) endif () # conan managed +if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + add_library(OpenGLDummy INTERFACE) + add_library(opengl::opengl ALIAS OpenGLDummy) +endif () find_package(httplib REQUIRED GLOBAL) find_package(glfw3 REQUIRED GLOBAL) find_package(stb REQUIRED GLOBAL) From 1423af757ce20cba2cefeb75f3ab2c3013e371d8 Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Sun, 14 Dec 2025 13:17:44 +0800 Subject: [PATCH 21/44] fix: macos build --- CMake/Target.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMake/Target.cmake b/CMake/Target.cmake index 456e5193..ebb4b6f6 100644 --- a/CMake/Target.cmake +++ b/CMake/Target.cmake @@ -203,7 +203,7 @@ function(exp_add_mirror_info_source_generation_target) list(APPEND inc_args "-I") foreach (i ${inc}) - list(APPEND inc_args ${i}) + list(APPEND inc_args \"${i}\") endforeach() if (DEFINED arg_FRAMEWORK_DIR) From 22a9d45e312a4dd7aa2e24bf780b9c4382f94f5f Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Sun, 14 Dec 2025 13:27:10 +0800 Subject: [PATCH 22/44] fix: auto set max files in qt conanfile for non windows platform --- ThirdParty/ConanRecipes/qt/conanfile.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ThirdParty/ConanRecipes/qt/conanfile.py b/ThirdParty/ConanRecipes/qt/conanfile.py index 9344b834..0ff84cd1 100644 --- a/ThirdParty/ConanRecipes/qt/conanfile.py +++ b/ThirdParty/ConanRecipes/qt/conanfile.py @@ -5,6 +5,7 @@ from conan.tools.files import apply_conandata_patches, get, copy from pip._internal import main as pip_main import os +import resource required_conan_version = ">=2.0.9" @@ -64,6 +65,13 @@ def generate(self): except ImportError: raise RuntimeError("failed to import html5lib") + # to ensure qtwebengine build success + if self.settings.os != "Windows": + soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) + resource.setrlimit(resource.RLIMIT_NOFILE, (1000000, hard_limit)) + soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) + print(f"set resource.RLIMIT_NOFILE for qtwebengine build to (soft: {soft_limit}, hard: {hard_limit})") + cmake_toolchain = CMakeToolchain(self, generator="Ninja") cmake_toolchain.cache_variables["QT_AUTODETECT_ANDROID"] = "" cmake_toolchain.cache_variables["QT_GENERATE_SBOM"] = "OFF" From 20243fe5258b40c471632a1306fc9afde3b2ed02 Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Sun, 14 Dec 2025 13:47:54 +0800 Subject: [PATCH 23/44] feat: update README.md --- README.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9279187d..1d095705 100644 --- a/README.md +++ b/README.md @@ -38,12 +38,6 @@ Some third-party libraries managed by Conan may need to be downloaded and instal conan remote add explosion https://kindem.online/artifactory/api/conan/conan ``` -Additionally, to ensure the qt-webengine module builds successfully, you need to install html5lib in python: - -```shell -pip3 install html5lib -``` - ## macOS Notice If you have not installed xcode and xcode command line tool, you need install them, xcode can be downloaded from app store, and xcode command line tool can be installed with: @@ -51,16 +45,16 @@ If you have not installed xcode and xcode command line tool, you need install th xcode-select --install ``` -In cmake configure stage, if package with your compiler and os info not be cached in our repo, conan will build qt locally, which need set xcode path to app path to make qt build success: +And you need check the xcode-select path: -```cpp -sudo xcode-select -s /Applications/Xcode.app/Contents/Developer +```shell +xcode-select -p ``` -But in explosion project build stage, we use command line tool path instead, so you need switch it: +If the output not equals `/Applications/Xcode.app/Contents/Developer`, you need to set it: ```shell -sudo xcode-select -s /Library/Developer/CommandLineTools +sudo xcode-select -s /Applications/Xcode.app/Contents/Developer ``` ## Windows Notice From 3250bcaa0e4822ef12af4737901edafdb76b963b Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Sun, 14 Dec 2025 13:55:16 +0800 Subject: [PATCH 24/44] fix: windows qt conanfile --- ThirdParty/ConanRecipes/qt/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/ConanRecipes/qt/conanfile.py b/ThirdParty/ConanRecipes/qt/conanfile.py index 0ff84cd1..36defd52 100644 --- a/ThirdParty/ConanRecipes/qt/conanfile.py +++ b/ThirdParty/ConanRecipes/qt/conanfile.py @@ -5,7 +5,6 @@ from conan.tools.files import apply_conandata_patches, get, copy from pip._internal import main as pip_main import os -import resource required_conan_version = ">=2.0.9" @@ -67,6 +66,7 @@ def generate(self): # to ensure qtwebengine build success if self.settings.os != "Windows": + import resource soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) resource.setrlimit(resource.RLIMIT_NOFILE, (1000000, hard_limit)) soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE) From 96f5caa6b6dd0aa5cbb5a9116caaff13d3580594 Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 14 Dec 2025 17:28:51 +0800 Subject: [PATCH 25/44] refactor: remove useless cmake variables --- Editor/CMakeLists.txt | 2 +- ThirdParty/CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 3494b7fa..3b21b62a 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -5,7 +5,7 @@ find_package( ) set(QT_ROOT ${QT6_INSTALL_PREFIX}) -qt_standard_project_setup(REQUIRES ${QT_VERSION}) +qt_standard_project_setup() if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") set(platform_executable_hint MACOSX_BUNDLE) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index f2022e57..c500eb7b 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -291,7 +291,6 @@ find_package(Taskflow REQUIRED GLOBAL) find_package(libclang REQUIRED GLOBAL) find_package(assimp REQUIRED GLOBAL) -set(QT_VERSION "6.8.3" CACHE STRING "" FORCE) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) set_target_properties(assimp::assimp PROPERTIES RUNTIME_DEP "${assimp_INCLUDE_DIR}/../bin/assimp-vc${MSVC_TOOLSET_VERSION}-mt.dll") From da37fd30a21a749239b7e3a94ae78249d0f4a354 Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 14 Dec 2025 17:35:32 +0800 Subject: [PATCH 26/44] feat: use conan to manage vulkan memory allocator lib --- Engine/Source/RHI-Vulkan/CMakeLists.txt | 2 +- ThirdParty/CMakeLists.txt | 16 +--------------- conanfile.py | 1 + 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/Engine/Source/RHI-Vulkan/CMakeLists.txt b/Engine/Source/RHI-Vulkan/CMakeLists.txt index 416fc8d1..aa198485 100644 --- a/Engine/Source/RHI-Vulkan/CMakeLists.txt +++ b/Engine/Source/RHI-Vulkan/CMakeLists.txt @@ -16,7 +16,7 @@ exp_add_library( SRC ${sources} ${platform_sources} PUBLIC_INC Include PUBLIC_LIB RHI ${platform_ext_libs} - PUBLIC_MERGE_LIB VulkanSDK spirv-cross VulkanMemoryAllocator + PUBLIC_MERGE_LIB VulkanSDK spirv-cross GPUOpen::VulkanMemoryAllocator ) # .mm files can not perform unity build with .cpp files diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index c500eb7b..cd517008 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -247,21 +247,6 @@ if (${spirv-cross_READY}) ) endif () -# vma -download_and_setup_3rd_package( - NAME VulkanMemoryAllocator - PLATFORM All - VERSION 3.0.1 - HASH a63a5e32c21fa9e839580d0c8727c6dead9da01730a8f0d10717cd784bc632de -) -if (${VulkanMemoryAllocator_READY}) - exp_add_3rd_header_only_package( - NAME VulkanMemoryAllocator - SOURCE_DIR ${VulkanMemoryAllocator_SOURCE_DIR} - INCLUDE $/include - ) -endif () - # rapidjson download_and_setup_3rd_package( NAME rapidjson @@ -290,6 +275,7 @@ find_package(GTest REQUIRED GLOBAL) find_package(Taskflow REQUIRED GLOBAL) find_package(libclang REQUIRED GLOBAL) find_package(assimp REQUIRED GLOBAL) +find_package(VulkanMemoryAllocator REQUIRED GLOBAL) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) diff --git a/conanfile.py b/conanfile.py index 526b1f44..9b88101c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -11,6 +11,7 @@ def requirements(self): self.requires("cityhash/1.0.1") self.requires("gtest/1.17.0") self.requires("taskflow/3.10.0") + self.requires("vulkan-memory-allocator/3.3.0") self.requires("assimp/6.0.2", options={ "shared": True }) From 6b71f215a7ffbf7c9ab2a6e1448f3d0abd59c943 Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 14 Dec 2025 18:41:07 +0800 Subject: [PATCH 27/44] feat: add debugbreak conan recipes --- .../ConanRecipes/debugbreak/conandata.yml | 3 ++ .../ConanRecipes/debugbreak/conanfile.py | 37 +++++++++++++++++++ .../debugbreak/test_package/CMakeLists.txt | 7 ++++ .../debugbreak/test_package/conanfile.py | 25 +++++++++++++ .../debugbreak/test_package/test_package.cpp | 5 +++ 5 files changed, 77 insertions(+) create mode 100644 ThirdParty/ConanRecipes/debugbreak/conandata.yml create mode 100644 ThirdParty/ConanRecipes/debugbreak/conanfile.py create mode 100644 ThirdParty/ConanRecipes/debugbreak/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/debugbreak/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/debugbreak/test_package/test_package.cpp diff --git a/ThirdParty/ConanRecipes/debugbreak/conandata.yml b/ThirdParty/ConanRecipes/debugbreak/conandata.yml new file mode 100644 index 00000000..f9dfc2dc --- /dev/null +++ b/ThirdParty/ConanRecipes/debugbreak/conandata.yml @@ -0,0 +1,3 @@ +sources: + "1.0-exp": + url: "https://github.com/scottt/debugbreak/archive/refs/tags/v1.0.tar.gz" diff --git a/ThirdParty/ConanRecipes/debugbreak/conanfile.py b/ThirdParty/ConanRecipes/debugbreak/conanfile.py new file mode 100644 index 00000000..4fb320cc --- /dev/null +++ b/ThirdParty/ConanRecipes/debugbreak/conanfile.py @@ -0,0 +1,37 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, get, copy +import os + +required_conan_version = ">=2.0.9" + +class DebugBreakConan(ConanFile): + name = "debugbreak" + description = "debugbreak" + license = "https://github.com/scottt/debugbreak?tab=BSD-2-Clause-1-ov-file" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/scottt/debugbreak" + topics = ("utils", "debug") + package_type = "header-library" + + def layout(self): + self.folders.source = "src" + self.folders.build = "build" + self.folders.generators = "build/generators" + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) + + def package(self): + copy(self, "*.h", self.source_folder, os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.includedirs = ["include"] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/debugbreak/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/debugbreak/test_package/CMakeLists.txt new file mode 100644 index 00000000..96f2689a --- /dev/null +++ b/ThirdParty/ConanRecipes/debugbreak/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(debugbreak REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE debugbreak::debugbreak) diff --git a/ThirdParty/ConanRecipes/debugbreak/test_package/conanfile.py b/ThirdParty/ConanRecipes/debugbreak/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/debugbreak/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/debugbreak/test_package/test_package.cpp b/ThirdParty/ConanRecipes/debugbreak/test_package/test_package.cpp new file mode 100644 index 00000000..70c34392 --- /dev/null +++ b/ThirdParty/ConanRecipes/debugbreak/test_package/test_package.cpp @@ -0,0 +1,5 @@ +#include + +int main(void) { + return 0; +} From 6fc09709e116fad491ddea028e5f1ff43f8825c0 Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 14 Dec 2025 18:45:00 +0800 Subject: [PATCH 28/44] feat: use conan to manage debugbreak lib --- Engine/Source/Common/CMakeLists.txt | 2 +- ThirdParty/CMakeLists.txt | 18 +----------------- conanfile.py | 1 + 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/Engine/Source/Common/CMakeLists.txt b/Engine/Source/Common/CMakeLists.txt index 278f299d..1917725b 100644 --- a/Engine/Source/Common/CMakeLists.txt +++ b/Engine/Source/Common/CMakeLists.txt @@ -4,7 +4,7 @@ exp_add_library( TYPE STATIC SRC ${sources} PUBLIC_INC Include - PUBLIC_MERGE_LIB rapidjson debugbreak cityhash::cityhash Taskflow::Taskflow + PUBLIC_MERGE_LIB rapidjson debugbreak::debugbreak cityhash::cityhash Taskflow::Taskflow ) file(GLOB test_sources Test/*.cpp) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index cd517008..9b4f984e 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -208,23 +208,6 @@ if (${clipp_READY}) ) endif () -# DebugBreak -download_and_setup_3rd_package( - NAME debugbreak - PLATFORM All - VERSION 1.0 - HASH 16e35a330a9927181ed2e03a92efe6d39670b33c1bdf61ab88d29673ef3a89d4 -) -if (${debugbreak_READY}) - exp_add_3rd_header_only_package( - NAME debugbreak - SOURCE_DIR ${debugbreak_SOURCE_DIR} - INSTALL_DIR ${debugbreak_INSTALL_DIR} - INSTALL_FILES debugbreak.h - INCLUDE $ - ) -endif () - # spirv-cross download_and_setup_3rd_package( NAME spirv-cross @@ -276,6 +259,7 @@ find_package(Taskflow REQUIRED GLOBAL) find_package(libclang REQUIRED GLOBAL) find_package(assimp REQUIRED GLOBAL) find_package(VulkanMemoryAllocator REQUIRED GLOBAL) +find_package(debugbreak REQUIRED GLOBAL) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) diff --git a/conanfile.py b/conanfile.py index 9b88101c..880b6db9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -22,3 +22,4 @@ def requirements(self): # private repo self.requires("libclang/21.1.7-exp") self.requires("qt/6.10.1-exp") + self.requires("debugbreak/1.0-exp") From ed35b01257ad235758851b16e5924a576a4d66b4 Mon Sep 17 00:00:00 2001 From: kindem Date: Sun, 14 Dec 2025 19:22:18 +0800 Subject: [PATCH 29/44] feat: update debugbreak conanfile --- ThirdParty/ConanRecipes/debugbreak/conanfile.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/ThirdParty/ConanRecipes/debugbreak/conanfile.py b/ThirdParty/ConanRecipes/debugbreak/conanfile.py index 4fb320cc..5a1d917f 100644 --- a/ThirdParty/ConanRecipes/debugbreak/conanfile.py +++ b/ThirdParty/ConanRecipes/debugbreak/conanfile.py @@ -1,7 +1,5 @@ from conan import ConanFile -from conan.tools.build import check_min_cppstd from conan.tools.build import can_run -from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.files import apply_conandata_patches, get, copy import os From 7404f7cbd195da0827266e903b13c119f9f64062 Mon Sep 17 00:00:00 2001 From: kindem Date: Mon, 15 Dec 2025 21:56:14 +0800 Subject: [PATCH 30/44] feat: for conan files, auto change eol to crlf for revision equals on all platforms --- .gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..bebc3791 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +ThirdParty/ConanRecipes/**/* text eol=lf \ No newline at end of file From 36f544b4fc1c4771b63badae3eebd32107e9a9cc Mon Sep 17 00:00:00 2001 From: kindem Date: Tue, 16 Dec 2025 20:48:20 +0800 Subject: [PATCH 31/44] feat: add rapidjson conan dependency --- Engine/Source/Common/CMakeLists.txt | 2 +- ThirdParty/CMakeLists.txt | 16 +------- .../ConanRecipes/rapidjson/conandata.yml | 3 ++ .../ConanRecipes/rapidjson/conanfile.py | 38 +++++++++++++++++++ .../rapidjson/test_package/CMakeLists.txt | 7 ++++ .../rapidjson/test_package/conanfile.py | 25 ++++++++++++ .../rapidjson/test_package/test_package.cpp | 9 +++++ conanfile.py | 3 ++ 8 files changed, 87 insertions(+), 16 deletions(-) create mode 100644 ThirdParty/ConanRecipes/rapidjson/conandata.yml create mode 100644 ThirdParty/ConanRecipes/rapidjson/conanfile.py create mode 100644 ThirdParty/ConanRecipes/rapidjson/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/rapidjson/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/rapidjson/test_package/test_package.cpp diff --git a/Engine/Source/Common/CMakeLists.txt b/Engine/Source/Common/CMakeLists.txt index 1917725b..bc7fbe10 100644 --- a/Engine/Source/Common/CMakeLists.txt +++ b/Engine/Source/Common/CMakeLists.txt @@ -4,7 +4,7 @@ exp_add_library( TYPE STATIC SRC ${sources} PUBLIC_INC Include - PUBLIC_MERGE_LIB rapidjson debugbreak::debugbreak cityhash::cityhash Taskflow::Taskflow + PUBLIC_MERGE_LIB rapidjson::rapidjson debugbreak::debugbreak cityhash::cityhash Taskflow::Taskflow ) file(GLOB test_sources Test/*.cpp) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 9b4f984e..b8eb80a1 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -230,21 +230,6 @@ if (${spirv-cross_READY}) ) endif () -# rapidjson -download_and_setup_3rd_package( - NAME rapidjson - PLATFORM All - VERSION d621dc9 - HASH 696f6ca1ecca9d13170c0a47eda66a3015bcf02a7b4bdd23f574ea302eb4bf3e -) -if (${rapidjson_READY}) - exp_add_3rd_header_only_package( - NAME rapidjson - SOURCE_DIR ${rapidjson_SOURCE_DIR} - INCLUDE $/include - ) -endif () - # conan managed if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") add_library(OpenGLDummy INTERFACE) @@ -260,6 +245,7 @@ find_package(libclang REQUIRED GLOBAL) find_package(assimp REQUIRED GLOBAL) find_package(VulkanMemoryAllocator REQUIRED GLOBAL) find_package(debugbreak REQUIRED GLOBAL) +find_package(rapidjson REQUIRED GLOBAL) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) diff --git a/ThirdParty/ConanRecipes/rapidjson/conandata.yml b/ThirdParty/ConanRecipes/rapidjson/conandata.yml new file mode 100644 index 00000000..db1ea513 --- /dev/null +++ b/ThirdParty/ConanRecipes/rapidjson/conandata.yml @@ -0,0 +1,3 @@ +sources: + "cci.20250205-exp": + commit: "24b5e7a8b27f42fa16b96fc70aade9106cf7102f" diff --git a/ThirdParty/ConanRecipes/rapidjson/conanfile.py b/ThirdParty/ConanRecipes/rapidjson/conanfile.py new file mode 100644 index 00000000..28fc23df --- /dev/null +++ b/ThirdParty/ConanRecipes/rapidjson/conanfile.py @@ -0,0 +1,38 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.scm import Git +from conan.tools.files import apply_conandata_patches, get, copy +import os + +required_conan_version = ">=2.0.9" + +class RapidJsonConan(ConanFile): + name = "rapidjson" + description = "rapidjson" + license = "https://github.com/Tencent/rapidjson?tab=License-1-ov-file" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/Tencent/rapidjson" + topics = ("utils", "json") + package_type = "header-library" + + def layout(self): + self.folders.source = "src" + self.folders.build = "build" + self.folders.generators = "build/generators" + + def source(self): + git = Git(self) + git.clone("https://github.com/Tencent/rapidjson.git", target=".") + git.checkout(self.conan_data["sources"][self.version]["commit"]) + apply_conandata_patches(self) + + def package(self): + copy(self, "*", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.includedirs = ["include"] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/rapidjson/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/rapidjson/test_package/CMakeLists.txt new file mode 100644 index 00000000..3c9040e6 --- /dev/null +++ b/ThirdParty/ConanRecipes/rapidjson/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(rapidjson REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE rapidjson::rapidjson) diff --git a/ThirdParty/ConanRecipes/rapidjson/test_package/conanfile.py b/ThirdParty/ConanRecipes/rapidjson/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/rapidjson/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/rapidjson/test_package/test_package.cpp b/ThirdParty/ConanRecipes/rapidjson/test_package/test_package.cpp new file mode 100644 index 00000000..0db25650 --- /dev/null +++ b/ThirdParty/ConanRecipes/rapidjson/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include + +int main(void) { + const char* json = "{\"a\": true, \"b\": 1, \"c\": \"2\"}"; + rapidjson::Document document; + document.Parse(json); + assert(document.IsObject()); + return 0; +} diff --git a/conanfile.py b/conanfile.py index 880b6db9..ffbb91cb 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,4 +1,6 @@ from conan import ConanFile +from typing_extensions import override + class ExplosionConan(ConanFile): generators = "CMakeConfigDeps" @@ -23,3 +25,4 @@ def requirements(self): self.requires("libclang/21.1.7-exp") self.requires("qt/6.10.1-exp") self.requires("debugbreak/1.0-exp") + self.requires("rapidjson/cci.20250205-exp") From cb235c0453e1e10845bd5f9a7f9e7a77a121cd31 Mon Sep 17 00:00:00 2001 From: kindem Date: Tue, 16 Dec 2025 22:30:00 +0800 Subject: [PATCH 32/44] feat: add assimp conan dependency --- ThirdParty/ConanRecipes/assimp/conandata.yml | 3 + ThirdParty/ConanRecipes/assimp/conanfile.py | 67 +++++++++++++++++++ .../assimp/test_package/CMakeLists.txt | 7 ++ .../assimp/test_package/conanfile.py | 25 +++++++ .../assimp/test_package/test_package.cpp | 9 +++ conanfile.py | 4 +- 6 files changed, 112 insertions(+), 3 deletions(-) create mode 100644 ThirdParty/ConanRecipes/assimp/conandata.yml create mode 100644 ThirdParty/ConanRecipes/assimp/conanfile.py create mode 100644 ThirdParty/ConanRecipes/assimp/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/assimp/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/assimp/test_package/test_package.cpp diff --git a/ThirdParty/ConanRecipes/assimp/conandata.yml b/ThirdParty/ConanRecipes/assimp/conandata.yml new file mode 100644 index 00000000..01dc5ceb --- /dev/null +++ b/ThirdParty/ConanRecipes/assimp/conandata.yml @@ -0,0 +1,3 @@ +sources: + "6.0.2-exp": + url: "https://github.com/assimp/assimp/archive/refs/tags/v6.0.2.tar.gz" diff --git a/ThirdParty/ConanRecipes/assimp/conanfile.py b/ThirdParty/ConanRecipes/assimp/conanfile.py new file mode 100644 index 00000000..a48a9206 --- /dev/null +++ b/ThirdParty/ConanRecipes/assimp/conanfile.py @@ -0,0 +1,67 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd +from conan.tools.build import can_run +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import apply_conandata_patches, get, collect_libs +import os + +required_conan_version = ">=2.0.9" + +class AssimpConan(ConanFile): + name = "assimp" + description = "assimp" + license = "https://github.com/assimp/assimp?tab=License-1-ov-file" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/assimp/assimp" + topics = ("model", "loader", "tool") + package_type = "shared-library" + settings = "os", "arch", "compiler", "build_type" + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + check_min_cppstd(self, 17) + + def requirements(self): + self.requires("zlib/1.3.1") + + def build_requirements(self): + self.tool_requires("ninja/[>=1.12]") + self.tool_requires("cmake/[>=3.16]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) + + def generate(self): + cmake_toolchain = CMakeToolchain(self, generator="Ninja") + cmake_toolchain.cache_variables["ASSIMP_BUILD_TESTS"] = "OFF" + cmake_toolchain.cache_variables["ASSIMP_WARNINGS_AS_ERRORS"] = "OFF" + cmake_toolchain.cache_variables["ASSIMP_INSTALL_PDB"] = "OFF" + cmake_toolchain.cache_variables["ASSIMP_BUILD_ZLIB"] = "OFF" + cmake_toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.libs = collect_libs(self) + self.cpp_info.includedirs = ["include"] + self.cpp_info.libdirs = ["lib"] + if self.settings.os == "Windows": + self.cpp_info.bindirs = ["bin"] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/assimp/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/assimp/test_package/CMakeLists.txt new file mode 100644 index 00000000..8a14c920 --- /dev/null +++ b/ThirdParty/ConanRecipes/assimp/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(assimp REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE assimp::assimp) diff --git a/ThirdParty/ConanRecipes/assimp/test_package/conanfile.py b/ThirdParty/ConanRecipes/assimp/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/assimp/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/assimp/test_package/test_package.cpp b/ThirdParty/ConanRecipes/assimp/test_package/test_package.cpp new file mode 100644 index 00000000..fbeef62b --- /dev/null +++ b/ThirdParty/ConanRecipes/assimp/test_package/test_package.cpp @@ -0,0 +1,9 @@ +#include +#include +#include + +int main(int argc, char **argv) { + Assimp::Importer importer; + const aiScene* scene = importer.ReadFile("", aiProcess_CalcTangentSpace | aiProcess_Triangulate | aiProcess_JoinIdenticalVertices | aiProcess_SortByPType); + return 0; +} \ No newline at end of file diff --git a/conanfile.py b/conanfile.py index ffbb91cb..41f007bc 100644 --- a/conanfile.py +++ b/conanfile.py @@ -14,9 +14,6 @@ def requirements(self): self.requires("gtest/1.17.0") self.requires("taskflow/3.10.0") self.requires("vulkan-memory-allocator/3.3.0") - self.requires("assimp/6.0.2", options={ - "shared": True - }) if self.settings.os == "Windows": self.requires("directx-headers/1.610.2") @@ -26,3 +23,4 @@ def requirements(self): self.requires("qt/6.10.1-exp") self.requires("debugbreak/1.0-exp") self.requires("rapidjson/cci.20250205-exp") + self.requires("assimp/6.0.2-exp") From 4ce093da19c652a94c8f96809d03b2e6a8864124 Mon Sep 17 00:00:00 2001 From: kindem Date: Wed, 17 Dec 2025 20:41:30 +0800 Subject: [PATCH 33/44] feat: add clipp conan dependency --- Engine/Source/Core/CMakeLists.txt | 2 +- Sample/CMakeLists.txt | 2 +- ThirdParty/CMakeLists.txt | 16 +---- ThirdParty/ConanRecipes/clipp/conandata.yml | 8 +++ ThirdParty/ConanRecipes/clipp/conanfile.py | 38 ++++++++++++ .../clipp/patches/0000-fix-cpp23.patch | 60 +++++++++++++++++++ .../clipp/test_package/CMakeLists.txt | 7 +++ .../clipp/test_package/conanfile.py | 25 ++++++++ .../clipp/test_package/test_package.cpp | 21 +++++++ Tool/MirrorTool/CMakeLists.txt | 2 +- conanfile.py | 3 +- 11 files changed, 164 insertions(+), 20 deletions(-) create mode 100644 ThirdParty/ConanRecipes/clipp/conandata.yml create mode 100644 ThirdParty/ConanRecipes/clipp/conanfile.py create mode 100644 ThirdParty/ConanRecipes/clipp/patches/0000-fix-cpp23.patch create mode 100644 ThirdParty/ConanRecipes/clipp/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/clipp/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/clipp/test_package/test_package.cpp diff --git a/Engine/Source/Core/CMakeLists.txt b/Engine/Source/Core/CMakeLists.txt index 22de49fc..c1571258 100644 --- a/Engine/Source/Core/CMakeLists.txt +++ b/Engine/Source/Core/CMakeLists.txt @@ -5,7 +5,7 @@ exp_add_library( SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Common - PUBLIC_MERGE_LIB clipp + PUBLIC_MERGE_LIB clipp::clipp ) file(GLOB test_sources Test/*.cpp) diff --git a/Sample/CMakeLists.txt b/Sample/CMakeLists.txt index db33ac05..7603dbea 100644 --- a/Sample/CMakeLists.txt +++ b/Sample/CMakeLists.txt @@ -52,7 +52,7 @@ exp_add_library( SRC ${sources} PUBLIC_INC Base PUBLIC_LIB RHI ${platform_ext_libs} Render.Static - PUBLIC_MERGE_LIB glfw clipp stb::stb assimp::assimp + PUBLIC_MERGE_LIB glfw clipp::clipp stb::stb assimp::assimp NOT_INSTALL ) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index b8eb80a1..2c9c6b25 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -193,21 +193,6 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") endif () endif () -# clipp -download_and_setup_3rd_package( - NAME clipp - PLATFORM All - VERSION forked-f7cffbd61a7b64189d6573e8c3848d094c35168a - HASH 59db8b8586381652b5e0ae629a9d32e0e443428bc4d94af091b9525a62d167fb -) -if (${clipp_READY}) - exp_add_3rd_header_only_package( - NAME clipp - SOURCE_DIR ${clipp_SOURCE_DIR} - INCLUDE $/include - ) -endif () - # spirv-cross download_and_setup_3rd_package( NAME spirv-cross @@ -246,6 +231,7 @@ find_package(assimp REQUIRED GLOBAL) find_package(VulkanMemoryAllocator REQUIRED GLOBAL) find_package(debugbreak REQUIRED GLOBAL) find_package(rapidjson REQUIRED GLOBAL) +find_package(clipp REQUIRED GLOBAL) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) diff --git a/ThirdParty/ConanRecipes/clipp/conandata.yml b/ThirdParty/ConanRecipes/clipp/conandata.yml new file mode 100644 index 00000000..6dc1f8e4 --- /dev/null +++ b/ThirdParty/ConanRecipes/clipp/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.2.3-exp": + url: "https://github.com/muellan/clipp/archive/refs/tags/v1.2.3.tar.gz" +patches: + "1.2.3-exp": + - patch_file: patches/0000-fix-cpp23.patch + patch_description: fix build for c++23 + patch_type: portability diff --git a/ThirdParty/ConanRecipes/clipp/conanfile.py b/ThirdParty/ConanRecipes/clipp/conanfile.py new file mode 100644 index 00000000..4895c2de --- /dev/null +++ b/ThirdParty/ConanRecipes/clipp/conanfile.py @@ -0,0 +1,38 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.files import get, apply_conandata_patches, copy, export_conandata_patches +import os + +required_conan_version = ">=2.0.9" + +class ClippConan(ConanFile): + name = "clipp" + description = "clipp" + license = "https://github.com/muellan/clipp?tab=MIT-1-ov-file" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/muellan/clipp" + topics = ("utils", "cli") + package_type = "header-library" + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + self.folders.source = "src" + self.folders.build = "build" + self.folders.generators = "build/generators" + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + apply_conandata_patches(self) + + def package(self): + copy(self, "*.h", os.path.join(self.source_folder, "include"), os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.includedirs = ["include"] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/clipp/patches/0000-fix-cpp23.patch b/ThirdParty/ConanRecipes/clipp/patches/0000-fix-cpp23.patch new file mode 100644 index 00000000..9d0f3dc6 --- /dev/null +++ b/ThirdParty/ConanRecipes/clipp/patches/0000-fix-cpp23.patch @@ -0,0 +1,60 @@ +From 390fd25c5404fdb9f8515774a1ab4283d06873e0 Mon Sep 17 00:00:00 2001 +From: K +Date: Thu, 7 Apr 2022 21:05:09 +0800 +Subject: [PATCH] fix: fix compile issue in C++23 + +#see https://github.com/muellan/clipp/pull/54 +--- + include/clipp.h | 22 +++++++++++++++++++--- + 1 file changed, 19 insertions(+), 3 deletions(-) + +diff --git a/include/clipp.h b/include/clipp.h +index d7b101e..a1bec2d 100644 +--- a/include/clipp.h ++++ b/include/clipp.h +@@ -155,16 +155,27 @@ namespace traits { + * @brief function (class) signature type trait + * + *****************************************************************************/ ++#if defined(__cpp_lib_is_invocable) + template + constexpr auto + check_is_callable(int) -> decltype( + std::declval()(std::declval()...), + std::integral_constant::type>::value>{} ); ++ std::is_same::type>::value>{} ); + +-template ++template + constexpr auto +-check_is_callable(long) -> std::false_type; ++check_is_callable_without_arg(int) -> decltype( ++ std::declval()(), ++ std::integral_constant::type>::value>{} ); ++#else ++template ++constexpr auto ++check_is_callable(int) -> decltype( ++ std::declval()(std::declval()...), ++ std::integral_constant::type>::value>{} ); + + template + constexpr auto +@@ -172,6 +183,11 @@ check_is_callable_without_arg(int) -> decltype( + std::declval()(), + std::integral_constant::type>::value>{} ); ++#endif ++ ++template ++constexpr auto ++check_is_callable(long) -> std::false_type; + + template + constexpr auto +-- +2.50.1.windows.1 + diff --git a/ThirdParty/ConanRecipes/clipp/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/clipp/test_package/CMakeLists.txt new file mode 100644 index 00000000..07a8b065 --- /dev/null +++ b/ThirdParty/ConanRecipes/clipp/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(clipp REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE clipp::clipp) diff --git a/ThirdParty/ConanRecipes/clipp/test_package/conanfile.py b/ThirdParty/ConanRecipes/clipp/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/clipp/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/clipp/test_package/test_package.cpp b/ThirdParty/ConanRecipes/clipp/test_package/test_package.cpp new file mode 100644 index 00000000..6846564a --- /dev/null +++ b/ThirdParty/ConanRecipes/clipp/test_package/test_package.cpp @@ -0,0 +1,21 @@ +#include +#include + +using namespace clipp; +using std::cout; +using std::string; + +int main(int argc, char* argv[]) { + bool rec = false, utf16 = false; + string infile = "", fmt = "csv"; + + auto cli = ( + value("input file", infile), + option("-r", "--recursive").set(rec).doc("convert files recursively"), + option("-o") & value("output format", fmt), + option("-utf16").set(utf16).doc("use UTF-16 encoding") + ); + + parse(argc, argv, cli); + return 0; +} diff --git a/Tool/MirrorTool/CMakeLists.txt b/Tool/MirrorTool/CMakeLists.txt index 6e0abbb0..75b78cfe 100644 --- a/Tool/MirrorTool/CMakeLists.txt +++ b/Tool/MirrorTool/CMakeLists.txt @@ -4,7 +4,7 @@ exp_add_library( SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Mirror - PUBLIC_MERGE_LIB libclang::libclang clipp + PUBLIC_MERGE_LIB libclang::libclang clipp::clipp NOT_INSTALL ) diff --git a/conanfile.py b/conanfile.py index 41f007bc..cdfe2cf3 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,6 +1,4 @@ from conan import ConanFile -from typing_extensions import override - class ExplosionConan(ConanFile): generators = "CMakeConfigDeps" @@ -24,3 +22,4 @@ def requirements(self): self.requires("debugbreak/1.0-exp") self.requires("rapidjson/cci.20250205-exp") self.requires("assimp/6.0.2-exp") + self.requires("clipp/1.2.3-exp") From 0a85f01f66de1f5e264db76c54cf8fb16a14f8e8 Mon Sep 17 00:00:00 2001 From: kindem Date: Wed, 17 Dec 2025 22:36:15 +0800 Subject: [PATCH 34/44] feat: add dxc conan dependency --- Engine/Source/Render/CMakeLists.txt | 2 +- ThirdParty/CMakeLists.txt | 36 +------- ThirdParty/ConanRecipes/README.md | 8 +- ThirdParty/ConanRecipes/dxc/conandata.yml | 3 + ThirdParty/ConanRecipes/dxc/conanfile.py | 74 +++++++++++++++ .../dxc/test_package/CMakeLists.txt | 9 ++ .../dxc/test_package/conanfile.py | 25 ++++++ .../dxc/test_package/test_package.cpp | 89 +++++++++++++++++++ conanfile.py | 1 + 9 files changed, 212 insertions(+), 35 deletions(-) create mode 100644 ThirdParty/ConanRecipes/dxc/conandata.yml create mode 100644 ThirdParty/ConanRecipes/dxc/conanfile.py create mode 100644 ThirdParty/ConanRecipes/dxc/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/dxc/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/dxc/test_package/test_package.cpp diff --git a/Engine/Source/Render/CMakeLists.txt b/Engine/Source/Render/CMakeLists.txt index 0a187690..5a2d70c5 100644 --- a/Engine/Source/Render/CMakeLists.txt +++ b/Engine/Source/Render/CMakeLists.txt @@ -9,7 +9,7 @@ exp_add_library( SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Core RHI - PUBLIC_MERGE_LIB dxc spirv-cross ${platform_libs} + PUBLIC_MERGE_LIB dxc::dxc spirv-cross ${platform_libs} ) file(GLOB shader_sources SharedSrc/*.cpp) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index 2c9c6b25..b913c610 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -160,39 +160,6 @@ if (${VulkanSDK_READY}) endif () endif () -# DXC -# Windows uses standalone package, macOS uses lib in VulkanSDK -if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - download_and_setup_3rd_package( - NAME dxc - PLATFORM Windows - VERSION 1.6.2112 - HASH b8d8e5cd03234e477bc3fe5d4258652a7fb61916141660408ee4c54a4f1eb939 - ) - if (${dxc_READY}) - exp_add_3rd_binary_package( - NAME dxc - SOURCE_DIR ${dxc_SOURCE_DIR} - INCLUDE $/inc - LINK $/lib/x64 - LIB dxcompiler - RUNTIME_DEP - Windows $/bin/x64/dxcompiler.dll $/bin/x64/dxil.dll - ) - endif () -elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - should_setup_3rd_package( - NAME dxc - PLATFORM Darwin - ) - if (${dxc_READY}) - exp_add_3rd_alias_package( - NAME dxc - LIB dxcompiler - ) - endif () -endif () - # spirv-cross download_and_setup_3rd_package( NAME spirv-cross @@ -220,6 +187,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") add_library(OpenGLDummy INTERFACE) add_library(opengl::opengl ALIAS OpenGLDummy) endif () + find_package(httplib REQUIRED GLOBAL) find_package(glfw3 REQUIRED GLOBAL) find_package(stb REQUIRED GLOBAL) @@ -232,9 +200,11 @@ find_package(VulkanMemoryAllocator REQUIRED GLOBAL) find_package(debugbreak REQUIRED GLOBAL) find_package(rapidjson REQUIRED GLOBAL) find_package(clipp REQUIRED GLOBAL) +find_package(dxc REQUIRED GLOBAL) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) set_target_properties(assimp::assimp PROPERTIES RUNTIME_DEP "${assimp_INCLUDE_DIR}/../bin/assimp-vc${MSVC_TOOLSET_VERSION}-mt.dll") set_target_properties(libclang::libclang PROPERTIES RUNTIME_DEP "${libclang_INCLUDE_DIR}/../bin/libclang.dll") + set_target_properties(dxc::dxc PROPERTIES RUNTIME_DEP "${dxc_INCLUDE_DIR}/../bin/dxil.dll;${dxc_INCLUDE_DIR}/../bin/") endif () diff --git a/ThirdParty/ConanRecipes/README.md b/ThirdParty/ConanRecipes/README.md index 01132454..f32e1eb6 100644 --- a/ThirdParty/ConanRecipes/README.md +++ b/ThirdParty/ConanRecipes/README.md @@ -27,7 +27,13 @@ conan test qt/test_package qt/6.10.1-exp ``` # Windows User Notice -In windows, some lib may build failed with long build tree path in development mode (like qt-webengine), in this case, you can use the commands to map conan recipes working directory as a driver and execute all conan commands in the driver root: +On the Windows platform, we consider some Visual Studio components as part of the system toolchain. These components are not automatically configured in the conan script, so you will need to install them manually: + +* ATL +* Windows SDK +* Windows Driver Kit + +And some lib may build failed with long build tree path in development mode (like qt-webengine), in this case, you can use the commands to map conan recipes working directory as a driver and execute all conan commands in the driver root: ```shell # map diff --git a/ThirdParty/ConanRecipes/dxc/conandata.yml b/ThirdParty/ConanRecipes/dxc/conandata.yml new file mode 100644 index 00000000..20866f15 --- /dev/null +++ b/ThirdParty/ConanRecipes/dxc/conandata.yml @@ -0,0 +1,3 @@ +sources: + "1.8.2505.1-exp": + commit: "b106a961d09221b3c5bdb37be45b679257da08b8" diff --git a/ThirdParty/ConanRecipes/dxc/conanfile.py b/ThirdParty/ConanRecipes/dxc/conanfile.py new file mode 100644 index 00000000..53d377ea --- /dev/null +++ b/ThirdParty/ConanRecipes/dxc/conanfile.py @@ -0,0 +1,74 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd, can_run +from conan.tools.cmake import cmake_layout, CMakeToolchain, CMakeDeps, CMake +from conan.tools.files import apply_conandata_patches, copy +from conan.tools.scm import Git +import os + +required_conan_version = ">=2.0.9" + +class DXCConan(ConanFile): + name = "dxc" + description = "DirectX shader compiler" + license = "https://github.com/microsoft/DirectXShaderCompiler?tab=License-1-ov-file" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/microsoft/DirectXShaderCompiler" + topics = ("shader", "tool", "compiler") + package_type = "shared-library" + settings = "os", "arch", "compiler", "build_type" + options = {} + default_options = {} + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + check_min_cppstd(self, 17) + + def build_requirements(self): + self.tool_requires("ninja/[>=1.12]") + self.tool_requires("cmake/[>=3.16]") + + def source(self): + git = Git(self) + git.clone("https://github.com/microsoft/DirectXShaderCompiler", target=".") + git.checkout(self.conan_data["sources"][self.version]["commit"]) + git.run("submodule update --init --recursive") + apply_conandata_patches(self) + + def generate(self): + cmake_toolchain = CMakeToolchain(self, generator="Ninja") + cmake_toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + install_folder = os.path.join(self.build_folder, "installed") + predefined_params_file = os.path.join(self.source_folder, "cmake", "caches", "PredefinedParams.cmake") + + cmake = CMake(self) + cmake.configure(cli_args=["-C", predefined_params_file, f"-DCMAKE_INSTALL_PREFIX={install_folder}"]) + cmake.build() + cmake.build(target="install-distribution") + + def package(self): + copy(self, "*", os.path.join(self.build_folder, "installed", "include"), os.path.join(self.package_folder, "include")) + copy(self, "*", os.path.join(self.build_folder, "installed", "bin"), os.path.join(self.package_folder, "bin")) + if self.settings.os == "Windows": + copy(self, "d3d12shader.h", os.path.join(self.source_folder, "external", "DirectX-Headers", "include", "directx"), os.path.join(self.package_folder, "include", "dxc")) + copy(self, "dxil.dll", os.path.join(self.build_folder, "bin"), os.path.join(self.package_folder, "bin")) + copy(self, "dxcompiler.lib", os.path.join(self.build_folder, "lib"), os.path.join(self.package_folder, "lib")) + elif self.settings.os == "Macos": + copy(self, "*", os.path.join(self.build_folder, "installed", "lib"), os.path.join(self.package_folder, "lib")) + + def package_info(self): + self.cpp_info.includedirs = ["include"] + self.cpp_info.libdirs = ["lib"] + self.cpp_info.bindirs = ["bin"] + self.cpp_info.libs = ["dxcompiler"] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/dxc/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/dxc/test_package/CMakeLists.txt new file mode 100644 index 00000000..7f644749 --- /dev/null +++ b/ThirdParty/ConanRecipes/dxc/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(dxc REQUIRED) + +add_definitions(-DPLATFORM_WINDOWS=$,1,0>) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE dxc::dxc) diff --git a/ThirdParty/ConanRecipes/dxc/test_package/conanfile.py b/ThirdParty/ConanRecipes/dxc/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/dxc/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/dxc/test_package/test_package.cpp b/ThirdParty/ConanRecipes/dxc/test_package/test_package.cpp new file mode 100644 index 00000000..b01f3a2e --- /dev/null +++ b/ThirdParty/ConanRecipes/dxc/test_package/test_package.cpp @@ -0,0 +1,89 @@ +#include +#include +#include + +#if PLATFORM_WINDOWS +#include +#include +#else +#define __EMULATE_UUID 1 +#endif + +#include + +#if PLATFORM_WINDOWS +#include +using namespace Microsoft::WRL; +#define ComPtrGet(name) name.Get() +#else +// defined in dxc WinAdapter.h +#define ComPtr CComPtr +#define ComPtrGet(name) name +#endif + +int main(void) { + const std::string shaderSource = "[numthreads(8, 8, 1)] void CSMain() { }"; + + ComPtr library; + if (FAILED(DxcCreateInstance(CLSID_DxcLibrary, IID_PPV_ARGS(&library)))) { + std::cout << "failed to create dxc library" << std::endl; + return 1; + } + + ComPtr compiler; + if (FAILED(DxcCreateInstance(CLSID_DxcCompiler, IID_PPV_ARGS(&compiler)))) { + std::cout << "failed to create dxc compiler" << std::endl; + return 1; + } + + ComPtr utils; + if (FAILED(SUCCEEDED(DxcCreateInstance(CLSID_DxcUtils, IID_PPV_ARGS(&utils))))) { + std::cout << "failed to create dxc utils" << std::endl; + return 1; + } + + ComPtr includeHandler; + if (FAILED(SUCCEEDED(utils->CreateDefaultIncludeHandler(&includeHandler)))) { + std::cout << "failed to create dxc include handler" << std::endl; + return 1; + } + + ComPtr source; + if (FAILED(utils->CreateBlobFromPinned(shaderSource.c_str(), std::strlen(shaderSource.c_str()), CP_UTF8, &source))) { + std::cout << "failed to create dxc blob encoding" << std::endl; + return 1; + } + + std::vector arguments = { + DXC_ARG_WARNINGS_ARE_ERRORS, + DXC_ARG_PACK_MATRIX_ROW_MAJOR, + L"-E", L"CSMain", + L"-T", L"cs_6_2" + }; + + DxcBuffer sourceBuffer; + sourceBuffer.Ptr = source->GetBufferPointer(); + sourceBuffer.Size = source->GetBufferSize(); + sourceBuffer.Encoding = 0u; + + ComPtr result; + const HRESULT operationResult = compiler->Compile( + &sourceBuffer, + arguments.data(), + arguments.size(), + ComPtrGet(includeHandler), + IID_PPV_ARGS(&result)); + + ComPtr errorBlob; + if (FAILED(result->GetOutput(DXC_OUT_ERRORS, IID_PPV_ARGS(&errorBlob), nullptr))) { + std::cout << "failed to get error info" << std::endl; + return 1; + } + + if (FAILED(operationResult) || errorBlob->GetBufferSize() > 0) { + std::string error(static_cast(errorBlob->GetBufferPointer()), errorBlob->GetBufferSize()); + std::cout << "dxc compile error: " << error << std::endl; + return 1; + } + return 0; +} diff --git a/conanfile.py b/conanfile.py index cdfe2cf3..5b79ab0b 100644 --- a/conanfile.py +++ b/conanfile.py @@ -23,3 +23,4 @@ def requirements(self): self.requires("rapidjson/cci.20250205-exp") self.requires("assimp/6.0.2-exp") self.requires("clipp/1.2.3-exp") + self.requires("dxc/1.8.2505.1-exp") From 7be0a8637e4d1b13cc8f6b7f116cf1bd0b7bb8ab Mon Sep 17 00:00:00 2001 From: kindem Date: Sat, 20 Dec 2025 15:46:54 +0800 Subject: [PATCH 35/44] feat: remove auto config vulkan validation layers logic in cmake --- ThirdParty/CMakeLists.txt | 76 --------------------------------------- 1 file changed, 76 deletions(-) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index b913c610..f34c4719 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -82,82 +82,6 @@ if (${VulkanSDK_READY}) Windows vulkan-1 Darwin vulkan.1 ) - if (NOT ${CI}) - #see https://github.com/KhronosGroup/Vulkan-Loader/blob/main/docs/LoaderLayerInterface.md - if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - execute_process(COMMAND reg query "HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers" OUTPUT_VARIABLE layers) - string(REGEX MATCH "VkLayer_khronos_validation\.json" match_result ${layers}) - list(LENGTH match_result match_result_length) - - if (${match_result_length} GREATER 0) - message("Used registered validation layer in HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers") - else () - set(validation_layer_json ${3RD_SOURCE_DIR}/VulkanSDK-Windows-${VULKAN_SDK_VERSION}/Bin/VkLayer_khronos_validation.json) - message("Found no registered validation layer, will register ${validation_layer_json} to reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers") - string(REPLACE "/" "\\" validation_layer_json ${validation_layer_json}) - execute_process(COMMAND PowerShell -Command "Start-Process reg -ArgumentList 'add HKEY_LOCAL_MACHINE\\SOFTWARE\\Khronos\\Vulkan\\ExplicitLayers /v ${validation_layer_json} /t REG_DWORD /d 0' -Verb RunAs") - endif () - else (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - # new version of vulkaninfo application use volk to perform dynamic loading, which need libvulkan.dylib in working directory or system, - # so if vulkaninfo print initialized failed, we need copy vulkan dynamic lib to working directory - set(platform_vulkan_sdk_dir ${CMAKE_SOURCE_DIR}/ThirdParty/Lib/VulkanSDK-Darwin-${VULKAN_SDK_VERSION}/macOS) - execute_process(COMMAND ${platform_vulkan_sdk_dir}/bin/vulkaninfo WORKING_DIRECTORY ${platform_vulkan_sdk_dir}/bin OUTPUT_VARIABLE vulkan_info ERROR_VARIABLE vulkan_info) - string(REGEX MATCH "Failed to initialize" match_result ${vulkan_info}) - list(LENGTH match_result match_result_length) - if (${match_result_length} GREATER 0) - set(src_file ${platform_vulkan_sdk_dir}/lib/libvulkan.dylib) - set(dst_file ${platform_vulkan_sdk_dir}/bin/libvulkan.dylib) - message("vulkaninfo initialized failed, perform vulkan dynamic library copy: ${src_file} -> ${dst_file}") - file(COPY_FILE ${src_file} ${dst_file} ONLY_IF_DIFFERENT) - else () - message("vulkaninfo test success") - endif () - - # check drivers - execute_process(COMMAND ${platform_vulkan_sdk_dir}/bin/vulkaninfo WORKING_DIRECTORY ${platform_vulkan_sdk_dir}/bin OUTPUT_VARIABLE vulkan_info ERROR_VARIABLE vulkan_info) - string(REGEX MATCH "ERROR_INCOMPATIBLE_DRIVER" match_result ${vulkan_info}) - list(LENGTH match_result match_result_length) - if (${match_result_length} GREATER 0) - message("there is no drivers found for vulkan, copy and rewrite driver files to ~/.config/vulkan/icd.d") - get_filename_component(drivers_dir_absolute ~/.config/vulkan/icd.d ABSOLUTE) - if (NOT EXISTS ${drivers_dir_absolute}) - file(MAKE_DIRECTORY ${drivers_dir_absolute}) - endif () - - file(GLOB driver_files ${platform_vulkan_sdk_dir}/share/vulkan/icd.d/*.json) - foreach (driver_file ${driver_files}) - file(READ ${driver_file} file_content) - string(REPLACE "../../../lib" "${platform_vulkan_sdk_dir}/lib" file_content ${file_content}) - get_filename_component(file_name ${driver_file} NAME) - file(WRITE ${drivers_dir_absolute}/${file_name} ${file_content}) - endforeach () - else () - message("found vulkan drivers installed in system, will use it") - endif () - - # check layers - execute_process(COMMAND ${platform_vulkan_sdk_dir}/bin/vulkaninfo WORKING_DIRECTORY ${platform_vulkan_sdk_dir}/bin OUTPUT_VARIABLE vulkan_info ERROR_VARIABLE vulkan_info) - string(REGEX MATCH "Layers:\n=======" match_result ${vulkan_info}) - list(LENGTH match_result match_result_length) - if (${match_result_length} GREATER 0) - message("there is no layers found for vulkan, copy and rewrite layer files to ~/.config/vulkan/explicit_layer.d") - get_filename_component(layers_dir_absolute ~/.config/vulkan/explicit_layer.d ABSOLUTE) - if (NOT EXISTS ${layers_dir_absolute}) - file(MAKE_DIRECTORY ${layers_dir_absolute}) - endif () - - file(GLOB layer_files ${platform_vulkan_sdk_dir}/share/vulkan/explicit_layer.d/*.json) - foreach (layer_file ${layer_files}) - file(READ ${layer_file} file_content) - string(REPLACE "../../../lib" "${platform_vulkan_sdk_dir}/lib" file_content ${file_content}) - get_filename_component(file_name ${layer_file} NAME) - file(WRITE ${layers_dir_absolute}/${file_name} ${file_content}) - endforeach () - else () - message("found vulkan layers installed in system, will use it") - endif () - endif () - endif () endif () # spirv-cross From fd425d53c804b9e0abc13aa57b1bef5b62ec592d Mon Sep 17 00:00:00 2001 From: kindem Date: Sat, 20 Dec 2025 16:01:15 +0800 Subject: [PATCH 36/44] feat: add vulkan validation layers and utility libraries conan recipe --- .../vulkan-utility-libraries/conandata.yml | 3 + .../vulkan-utility-libraries/conanfile.py | 84 +++++++++++++++++++ .../test_package/CMakeLists.txt | 7 ++ .../test_package/conanfile.py | 25 ++++++ .../test_package/test_package.cpp | 8 ++ .../vulkan-validationlayers/conandata.yml | 8 ++ .../vulkan-validationlayers/conanfile.py | 79 +++++++++++++++++ .../0000-fix-spirv-tools-includes.patch | 25 ++++++ .../test_package/CMakeLists.txt | 25 ++++++ .../test_package/conanfile.py | 25 ++++++ .../test_package/test_package.cpp | 3 + 11 files changed, 292 insertions(+) create mode 100644 ThirdParty/ConanRecipes/vulkan-utility-libraries/conandata.yml create mode 100644 ThirdParty/ConanRecipes/vulkan-utility-libraries/conanfile.py create mode 100644 ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/test_package.cpp create mode 100644 ThirdParty/ConanRecipes/vulkan-validationlayers/conandata.yml create mode 100644 ThirdParty/ConanRecipes/vulkan-validationlayers/conanfile.py create mode 100644 ThirdParty/ConanRecipes/vulkan-validationlayers/patches/0000-fix-spirv-tools-includes.patch create mode 100644 ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/test_package.cpp diff --git a/ThirdParty/ConanRecipes/vulkan-utility-libraries/conandata.yml b/ThirdParty/ConanRecipes/vulkan-utility-libraries/conandata.yml new file mode 100644 index 00000000..d1483c32 --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-utility-libraries/conandata.yml @@ -0,0 +1,3 @@ +sources: + "1.4.313.0-exp": + branch: "vulkan-sdk-1.4.313" diff --git a/ThirdParty/ConanRecipes/vulkan-utility-libraries/conanfile.py b/ThirdParty/ConanRecipes/vulkan-utility-libraries/conanfile.py new file mode 100644 index 00000000..17817d35 --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-utility-libraries/conanfile.py @@ -0,0 +1,84 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd, can_run +from conan.tools.cmake import cmake_layout, CMakeToolchain, CMakeDeps, CMake +from conan.tools.files import apply_conandata_patches +from conan.tools.scm import Git +import os + +required_conan_version = ">=2.0.9" + +class VulkanUtilityLibrariesConan(ConanFile): + name = "vulkan-utility-libraries" + description = "vulkan utility libraries" + license = "https://github.com/KhronosGroup/Vulkan-Utility-Libraries?tab=License-1-ov-file" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/KhronosGroup/Vulkan-Utility-Libraries" + topics = ("vulkan", "utils") + package_type = "static-library" + settings = "os", "arch", "compiler", "build_type" + options = {} + default_options = {} + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + check_min_cppstd(self, 17) + + def requirements(self): + base_version = self.version.replace("-exp", "") + self.requires(f"vulkan-headers/{base_version}", transitive_headers=True) + + def build_requirements(self): + self.tool_requires("ninja/[>=1.12]") + self.tool_requires("cmake/[>=3.16]") + + def source(self): + git = Git(self) + git.clone("https://github.com/KhronosGroup/Vulkan-Utility-Libraries", target=".", args=["-b", self.conan_data["sources"][self.version]["branch"]]) + apply_conandata_patches(self) + + def generate(self): + cmake_toolchain = CMakeToolchain(self, generator="Ninja") + cmake_toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "VulkanUtilityLibraries") + + self.cpp_info.components["vulkanlayersettings"].set_property("cmake_target_name", "Vulkan::LayerSettings") + self.cpp_info.components["vulkanlayersettings"].bindirs = [] + self.cpp_info.components["vulkanlayersettings"].libdirs = ["lib"] + self.cpp_info.components["vulkanlayersettings"].includedirs = ["include"] + self.cpp_info.components["vulkanlayersettings"].requires = ["vulkan-headers::vulkanheaders"] + self.cpp_info.components["vulkanlayersettings"].libs = ["VulkanLayerSettings"] + + self.cpp_info.components["vulkanutilityheaders"].set_property("cmake_target_name", "Vulkan::UtilityHeaders") + self.cpp_info.components["vulkanutilityheaders"].bindirs = [] + self.cpp_info.components["vulkanutilityheaders"].libdirs = [] + self.cpp_info.components["vulkanutilityheaders"].includedirs = ["include"] + self.cpp_info.components["vulkanutilityheaders"].requires = ["vulkan-headers::vulkanheaders"] + self.cpp_info.components["vulkanutilityheaders"].libs = [] + + self.cpp_info.components["vulkansafestruct"].set_property("cmake_target_name", "Vulkan::SafeStruct") + self.cpp_info.components["vulkansafestruct"].bindirs = [] + self.cpp_info.components["vulkansafestruct"].libdirs = ["lib"] + self.cpp_info.components["vulkansafestruct"].includedirs = ["include"] + self.cpp_info.components["vulkansafestruct"].requires = ["vulkan-headers::vulkanheaders", "vulkanutilityheaders"] + self.cpp_info.components["vulkansafestruct"].libs = ["VulkanSafeStruct"] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/CMakeLists.txt new file mode 100644 index 00000000..7c3013bc --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(VulkanUtilityLibraries REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE Vulkan::LayerSettings Vulkan::UtilityHeaders Vulkan::SafeStruct) diff --git a/ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/conanfile.py b/ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/test_package.cpp b/ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/test_package.cpp new file mode 100644 index 00000000..4f74a926 --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-utility-libraries/test_package/test_package.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main(int argc, char* argv[]) +{ + vku::safe_VkInstanceCreateInfo safe_info; + return 0; +} diff --git a/ThirdParty/ConanRecipes/vulkan-validationlayers/conandata.yml b/ThirdParty/ConanRecipes/vulkan-validationlayers/conandata.yml new file mode 100644 index 00000000..560d4bde --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-validationlayers/conandata.yml @@ -0,0 +1,8 @@ +sources: + "1.4.313.0-exp": + branch: "vulkan-sdk-1.4.313" +patches: + "1.4.313.0-exp": + - patch_file: patches/0000-fix-spirv-tools-includes.patch + patch_description: fix spir-v tools includes + patch_type: portability diff --git a/ThirdParty/ConanRecipes/vulkan-validationlayers/conanfile.py b/ThirdParty/ConanRecipes/vulkan-validationlayers/conanfile.py new file mode 100644 index 00000000..6740f211 --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-validationlayers/conanfile.py @@ -0,0 +1,79 @@ +from os import mkdir + +from conan import ConanFile +from conan.tools.build import check_min_cppstd, can_run +from conan.tools.cmake import cmake_layout, CMakeToolchain, CMakeDeps, CMake +from conan.tools.files import apply_conandata_patches, export_conandata_patches +from conan.tools.scm import Git +import os + +required_conan_version = ">=2.0.9" + +class VulkanValidationLayersConan(ConanFile): + name = "vulkan-validationlayers" + description = "vulkan validation layers" + license = "https://github.com/KhronosGroup/Vulkan-ValidationLayers?tab=License-1-ov-file" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/KhronosGroup/Vulkan-ValidationLayers" + topics = ("vulkan", "debug") + package_type = "shared-library" + settings = "os", "arch", "compiler", "build_type" + options = {} + default_options = {} + + def export_sources(self): + export_conandata_patches(self) + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + check_min_cppstd(self, 17) + + def requirements(self): + base_version = self.version.replace("-exp", "") + self.requires(f"vulkan-headers/{base_version}") + self.requires(f"spirv-headers/{base_version}") + self.requires(f"spirv-tools/{base_version}") + self.requires(f"vulkan-utility-libraries/{self.version}") + + def build_requirements(self): + self.tool_requires("ninja/[>=1.12]") + self.tool_requires("cmake/[>=3.16]") + + def source(self): + git = Git(self) + git.clone("https://github.com/KhronosGroup/Vulkan-ValidationLayers", target=".", args=["-b", self.conan_data["sources"][self.version]["branch"]]) + apply_conandata_patches(self) + + def generate(self): + cmake_toolchain = CMakeToolchain(self, generator="Ninja") + cmake_toolchain.cache_variables["UPDATE_DEPS"] = "OFF" + cmake_toolchain.cache_variables["BUILD_WERROR"] = "OFF" + cmake_toolchain.cache_variables["BUILD_TESTS"] = "OFF" + cmake_toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + os.mkdir(os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "VulkanValidationLayers") + self.cpp_info.bindirs = ["bin"] + self.cpp_info.includedirs = ["include"] + self.cpp_info.libs = [] + self.cpp_info.libdirs = [] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/vulkan-validationlayers/patches/0000-fix-spirv-tools-includes.patch b/ThirdParty/ConanRecipes/vulkan-validationlayers/patches/0000-fix-spirv-tools-includes.patch new file mode 100644 index 00000000..10985357 --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-validationlayers/patches/0000-fix-spirv-tools-includes.patch @@ -0,0 +1,25 @@ +From 2e18b94238535157d98b0ccfa9df9e6d8a96fe7b Mon Sep 17 00:00:00 2001 +From: kindem +Date: Sat, 20 Dec 2025 17:16:43 +0800 +Subject: [PATCH] fix: spirv tools includes + +--- + CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index f2c844b7a..9af78879d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -115,7 +115,7 @@ find_package(VulkanUtilityLibraries CONFIG QUIET) + + find_package(SPIRV-Headers CONFIG QUIET) + +-find_package(SPIRV-Tools-opt CONFIG QUIET) ++find_package(SPIRV-Tools CONFIG QUIET) + + # NOTE: Our custom code generation target isn't desirable for system package managers or add_subdirectory users. + # So this target needs to be off by default to avoid obtuse build errors or patches. +-- +2.50.1.windows.1 + diff --git a/ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/CMakeLists.txt new file mode 100644 index 00000000..b52a2443 --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(VulkanValidationLayers REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") + add_custom_command( + TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VulkanValidationLayers_INCLUDE_DIR}/../bin/VkLayer_khronos_validation.dll $/VkLayer_khronos_validation.dll + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VulkanValidationLayers_INCLUDE_DIR}/../bin/VkLayer_khronos_validation.json $/VkLayer_khronos_validation.json + ) +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + add_custom_command( + TARGET ${PROJECT_NAME} + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${VulkanValidationLayers_INCLUDE_DIR}/../lib/libVkLayer_khronos_validation.dylib $/VkLayer_khronos_validation.dylib + COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${VulkanValidationLayers_INCLUDE_DIR}/../share/vulkan $/vulkan + ) +else () + message(FATAL_ERROR "os ${CMAKE_SYSTEM_NAME} not supported yet in test package") +endif () + diff --git a/ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/conanfile.py b/ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/test_package.cpp b/ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/test_package.cpp new file mode 100644 index 00000000..e9cdae16 --- /dev/null +++ b/ThirdParty/ConanRecipes/vulkan-validationlayers/test_package/test_package.cpp @@ -0,0 +1,3 @@ +int main() { + return 0; +} \ No newline at end of file From 8edd2a9e5f32e2d40ed47d650f9e4d01ab6aed96 Mon Sep 17 00:00:00 2001 From: kindem Date: Sat, 20 Dec 2025 19:22:48 +0800 Subject: [PATCH 37/44] fix: dxc runtime dep on windows --- ThirdParty/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index f34c4719..b42c4f02 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -130,5 +130,5 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) set_target_properties(assimp::assimp PROPERTIES RUNTIME_DEP "${assimp_INCLUDE_DIR}/../bin/assimp-vc${MSVC_TOOLSET_VERSION}-mt.dll") set_target_properties(libclang::libclang PROPERTIES RUNTIME_DEP "${libclang_INCLUDE_DIR}/../bin/libclang.dll") - set_target_properties(dxc::dxc PROPERTIES RUNTIME_DEP "${dxc_INCLUDE_DIR}/../bin/dxil.dll;${dxc_INCLUDE_DIR}/../bin/") + set_target_properties(dxc::dxc PROPERTIES RUNTIME_DEP "${dxc_INCLUDE_DIR}/../bin/dxil.dll;${dxc_INCLUDE_DIR}/../bin/dxcompiler.dll") endif () From 7f75ffb33666421094cb2382a4e001364f58c23a Mon Sep 17 00:00:00 2001 From: kindem Date: Sat, 20 Dec 2025 19:24:35 +0800 Subject: [PATCH 38/44] feat: remove vulkan sdk, use conan vulkan components --- CMake/Target.cmake | 5 + CMake/ThirdParty.cmake | 337 ------------------ CMakeLists.txt | 1 - Editor/CMakeLists.txt | 2 + .../Source/Common/Include/Common/Platform.h | 7 + Engine/Source/Common/Src/Platform.cpp | 21 ++ Engine/Source/RHI-Vulkan/CMakeLists.txt | 2 +- Engine/Source/RHI-Vulkan/Src/Instance.cpp | 11 +- Engine/Source/Render/CMakeLists.txt | 6 +- ThirdParty/CMakeLists.txt | 117 +----- .../Qt-Darwin-6.9.1-FindWrapOpenGL.cmake | 57 --- conanfile.py | 6 + 12 files changed, 61 insertions(+), 511 deletions(-) delete mode 100644 CMake/ThirdParty.cmake create mode 100644 Engine/Source/Common/Src/Platform.cpp delete mode 100644 ThirdParty/Patch/Qt-Darwin-6.9.1-FindWrapOpenGL.cmake diff --git a/CMake/Target.cmake b/CMake/Target.cmake index ebb4b6f6..45859a86 100644 --- a/CMake/Target.cmake +++ b/CMake/Target.cmake @@ -77,6 +77,11 @@ function(exp_process_runtime_dependencies) ) foreach (d ${arg_DEP_TARGET}) list(APPEND runtime_deps $) + exp_gather_target_runtime_dependencies_recurse( + NAME ${d} + OUT_RUNTIME_DEP dep_target_runtime_deps + ) + list(APPEND runtime_deps ${dep_target_runtime_deps}) endforeach () foreach(r ${runtime_deps}) add_custom_command( diff --git a/CMake/ThirdParty.cmake b/CMake/ThirdParty.cmake deleted file mode 100644 index 4b86cd4c..00000000 --- a/CMake/ThirdParty.cmake +++ /dev/null @@ -1,337 +0,0 @@ -function(exp_download_and_extract_3rd_package) - set(options "") - set(singleValueArgs URL SAVE_AS EXTRACT_TO) - set(multiValueArgs HASH) - cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (EXISTS ${arg_SAVE_AS}) - message("found downloaded file for ${arg_URL} -> ${arg_SAVE_AS}") - else() - message("starting download package ${arg_URL}") - file( - DOWNLOAD - ${arg_URL} ${arg_SAVE_AS} - SHOW_PROGRESS - ) - endif() - - if (DEFINED arg_HASH) - exp_get_3rd_platform_value( - OUTPUT platform_hash - INPUT ${arg_HASH} - ) - - file(SHA256 ${arg_SAVE_AS} hash_value) - if (NOT (${platform_hash} STREQUAL ${hash_value})) - message(FATAL_ERROR "check hash value failed for file ${arg_SAVE_AS}, given ${platform_hash} actual ${hash_value}") - endif () - endif() - - if (NOT EXISTS ${arg_EXTRACT_TO}) - file( - ARCHIVE_EXTRACT - INPUT ${arg_SAVE_AS} - DESTINATION ${arg_EXTRACT_TO} - ) - endif() -endfunction() - -function(exp_expand_3rd_path_expression) - set(options "") - set(singleValueArgs OUTPUT SOURCE_DIR BINARY_DIR INSTALL_DIR) - set(multiValueArgs INPUT) - cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - - foreach(i ${arg_INPUT}) - set(temp "${i}") - if (DEFINED arg_SOURCE_DIR) - string(REPLACE "$" ${arg_SOURCE_DIR} temp ${temp}) - endif() - if (DEFINED arg_BINARY_DIR) - string(REPLACE "$" ${arg_BINARY_DIR} temp ${temp}) - endif() - if (DEFINED arg_INSTALL_DIR) - string(REPLACE "$" ${arg_INSTALL_DIR} temp ${temp}) - endif() - list(APPEND result ${temp}) - endforeach() - - set(${arg_OUTPUT} ${result} PARENT_SCOPE) -endfunction() - -function(exp_get_3rd_platform_value) - set(options "") - set(singleValueArgs OUTPUT) - set(multiValueArgs INPUT) - cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(platform_keywords "Windows;Darwin;Linux") - - set(has_keywords FALSE) - foreach (i ${arg_INPUT}) - foreach (k ${platform_keywords}) - if (${i} STREQUAL ${k}) - set(has_keywords TRUE) - break() - endif() - endforeach() - - if (${has_keywords}) - break() - endif() - endforeach() - - set(start_log FALSE) - foreach (i ${arg_INPUT}) - if ((NOT ${start_log}) AND (${i} STREQUAL ${CMAKE_SYSTEM_NAME})) - set(start_log TRUE) - continue() - endif() - - if (NOT ${start_log}) - continue() - endif() - - set(end_log FALSE) - foreach (k ${platform_keywords}) - if (${k} STREQUAL ${i}) - set(end_log TRUE) - break() - endif() - endforeach() - - if (${end_log}) - break() - endif() - - list(APPEND result ${i}) - endforeach () - - if (${has_keywords}) - set(${arg_OUTPUT} ${result} PARENT_SCOPE) - else() - set(${arg_OUTPUT} ${arg_INPUT} PARENT_SCOPE) - endif() -endfunction() - -function(exp_add_3rd_header_only_package) - set(options "") - set(singleValueArgs NAME SOURCE_DIR INSTALL_DIR) - set(multiValueArgs INSTALL_FILES INCLUDE) - cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - - add_library(${arg_NAME} INTERFACE) - - if (DEFINED arg_INSTALL_DIR AND DEFINED arg_INSTALL_FILES) - foreach (install_file ${arg_INSTALL_FILES}) - if (IS_DIRECTORY ${arg_SOURCE_DIR}/${install_file}) - list(APPEND commands COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${arg_SOURCE_DIR}/${install_file} ${arg_INSTALL_DIR}/${install_file}) - else () - list(APPEND commands COMMAND ${CMAKE_COMMAND} -E copy_if_different ${arg_SOURCE_DIR}/${install_file} ${arg_INSTALL_DIR}/${install_file}) - endif () - endforeach () - - add_custom_target( - ${arg_NAME}.Install - COMMAND ${commands} - ) - add_dependencies(${arg_NAME} ${arg_NAME}.Install) - endif () - - if (DEFINED arg_INCLUDE) - exp_expand_3rd_path_expression( - INPUT ${arg_INCLUDE} - OUTPUT r_include - SOURCE_DIR ${arg_SOURCE_DIR} - INSTALL_DIR ${arg_INSTALL_DIR} - ) - exp_get_3rd_platform_value( - OUTPUT p_include - INPUT ${r_include} - ) - target_include_directories( - ${arg_NAME} - INTERFACE ${p_include} - ) - endif () -endfunction() - -function(exp_add_3rd_binary_package) - set(options "") - set(singleValueArgs NAME SOURCE_DIR) - set(multiValueArgs INCLUDE LINK LIB RUNTIME_DEP) - cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - - add_library(${arg_NAME} INTERFACE) - - if (DEFINED arg_INCLUDE) - exp_expand_3rd_path_expression( - INPUT ${arg_INCLUDE} - OUTPUT r_include - SOURCE_DIR ${arg_SOURCE_DIR} - ) - exp_get_3rd_platform_value( - INPUT ${r_include} - OUTPUT p_include - ) - target_include_directories( - ${arg_NAME} - INTERFACE ${p_include} - ) - endif() - - if (DEFINED arg_LINK) - exp_expand_3rd_path_expression( - INPUT ${arg_LINK} - OUTPUT r_link - SOURCE_DIR ${arg_SOURCE_DIR} - ) - exp_get_3rd_platform_value( - INPUT ${r_link} - OUTPUT p_link - ) - target_link_directories( - ${arg_NAME} - INTERFACE ${p_link} - ) - endif() - - if (DEFINED arg_LIB) - exp_expand_3rd_path_expression( - INPUT ${arg_LIB} - OUTPUT r_lib - SOURCE_DIR ${arg_SOURCE_DIR} - ) - exp_get_3rd_platform_value( - OUTPUT p_lib - INPUT ${r_lib} - ) - target_link_libraries( - ${arg_NAME} - INTERFACE "${p_lib}" - ) - endif() - - if (DEFINED arg_RUNTIME_DEP) - exp_expand_3rd_path_expression( - INPUT ${arg_RUNTIME_DEP} - OUTPUT r_runtime_dep - SOURCE_DIR ${arg_SOURCE_DIR} - ) - exp_get_3rd_platform_value( - INPUT ${r_runtime_dep} - OUTPUT p_runtime_dep - ) - set_target_properties( - ${arg_NAME} PROPERTIES - RUNTIME_DEP "${p_runtime_dep}" - ) - endif() -endfunction() - -function(exp_add_3rd_cmake_package) - set(options "") - set(singleValueArgs NAME SOURCE_DIR BINARY_DIR INSTALL_DIR) - set(multiValueArgs CMAKE_ARG INCLUDE LINK LIB RUNTIME_DEP) - cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - - if (NOT ${generator_is_multi_config}) - set(build_type_args -DCMAKE_BUILD_TYPE=Release) - endif () - - ExternalProject_Add( - ${arg_NAME}.External - SOURCE_DIR ${arg_SOURCE_DIR} - BINARY_DIR ${arg_BINARY_DIR} - CMAKE_ARGS ${build_type_args} -DCMAKE_INSTALL_PREFIX=${arg_INSTALL_DIR} ${arg_CMAKE_ARG} - BUILD_COMMAND ${CMAKE_COMMAND} --build --config Release -j 16 - INSTALL_COMMAND ${CMAKE_COMMAND} --install --config Release - ) - add_library(${arg_NAME} INTERFACE) - add_dependencies(${arg_NAME} ${arg_NAME}.External) - - if (DEFINED arg_INCLUDE) - exp_expand_3rd_path_expression( - INPUT ${arg_INCLUDE} - OUTPUT r_include - SOURCE_DIR ${arg_SOURCE_DIR} - BINARY_DIR ${arg_BINARY_DIR} - INSTALL_DIR ${arg_INSTALL_DIR} - ) - exp_get_3rd_platform_value( - INPUT ${r_include} - OUTPUT p_include - ) - target_include_directories( - ${arg_NAME} - INTERFACE ${p_include} - ) - endif() - - if (DEFINED arg_LINK) - exp_expand_3rd_path_expression( - INPUT ${arg_LINK} - OUTPUT r_link - SOURCE_DIR ${arg_SOURCE_DIR} - BINARY_DIR ${arg_BINARY_DIR} - INSTALL_DIR ${arg_INSTALL_DIR} - ) - exp_get_3rd_platform_value( - INPUT ${r_link} - OUTPUT p_link - ) - target_link_directories( - ${arg_NAME} - INTERFACE ${p_link} - ) - endif() - - if (DEFINED arg_LIB) - exp_expand_3rd_path_expression( - INPUT ${arg_LIB} - OUTPUT r_lib - SOURCE_DIR ${arg_SOURCE_DIR} - BINARY_DIR ${arg_BINARY_DIR} - INSTALL_DIR ${arg_INSTALL_DIR} - ) - exp_get_3rd_platform_value( - INPUT ${r_lib} - OUTPUT p_lib - ) - target_link_libraries( - ${arg_NAME} - INTERFACE "${p_lib}" - ) - endif() - - if (DEFINED arg_RUNTIME_DEP) - exp_expand_3rd_path_expression( - INPUT ${arg_RUNTIME_DEP} - OUTPUT r_runtime_dep - SOURCE_DIR ${arg_SOURCE_DIR} - BINARY_DIR ${arg_BINARY_DIR} - INSTALL_DIR ${arg_INSTALL_DIR} - ) - exp_get_3rd_platform_value( - INPUT ${r_runtime_dep} - OUTPUT p_runtime_dep - ) - set_target_properties( - ${arg_NAME} PROPERTIES - RUNTIME_DEP "${p_runtime_dep}" - ) - endif() -endfunction() - -function(exp_add_3rd_alias_package) - set(options "") - set(singleValueArgs NAME) - set(multiValueArgs LIB) - cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - - add_library(${arg_NAME} INTERFACE) - target_link_libraries( - ${arg_NAME} - INTERFACE "${arg_LIB}" - ) -endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f9bf25a..c4f71657 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,6 @@ add_definitions(-DBUILD_EDITOR=$) include(CMake/Common.cmake) include(CMake/Target.cmake) -include(CMake/ThirdParty.cmake) add_subdirectory(ThirdParty) add_subdirectory(Engine) diff --git a/Editor/CMakeLists.txt b/Editor/CMakeLists.txt index 3b21b62a..a1e5ec33 100644 --- a/Editor/CMakeLists.txt +++ b/Editor/CMakeLists.txt @@ -60,6 +60,7 @@ add_dependencies(Editor ${EDITOR_MIRROR_GENERATED_TARGET} ${RHI_DEP_TARGETS}) exp_process_runtime_dependencies( NAME Editor + DEP_TARGET ${RHI_DEP_TARGETS} ) install( TARGETS Editor @@ -95,6 +96,7 @@ endif () if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") foreach (rhi_dep_target ${RHI_DEP_TARGETS}) list(APPEND rhi_dep_target_copy_commands COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $/../Frameworks/$) + # TODO also copy runtime dep of runtime dep endforeach () add_custom_command( diff --git a/Engine/Source/Common/Include/Common/Platform.h b/Engine/Source/Common/Include/Common/Platform.h index 541d3fdd..110b73e3 100644 --- a/Engine/Source/Common/Include/Common/Platform.h +++ b/Engine/Source/Common/Include/Common/Platform.h @@ -4,6 +4,8 @@ #pragma once +#include + namespace Common { enum class DevelopmentPlatform { windows, @@ -29,4 +31,9 @@ namespace Common { x64, max }; + + class PlatformUtils { + public: + static void SetEnvVar(const std::string& inKey, const std::string& inValue); + }; } diff --git a/Engine/Source/Common/Src/Platform.cpp b/Engine/Source/Common/Src/Platform.cpp new file mode 100644 index 00000000..c44764f1 --- /dev/null +++ b/Engine/Source/Common/Src/Platform.cpp @@ -0,0 +1,21 @@ +// +// Created by johnk on 2025/12/21. +// + +#if PLATFORM_WINDOWS +#include +#endif + +#include +#include + +namespace Common { + void PlatformUtils::SetEnvVar(const std::string& inKey, const std::string& inValue) + { +#if PLATFORM_WINDOWS + Assert(SetEnvironmentVariableA(inKey.c_str(), inValue.c_str())); +#else + Unimplement(); +#endif + } +} diff --git a/Engine/Source/RHI-Vulkan/CMakeLists.txt b/Engine/Source/RHI-Vulkan/CMakeLists.txt index aa198485..9f3f8190 100644 --- a/Engine/Source/RHI-Vulkan/CMakeLists.txt +++ b/Engine/Source/RHI-Vulkan/CMakeLists.txt @@ -16,7 +16,7 @@ exp_add_library( SRC ${sources} ${platform_sources} PUBLIC_INC Include PUBLIC_LIB RHI ${platform_ext_libs} - PUBLIC_MERGE_LIB VulkanSDK spirv-cross GPUOpen::VulkanMemoryAllocator + PUBLIC_MERGE_LIB Vulkan::Headers Vulkan::Loader vulkan-validationlayers::vulkan-validationlayers spirv-cross::spirv-cross GPUOpen::VulkanMemoryAllocator ) # .mm files can not perform unity build with .cpp files diff --git a/Engine/Source/RHI-Vulkan/Src/Instance.cpp b/Engine/Source/RHI-Vulkan/Src/Instance.cpp index c19574d3..335c7951 100644 --- a/Engine/Source/RHI-Vulkan/Src/Instance.cpp +++ b/Engine/Source/RHI-Vulkan/Src/Instance.cpp @@ -6,8 +6,11 @@ #include #include -#include + +#include "Common/Platform.h" + #include +#include namespace RHI::Vulkan { static std::vector requiredLayerNames = { @@ -84,6 +87,12 @@ namespace RHI::Vulkan { #if BUILD_CONFIG_DEBUG void VulkanInstance::PrepareLayers() { +#if PLATFORM_WINDOWS + Common::PlatformUtils::SetEnvVar("VK_LAYER_PATH", "VkLayer_khronos_validation.json"); +#else + // TODO +#endif + uint32_t supportedLayerCount = 0; vkEnumerateInstanceLayerProperties(&supportedLayerCount, nullptr); std::vector supportedLayers(supportedLayerCount); diff --git a/Engine/Source/Render/CMakeLists.txt b/Engine/Source/Render/CMakeLists.txt index 5a2d70c5..f391457a 100644 --- a/Engine/Source/Render/CMakeLists.txt +++ b/Engine/Source/Render/CMakeLists.txt @@ -1,7 +1,3 @@ -if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") - set(platform_libs VulkanSDK) -endif() - file(GLOB sources Src/*.cpp) exp_add_library( NAME Render.Static @@ -9,7 +5,7 @@ exp_add_library( SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Core RHI - PUBLIC_MERGE_LIB dxc::dxc spirv-cross ${platform_libs} + PUBLIC_MERGE_LIB dxc::dxc spirv-cross::spirv-cross ) file(GLOB shader_sources SharedSrc/*.cpp) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index b42c4f02..fa55a795 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -1,112 +1,3 @@ -set(3RD_REPO "http://1.13.181.171" CACHE STRING "" FORCE) -set(3RD_DIR ${CMAKE_SOURCE_DIR}/ThirdParty CACHE PATH "" FORCE) -set(3RD_ZIP_DIR ${3RD_DIR}/Zip CACHE PATH "" FORCE) -set(3RD_SOURCE_DIR ${3RD_DIR}/Lib CACHE PATH "" FORCE) -set(3RD_BINARY_DIR ${CMAKE_BINARY_DIR}/ThirdPartyBuild CACHE PATH "" FORCE) -set(3RD_INSTALL_DIR ${CMAKE_BINARY_DIR}/ThirdPartyInstall CACHE PATH "" FORCE) - -function(download_and_setup_3rd_package) - set(options "") - set(singleValueArgs NAME) - set(multiValueArgs PLATFORM VERSION HASH) - cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - - exp_get_3rd_platform_value( - OUTPUT version_value - INPUT ${arg_VERSION} - ) - - set(cur_platform All ${CMAKE_SYSTEM_NAME}) - foreach (platform ${cur_platform}) - if (${platform} IN_LIST arg_PLATFORM) - set(full_name "${arg_NAME}-${platform}-${version_value}") - endif () - endforeach () - - if (NOT DEFINED full_name) - set(${arg_NAME}_READY FALSE PARENT_SCOPE) - return() - endif () - - set(source_dir ${3RD_SOURCE_DIR}/${full_name}) - exp_download_and_extract_3rd_package( - URL ${3RD_REPO}/${full_name}.7z - SAVE_AS ${3RD_ZIP_DIR}/${full_name}.7z - EXTRACT_TO ${source_dir} - HASH ${arg_HASH} - ) - set(${arg_NAME}_READY TRUE PARENT_SCOPE) - set(${arg_NAME}_SOURCE_DIR ${source_dir} PARENT_SCOPE) - set(${arg_NAME}_BINARY_DIR ${3RD_BINARY_DIR}/${arg_NAME} PARENT_SCOPE) - set(${arg_NAME}_INSTALL_DIR ${3RD_INSTALL_DIR}/${arg_NAME}/$ PARENT_SCOPE) -endfunction() - -function(should_setup_3rd_package) - set(options "") - set(singleValueArgs NAME) - set(multiValueArgs PLATFORM) - cmake_parse_arguments(arg "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN}) - - set(cur_platform All ${CMAKE_SYSTEM_NAME}) - foreach (platform ${cur_platform}) - if (${platform} IN_LIST arg_PLATFORM) - set(${arg_NAME}_READY TRUE PARENT_SCOPE) - return() - endif () - endforeach () - - set(${arg_NAME}_READY FALSE PARENT_SCOPE) -endfunction() - -# VulkanSDK -set(VULKAN_SDK_VERSION 1.3.296.0) -download_and_setup_3rd_package( - NAME VulkanSDK - PLATFORM Windows Darwin - VERSION ${VULKAN_SDK_VERSION} - HASH - Windows 27b8344a5b1333222d55c9c107914dba1cc9beb788b207e087c27dc7b8762816 - Darwin a792aaad3937a694a4cb853d2fbb3fa7025ba3754bedd52799e687a4c254129c -) -if (${VulkanSDK_READY}) - exp_add_3rd_binary_package( - NAME VulkanSDK - SOURCE_DIR ${VulkanSDK_SOURCE_DIR} - INCLUDE - Windows $/Include - Darwin $/macOS/include - LINK - Windows $/Lib - Darwin $/macOS/lib - LIB - Windows vulkan-1 - Darwin vulkan.1 - ) -endif () - -# spirv-cross -download_and_setup_3rd_package( - NAME spirv-cross - PLATFORM All - VERSION 1.3.243.0 - HASH 2b09e3cf9357156e8a4f1bd7cde3771184f652ec3b632993495748112a7f4665 -) -if (${spirv-cross_READY}) - exp_add_3rd_cmake_package( - NAME spirv-cross - SOURCE_DIR ${spirv-cross_SOURCE_DIR} - BINARY_DIR ${spirv-cross_BINARY_DIR} - INSTALL_DIR ${spirv-cross_INSTALL_DIR} - CMAKE_ARG -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DSPIRV_CROSS_CLI=OFF -DSPIRV_CROSS_ENABLE_C_API=OFF -DSPIRV_CROSS_ENABLE_TESTS=OFF - INCLUDE $/include - LINK $/lib - LIB spirv-cross-core - spirv-cross-msl - spirv-cross-glsl - ) -endif () - -# conan managed if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") add_library(OpenGLDummy INTERFACE) add_library(opengl::opengl ALIAS OpenGLDummy) @@ -125,10 +16,18 @@ find_package(debugbreak REQUIRED GLOBAL) find_package(rapidjson REQUIRED GLOBAL) find_package(clipp REQUIRED GLOBAL) find_package(dxc REQUIRED GLOBAL) +find_package(VulkanHeaders REQUIRED GLOBAL) +find_package(VulkanLoader REQUIRED GLOBAL) +find_package(VulkanValidationLayers REQUIRED GLOBAL) +find_package(spirv-cross REQUIRED GLOBAL) if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") find_package(DirectX-Headers REQUIRED GLOBAL) set_target_properties(assimp::assimp PROPERTIES RUNTIME_DEP "${assimp_INCLUDE_DIR}/../bin/assimp-vc${MSVC_TOOLSET_VERSION}-mt.dll") set_target_properties(libclang::libclang PROPERTIES RUNTIME_DEP "${libclang_INCLUDE_DIR}/../bin/libclang.dll") set_target_properties(dxc::dxc PROPERTIES RUNTIME_DEP "${dxc_INCLUDE_DIR}/../bin/dxil.dll;${dxc_INCLUDE_DIR}/../bin/dxcompiler.dll") + set_target_properties(vulkan-validationlayers::vulkan-validationlayers PROPERTIES RUNTIME_DEP "${VulkanValidationLayers_INCLUDE_DIR}/../bin/VkLayer_khronos_validation.dll;${VulkanValidationLayers_INCLUDE_DIR}/../bin/VkLayer_khronos_validation.json") endif () + +# TODO macos vulkan validation layers runtime dep +# TODO molten vk diff --git a/ThirdParty/Patch/Qt-Darwin-6.9.1-FindWrapOpenGL.cmake b/ThirdParty/Patch/Qt-Darwin-6.9.1-FindWrapOpenGL.cmake deleted file mode 100644 index fe73ab78..00000000 --- a/ThirdParty/Patch/Qt-Darwin-6.9.1-FindWrapOpenGL.cmake +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -# We can't create the same interface imported target multiple times, CMake will complain if we do -# that. This can happen if the find_package call is done in multiple different subdirectories. -if(TARGET WrapOpenGL::WrapOpenGL) - set(WrapOpenGL_FOUND ON) - return() -endif() - -set(WrapOpenGL_FOUND OFF) - -find_package(OpenGL ${WrapOpenGL_FIND_VERSION}) - -if (OpenGL_FOUND) - set(WrapOpenGL_FOUND ON) - - add_library(WrapOpenGL::WrapOpenGL INTERFACE IMPORTED) - if(APPLE) - # CMake 3.27 and older: - # On Darwin platforms FindOpenGL sets IMPORTED_LOCATION to the absolute path of the library - # within the framework. This ends up as an absolute path link flag, which we don't want, - # because that makes our .prl files un-relocatable. - # Extract the framework path instead, and use that in INTERFACE_LINK_LIBRARIES, - # which CMake ends up transforming into a relocatable -framework flag. - # See https://gitlab.kitware.com/cmake/cmake/-/issues/20871 for details. - # - # CMake 3.28 and above: - # IMPORTED_LOCATION is the absolute path the the OpenGL.framework folder. - get_target_property(__opengl_fw_lib_path OpenGL::GL IMPORTED_LOCATION) - if(__opengl_fw_lib_path AND NOT __opengl_fw_lib_path MATCHES "/([^/]+)\\.framework$") - get_filename_component(__opengl_fw_path "${__opengl_fw_lib_path}" DIRECTORY) - endif() - - if(NOT __opengl_fw_path) - # Just a safety measure in case if no OpenGL::GL target exists. - set(__opengl_fw_path "-framework OpenGL") - endif() - - target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE ${__opengl_fw_path}) - else() - target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE OpenGL::GL) - endif() -elseif(UNIX AND NOT APPLE AND NOT CMAKE_SYSTEM_NAME STREQUAL "Integrity") - # Requesting only the OpenGL component ensures CMake does not mark the package as - # not found if neither GLX nor libGL are available. This allows finding OpenGL - # on an X11-less Linux system. - find_package(OpenGL ${WrapOpenGL_FIND_VERSION} COMPONENTS OpenGL) - if (OpenGL_FOUND) - set(WrapOpenGL_FOUND ON) - add_library(WrapOpenGL::WrapOpenGL INTERFACE IMPORTED) - target_link_libraries(WrapOpenGL::WrapOpenGL INTERFACE OpenGL::OpenGL) - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(WrapOpenGL DEFAULT_MSG WrapOpenGL_FOUND) diff --git a/conanfile.py b/conanfile.py index 5b79ab0b..f95f4dac 100644 --- a/conanfile.py +++ b/conanfile.py @@ -11,7 +11,10 @@ def requirements(self): self.requires("cityhash/1.0.1") self.requires("gtest/1.17.0") self.requires("taskflow/3.10.0") + self.requires("vulkan-headers/1.4.313.0") + self.requires("vulkan-loader/1.4.313.0") self.requires("vulkan-memory-allocator/3.3.0") + self.requires("spirv-cross/1.4.313.0") if self.settings.os == "Windows": self.requires("directx-headers/1.610.2") @@ -24,3 +27,6 @@ def requirements(self): self.requires("assimp/6.0.2-exp") self.requires("clipp/1.2.3-exp") self.requires("dxc/1.8.2505.1-exp") + self.requires("vulkan-validationlayers/1.4.313.0-exp") + + # TODO molten-vk From b4bb8795c6a0f5e14383f58645361eac4203c0f8 Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Mon, 22 Dec 2025 22:00:03 +0800 Subject: [PATCH 39/44] fix: module load issue --- Engine/Source/Core/Src/Module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/Source/Core/Src/Module.cpp b/Engine/Source/Core/Src/Module.cpp index c8105c31..24ff9ec1 100644 --- a/Engine/Source/Core/Src/Module.cpp +++ b/Engine/Source/Core/Src/Module.cpp @@ -148,7 +148,7 @@ namespace Core { for (const auto& searchPath : searchPaths) { std::optional result = std::nullopt; - (void) searchPath.TraverseRecurse([&](const Common::Path& path) -> bool { + (void) searchPath.Traverse([&](const Common::Path& path) -> bool { if (path.IsDirectory()) { return true; } From dfbb0117099969e2509467c4211ebb0677e4fa75 Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Mon, 22 Dec 2025 22:02:16 +0800 Subject: [PATCH 40/44] feat: posix set env func --- Engine/Source/Common/Src/Platform.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Engine/Source/Common/Src/Platform.cpp b/Engine/Source/Common/Src/Platform.cpp index c44764f1..2add1eaf 100644 --- a/Engine/Source/Common/Src/Platform.cpp +++ b/Engine/Source/Common/Src/Platform.cpp @@ -4,6 +4,8 @@ #if PLATFORM_WINDOWS #include +#else +#include #endif #include @@ -15,7 +17,7 @@ namespace Common { #if PLATFORM_WINDOWS Assert(SetEnvironmentVariableA(inKey.c_str(), inValue.c_str())); #else - Unimplement(); + setenv(inKey.c_str(), inValue.c_str(), 1); #endif } } From aa5da984b364afdcec29fbab8cf3f21306336c57 Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Mon, 22 Dec 2025 22:11:51 +0800 Subject: [PATCH 41/44] feat: auto copy validation layers and load in runtime --- Engine/Source/RHI-Vulkan/Src/Instance.cpp | 4 ---- ThirdParty/CMakeLists.txt | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Engine/Source/RHI-Vulkan/Src/Instance.cpp b/Engine/Source/RHI-Vulkan/Src/Instance.cpp index 335c7951..672bc8f2 100644 --- a/Engine/Source/RHI-Vulkan/Src/Instance.cpp +++ b/Engine/Source/RHI-Vulkan/Src/Instance.cpp @@ -87,11 +87,7 @@ namespace RHI::Vulkan { #if BUILD_CONFIG_DEBUG void VulkanInstance::PrepareLayers() { -#if PLATFORM_WINDOWS Common::PlatformUtils::SetEnvVar("VK_LAYER_PATH", "VkLayer_khronos_validation.json"); -#else - // TODO -#endif uint32_t supportedLayerCount = 0; vkEnumerateInstanceLayerProperties(&supportedLayerCount, nullptr); diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index fa55a795..d1d3410b 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -27,6 +27,8 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set_target_properties(libclang::libclang PROPERTIES RUNTIME_DEP "${libclang_INCLUDE_DIR}/../bin/libclang.dll") set_target_properties(dxc::dxc PROPERTIES RUNTIME_DEP "${dxc_INCLUDE_DIR}/../bin/dxil.dll;${dxc_INCLUDE_DIR}/../bin/dxcompiler.dll") set_target_properties(vulkan-validationlayers::vulkan-validationlayers PROPERTIES RUNTIME_DEP "${VulkanValidationLayers_INCLUDE_DIR}/../bin/VkLayer_khronos_validation.dll;${VulkanValidationLayers_INCLUDE_DIR}/../bin/VkLayer_khronos_validation.json") +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set_target_properties(vulkan-validationlayers::vulkan-validationlayers PROPERTIES RUNTIME_DEP "${VulkanValidationLayers_INCLUDE_DIR}/../lib/libVkLayer_khronos_validation.dylib;${VulkanValidationLayers_INCLUDE_DIR}/../share/vulkan/explicit_layer.d/VkLayer_khronos_validation.json") endif () # TODO macos vulkan validation layers runtime dep From 66f88c71924112a66511e972bcbca9b4bb28a715 Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Mon, 22 Dec 2025 22:26:22 +0800 Subject: [PATCH 42/44] feat: add molten-vk conan dependency --- Engine/Source/RHI-Vulkan/CMakeLists.txt | 5 +- Engine/Source/RHI-Vulkan/Src/Instance.cpp | 4 + Sample/CMakeLists.txt | 1 + ThirdParty/CMakeLists.txt | 5 +- .../ConanRecipes/molten-vk/conandata.yml | 3 + .../ConanRecipes/molten-vk/conanfile.py | 88 +++++++++++++++++++ .../molten-vk/test_package/CMakeLists.txt | 12 +++ .../molten-vk/test_package/conanfile.py | 25 ++++++ .../molten-vk/test_package/test_package.cpp | 4 + conanfile.py | 5 +- 10 files changed, 142 insertions(+), 10 deletions(-) create mode 100644 ThirdParty/ConanRecipes/molten-vk/conandata.yml create mode 100644 ThirdParty/ConanRecipes/molten-vk/conanfile.py create mode 100644 ThirdParty/ConanRecipes/molten-vk/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/molten-vk/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/molten-vk/test_package/test_package.cpp diff --git a/Engine/Source/RHI-Vulkan/CMakeLists.txt b/Engine/Source/RHI-Vulkan/CMakeLists.txt index 9f3f8190..bad54060 100644 --- a/Engine/Source/RHI-Vulkan/CMakeLists.txt +++ b/Engine/Source/RHI-Vulkan/CMakeLists.txt @@ -4,10 +4,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(platform_sources Src/Platform/Win32Surface.cpp) elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") set(platform_sources Src/Platform/MacosSurface.mm) - set(platform_ext_libs - "-framework Cocoa" - "-framework IOKit" - "-framework CoreFoundation") + set(platform_ext_libs molten-vk::molten-vk "-framework Cocoa" "-framework IOKit" "-framework CoreFoundation") endif() exp_add_library( diff --git a/Engine/Source/RHI-Vulkan/Src/Instance.cpp b/Engine/Source/RHI-Vulkan/Src/Instance.cpp index 672bc8f2..803d12e3 100644 --- a/Engine/Source/RHI-Vulkan/Src/Instance.cpp +++ b/Engine/Source/RHI-Vulkan/Src/Instance.cpp @@ -60,6 +60,10 @@ namespace RHI::Vulkan { VulkanInstance::VulkanInstance() { +#if PLATFORM_MACOS + Common::PlatformUtils::SetEnvVar("VK_DRIVER_FILES", "MoltenVK_icd.json"); +#endif + #if BUILD_CONFIG_DEBUG PrepareLayers(); #endif diff --git a/Sample/CMakeLists.txt b/Sample/CMakeLists.txt index 7603dbea..476fe147 100644 --- a/Sample/CMakeLists.txt +++ b/Sample/CMakeLists.txt @@ -37,6 +37,7 @@ function(add_sample) RES ${paths} NOT_INSTALL ) + add_dependencies(${arg_NAME} ${platform_dep_target}) endfunction() if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index d1d3410b..c8ee8433 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -28,8 +28,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set_target_properties(dxc::dxc PROPERTIES RUNTIME_DEP "${dxc_INCLUDE_DIR}/../bin/dxil.dll;${dxc_INCLUDE_DIR}/../bin/dxcompiler.dll") set_target_properties(vulkan-validationlayers::vulkan-validationlayers PROPERTIES RUNTIME_DEP "${VulkanValidationLayers_INCLUDE_DIR}/../bin/VkLayer_khronos_validation.dll;${VulkanValidationLayers_INCLUDE_DIR}/../bin/VkLayer_khronos_validation.json") elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + find_package(MoltenVK REQUIRED GLOBAL) set_target_properties(vulkan-validationlayers::vulkan-validationlayers PROPERTIES RUNTIME_DEP "${VulkanValidationLayers_INCLUDE_DIR}/../lib/libVkLayer_khronos_validation.dylib;${VulkanValidationLayers_INCLUDE_DIR}/../share/vulkan/explicit_layer.d/VkLayer_khronos_validation.json") + set_target_properties(molten-vk::molten-vk PROPERTIES RUNTIME_DEP "${MoltenVK_INCLUDE_DIR}/../lib/libMoltenVK.dylib;${MoltenVK_INCLUDE_DIR}/../lib/MoltenVK_icd.json") endif () - -# TODO macos vulkan validation layers runtime dep -# TODO molten vk diff --git a/ThirdParty/ConanRecipes/molten-vk/conandata.yml b/ThirdParty/ConanRecipes/molten-vk/conandata.yml new file mode 100644 index 00000000..fc149926 --- /dev/null +++ b/ThirdParty/ConanRecipes/molten-vk/conandata.yml @@ -0,0 +1,3 @@ +sources: + "1.4.1-exp": + commit: "db445ff2042d9ce348c439ad8451112f354b8d2a" diff --git a/ThirdParty/ConanRecipes/molten-vk/conanfile.py b/ThirdParty/ConanRecipes/molten-vk/conanfile.py new file mode 100644 index 00000000..88c28aeb --- /dev/null +++ b/ThirdParty/ConanRecipes/molten-vk/conanfile.py @@ -0,0 +1,88 @@ +import re + +from conan import ConanFile +from conan.tools.build import check_min_cppstd, can_run +from conan.tools.cmake import cmake_layout, CMakeToolchain, CMakeDeps, CMake +from conan.tools.files import apply_conandata_patches, copy +from conan.tools.scm import Git +import os +import shutil + +required_conan_version = ">=2.0.9" + +class MoltenVKConan(ConanFile): + name = "molten-vk" + description = "molten vk (vulkan driver on macos)" + license = "https://github.com/KhronosGroup/MoltenVK?tab=Apache-2.0-1-ov-file" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/KhronosGroup/MoltenVK" + topics = ("vulkan", "driver", "macos") + package_type = "shared-library" + settings = "os", "arch", "compiler", "build_type" + options = {} + default_options = {} + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + check_min_cppstd(self, 17) + + def build_requirements(self): + self.tool_requires("ninja/[>=1.12]") + self.tool_requires("cmake/[>=3.16]") + + def source(self): + git = Git(self) + git.clone("https://github.com/KhronosGroup/MoltenVK", target=".") + git.checkout(self.conan_data["sources"][self.version]["commit"]) + apply_conandata_patches(self) + + def generate(self): + cmake_toolchain = CMakeToolchain(self, generator="Ninja") + cmake_toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + install_folder = os.path.join(self.build_folder, "installed") + cmake.configure(cli_args=[f"-DCMAKE_INSTALL_PREFIX={install_folder}"]) + cmake.build() + cmake.install(cli_args=["--prefix", install_folder]) + + lib_root = os.path.join(install_folder, "lib") + for entry in os.listdir(lib_root): + entry_path = os.path.join(lib_root, entry) + if os.path.isdir(entry_path): + shutil.rmtree(entry_path) + elif os.path.islink(entry_path): + os.remove(entry_path) + elif entry.startswith("libMoltenVK"): + os.rename(entry_path, os.path.join(lib_root, "libMoltenVK.dylib")) + + icd_descriptor_json = os.path.join(install_folder, "etc", "vulkan", "icd.d", "MoltenVK_icd.json") + new_icd_descriptor_json = os.path.join(install_folder, "lib", "MoltenVK_icd.json") + with open(icd_descriptor_json, "r") as file: + content = file.read() + new_content = re.sub(r"\"library_path\": \".+\"", "\"library_path\": \"libMoltenVK.dylib\"", content) + with open(new_icd_descriptor_json, "w") as file: + file.write(new_content) + + def package(self): + install_folder = os.path.join(self.build_folder, "installed") + copy(self, "*", install_folder, self.package_folder) + os.mkdir(os.path.join(self.package_folder, "include")) + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "MoltenVK") + self.cpp_info.bindirs = ["bin"] + self.cpp_info.includedirs = ["include"] + self.cpp_info.libs = [] + self.cpp_info.libdirs = [] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/molten-vk/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/molten-vk/test_package/CMakeLists.txt new file mode 100644 index 00000000..5b686501 --- /dev/null +++ b/ThirdParty/ConanRecipes/molten-vk/test_package/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(MoltenVK REQUIRED) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE molten-vk::molten-vk) +add_custom_command( + TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MoltenVK_INCLUDE_DIR}/../lib/libMoltenVK.dylib $/libMoltenVK.dylib + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${MoltenVK_INCLUDE_DIR}/../lib/MoltenVK_icd.json $/MoltenVK_icd.json +) diff --git a/ThirdParty/ConanRecipes/molten-vk/test_package/conanfile.py b/ThirdParty/ConanRecipes/molten-vk/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/molten-vk/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/molten-vk/test_package/test_package.cpp b/ThirdParty/ConanRecipes/molten-vk/test_package/test_package.cpp new file mode 100644 index 00000000..489dfc72 --- /dev/null +++ b/ThirdParty/ConanRecipes/molten-vk/test_package/test_package.cpp @@ -0,0 +1,4 @@ +int main(int argc, char* argv[]) +{ + return 0; +} diff --git a/conanfile.py b/conanfile.py index f95f4dac..93b1c95c 100644 --- a/conanfile.py +++ b/conanfile.py @@ -15,7 +15,6 @@ def requirements(self): self.requires("vulkan-loader/1.4.313.0") self.requires("vulkan-memory-allocator/3.3.0") self.requires("spirv-cross/1.4.313.0") - if self.settings.os == "Windows": self.requires("directx-headers/1.610.2") @@ -28,5 +27,5 @@ def requirements(self): self.requires("clipp/1.2.3-exp") self.requires("dxc/1.8.2505.1-exp") self.requires("vulkan-validationlayers/1.4.313.0-exp") - - # TODO molten-vk + if self.settings.os == "Macos": + self.requires("molten-vk/1.4.1-exp") From a5bf5e751a0829d1b6751a46946c9866b7dee79f Mon Sep 17 00:00:00 2001 From: FlyAntNotDown <461425614@qq.com> Date: Tue, 23 Dec 2025 22:37:04 +0800 Subject: [PATCH 43/44] feat: update github actions script for new conan 3rd dependencies workflow --- .github/workflows/build.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78c14524..caddafe9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ on: env: BUILD_TYPE: Release MAKE_THREAD_NUM: 16 - CMAKE_VERSION: '3.28.1' + CMAKE_VERSION: '4.1.2' jobs: build: @@ -31,9 +31,13 @@ jobs: detached: true - name: Set XCode Version - run: sudo xcode-select -s /Library/Developer/CommandLineTools + run: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer if: runner.os == 'macOS' + - name: Setup MSVC + uses: ilammy/msvc-dev-cmd@v1 + if: runner.os == 'Windows' + - name: Checkout Repo uses: actions/checkout@v4 @@ -42,19 +46,19 @@ jobs: with: node-version: 24 - - name: Setup cmake + - name: Setup CMake uses: jwlawson/actions-setup-cmake@v2 with: cmake-version: ${{env.CMAKE_VERSION}} - - name: Update Cache Files - uses: actions/cache@v4 - with: - path: ${{github.workspace}}/ThirdParty/Zip - key: ${{runner.os}}-3rd-zip + - name: Setup Conan + uses: conan-io/setup-conan@v1 + + - name: Config Conan Remote + run: conan remote add explosion https://kindem.online/artifactory/api/conan/conan - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCI=ON + run: cmake -B ${{github.workspace}}/build -G=Ninja -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCI=ON - name: Build run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} -j ${{env.MAKE_THREAD_NUM}} From f1c236bd3fe8ddb55f7a94410b36aef31924dba2 Mon Sep 17 00:00:00 2001 From: kindem Date: Wed, 24 Dec 2025 22:02:00 +0800 Subject: [PATCH 44/44] feat: add private glfw conan dependency --- Engine/Source/Launch/CMakeLists.txt | 2 +- Sample/CMakeLists.txt | 2 +- ThirdParty/CMakeLists.txt | 2 +- ThirdParty/ConanRecipes/glfw/conandata.yml | 3 + ThirdParty/ConanRecipes/glfw/conanfile.py | 63 +++++++++++++++++++ .../glfw/test_package/CMakeLists.txt | 14 +++++ .../glfw/test_package/conanfile.py | 25 ++++++++ .../glfw/test_package/test_package.cpp | 7 +++ conanfile.py | 2 +- 9 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 ThirdParty/ConanRecipes/glfw/conandata.yml create mode 100644 ThirdParty/ConanRecipes/glfw/conanfile.py create mode 100644 ThirdParty/ConanRecipes/glfw/test_package/CMakeLists.txt create mode 100644 ThirdParty/ConanRecipes/glfw/test_package/conanfile.py create mode 100644 ThirdParty/ConanRecipes/glfw/test_package/test_package.cpp diff --git a/Engine/Source/Launch/CMakeLists.txt b/Engine/Source/Launch/CMakeLists.txt index 0ca13e99..b90dcb38 100644 --- a/Engine/Source/Launch/CMakeLists.txt +++ b/Engine/Source/Launch/CMakeLists.txt @@ -5,5 +5,5 @@ exp_add_library( SRC ${sources} PUBLIC_INC Include PUBLIC_LIB Runtime - PUBLIC_MERGE_LIB glfw + PUBLIC_MERGE_LIB glfw::glfw ) \ No newline at end of file diff --git a/Sample/CMakeLists.txt b/Sample/CMakeLists.txt index 476fe147..931784ec 100644 --- a/Sample/CMakeLists.txt +++ b/Sample/CMakeLists.txt @@ -53,7 +53,7 @@ exp_add_library( SRC ${sources} PUBLIC_INC Base PUBLIC_LIB RHI ${platform_ext_libs} Render.Static - PUBLIC_MERGE_LIB glfw clipp::clipp stb::stb assimp::assimp + PUBLIC_MERGE_LIB glfw::glfw clipp::clipp stb::stb assimp::assimp NOT_INSTALL ) diff --git a/ThirdParty/CMakeLists.txt b/ThirdParty/CMakeLists.txt index c8ee8433..8971cdfe 100644 --- a/ThirdParty/CMakeLists.txt +++ b/ThirdParty/CMakeLists.txt @@ -4,7 +4,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") endif () find_package(httplib REQUIRED GLOBAL) -find_package(glfw3 REQUIRED GLOBAL) +find_package(glfw REQUIRED GLOBAL) find_package(stb REQUIRED GLOBAL) find_package(cityhash REQUIRED GLOBAL) find_package(GTest REQUIRED GLOBAL) diff --git a/ThirdParty/ConanRecipes/glfw/conandata.yml b/ThirdParty/ConanRecipes/glfw/conandata.yml new file mode 100644 index 00000000..576fdd62 --- /dev/null +++ b/ThirdParty/ConanRecipes/glfw/conandata.yml @@ -0,0 +1,3 @@ +sources: + "3.4-exp": + commit: "7b6aead9fb88b3623e3b3725ebb42670cbe4c579" diff --git a/ThirdParty/ConanRecipes/glfw/conanfile.py b/ThirdParty/ConanRecipes/glfw/conanfile.py new file mode 100644 index 00000000..88374883 --- /dev/null +++ b/ThirdParty/ConanRecipes/glfw/conanfile.py @@ -0,0 +1,63 @@ +from conan import ConanFile +from conan.tools.build import check_min_cppstd, can_run +from conan.tools.cmake import cmake_layout, CMakeToolchain, CMakeDeps, CMake +from conan.tools.files import apply_conandata_patches +from conan.tools.scm import Git +import os + +required_conan_version = ">=2.0.9" + +class GlfwConan(ConanFile): + name = "glfw" + description = "glfw window library" + license = "https://github.com/glfw/glfw?tab=Zlib-1-ov-file" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/glfw/glfw" + topics = ("opengl", "vulkan", "window-management") + package_type = "static-library" + settings = "os", "arch", "compiler", "build_type" + options = {} + default_options = {} + + def layout(self): + cmake_layout(self, src_folder="src") + + def validate(self): + check_min_cppstd(self, 17) + + def build_requirements(self): + self.tool_requires("ninja/[>=1.12]") + self.tool_requires("cmake/[>=3.16]") + + def source(self): + git = Git(self) + git.clone("https://github.com/glfw/glfw", target=".") + git.checkout(self.conan_data["sources"][self.version]["commit"]) + apply_conandata_patches(self) + + def generate(self): + cmake_toolchain = CMakeToolchain(self, generator="Ninja") + cmake_toolchain.generate() + + deps = CMakeDeps(self) + deps.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "glfw") + self.cpp_info.includedirs = ["include"] + self.cpp_info.libs = ["glfw3"] + self.cpp_info.libdirs = ["lib"] + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/glfw/test_package/CMakeLists.txt b/ThirdParty/ConanRecipes/glfw/test_package/CMakeLists.txt new file mode 100644 index 00000000..11150a2e --- /dev/null +++ b/ThirdParty/ConanRecipes/glfw/test_package/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(glfw REQUIRED) + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(platform_ext_libs + "-framework Cocoa" + "-framework IOKit" + "-framework CoreFoundation") +endif() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE glfw::glfw ${platform_ext_libs}) diff --git a/ThirdParty/ConanRecipes/glfw/test_package/conanfile.py b/ThirdParty/ConanRecipes/glfw/test_package/conanfile.py new file mode 100644 index 00000000..2e77b424 --- /dev/null +++ b/ThirdParty/ConanRecipes/glfw/test_package/conanfile.py @@ -0,0 +1,25 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain" + + def layout(self): + cmake_layout(self) + + def requirements(self): + self.requires(self.tested_reference_str) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/ThirdParty/ConanRecipes/glfw/test_package/test_package.cpp b/ThirdParty/ConanRecipes/glfw/test_package/test_package.cpp new file mode 100644 index 00000000..56f66423 --- /dev/null +++ b/ThirdParty/ConanRecipes/glfw/test_package/test_package.cpp @@ -0,0 +1,7 @@ +#include + +int main(void) { + glfwInit(); + glfwTerminate(); + return 0; +} diff --git a/conanfile.py b/conanfile.py index 93b1c95c..457f62bb 100644 --- a/conanfile.py +++ b/conanfile.py @@ -6,7 +6,6 @@ class ExplosionConan(ConanFile): def requirements(self): self.requires("cpp-httplib/0.27.0") - self.requires("glfw/3.4") self.requires("stb/cci.20230920") self.requires("cityhash/1.0.1") self.requires("gtest/1.17.0") @@ -19,6 +18,7 @@ def requirements(self): self.requires("directx-headers/1.610.2") # private repo + self.requires("glfw/3.4-exp") self.requires("libclang/21.1.7-exp") self.requires("qt/6.10.1-exp") self.requires("debugbreak/1.0-exp")