From 4c59349ac7fa8c89c42cba0f1fb22e96ea029aeb Mon Sep 17 00:00:00 2001 From: halx99 Date: Tue, 30 Apr 2024 00:43:54 +0800 Subject: [PATCH] Improve cmake scripts --- cmake/Modules/AXBuildHelpers.cmake | 2 +- cmake/Modules/AXGLSLCC.cmake | 3 +- tests/lua-tests/CMakeLists.txt | 55 ++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/cmake/Modules/AXBuildHelpers.cmake b/cmake/Modules/AXBuildHelpers.cmake index 4124ab85eb6a..51c3c376d2fb 100644 --- a/cmake/Modules/AXBuildHelpers.cmake +++ b/cmake/Modules/AXBuildHelpers.cmake @@ -118,7 +118,7 @@ function(ax_mark_multi_resources res_out) list(APPEND tmp_file_list ${opt_FILES}) foreach(cc_folder ${opt_FOLDERS}) - file(GLOB_RECURSE folder_files "${cc_folder}/*") + file(GLOB_RECURSE folder_files FOLLOW_SYMLINKS "${cc_folder}/*") list(APPEND tmp_file_list ${folder_files}) ax_mark_resources(FILES ${folder_files} BASEDIR ${cc_folder} RESOURCEBASE ${opt_RES_TO}) endforeach() diff --git a/cmake/Modules/AXGLSLCC.cmake b/cmake/Modules/AXGLSLCC.cmake index 651bbc6fe49f..f060b0864c28 100644 --- a/cmake/Modules/AXGLSLCC.cmake +++ b/cmake/Modules/AXGLSLCC.cmake @@ -226,7 +226,8 @@ function(ax_target_embed_compiled_shaders target_name rc_output) foreach(compiled_shader ${compiled_shaders}) file(RELATIVE_PATH compiled_shader_rp ${GLSLCC_OUT_DIR} ${compiled_shader}) file(TO_NATIVE_PATH "Content/axslc/${compiled_shader_rp}" compiled_shader_target_dir) - set(app_all_shaders_json "${app_all_shaders_json} \n") + file(TO_NATIVE_PATH "${compiled_shader}" compiled_shader_path) + set(app_all_shaders_json "${app_all_shaders_json} \n") # set(app_all_shaders_json "${app_all_shaders_json} Content\\axslc\\%(FileName)%(Extension)\n") set(app_all_shaders_json "${app_all_shaders_json} ${compiled_shader_target_dir}\n") set(app_all_shaders_json "${app_all_shaders_json} true\n") diff --git a/tests/lua-tests/CMakeLists.txt b/tests/lua-tests/CMakeLists.txt index 015ae2f56dae..b294117678e6 100644 --- a/tests/lua-tests/CMakeLists.txt +++ b/tests/lua-tests/CMakeLists.txt @@ -1,3 +1,28 @@ +#/**************************************************************************** +# Copyright (c) 2013-2014 cocos2d-x.org +# Copyright (c) 2019-present Axmol Engine contributors (see AUTHORS.md). +# +# https://axmolengine.github.io/ +# +# 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. +# ****************************************************************************/ + cmake_minimum_required(VERSION 3.10) set(APP_NAME lua-tests) @@ -31,9 +56,6 @@ if(NOT DEFINED BUILD_ENGINE_DONE) endif() endif() -_1kfetch(sample-assets) -_1klink("${sample-assets_SOURCE_DIR}/cpp-tests/Content" "${CMAKE_CURRENT_LIST_DIR}/Content/res") - # The common cross-platforms source files and header files file(GLOB_RECURSE GAME_HEADER Source/*.h @@ -46,24 +68,23 @@ set(GAME_INC_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/Source" ) +_1kfetch(sample-assets) -set(shared_content_folder "${_AX_ROOT}/tests/cpp-tests/Content") set(content_folder "${CMAKE_CURRENT_SOURCE_DIR}/Content") -set(engine_script_folder "${_AX_ROOT}/extensions/scripting/lua-bindings/script") +_1klink("${sample-assets_SOURCE_DIR}/cpp-tests/Content" "${CMAKE_CURRENT_LIST_DIR}/Content/res") +_1klink("${_AX_ROOT}/extensions/scripting/lua-bindings/script" "${CMAKE_CURRENT_LIST_DIR}/Content/src/axmol") + +set(content_folder + "${CMAKE_CURRENT_SOURCE_DIR}/Content" + ) if(APPLE) - ax_mark_multi_resources(content_files RES_TO "Resources" FOLDERS ${content_folder}) - ax_mark_multi_resources(shared_content_files RES_TO "Resources/res" FOLDERS ${shared_content_folder}) - set(common_content_files ${content_files} ${shared_content_files}) - ax_mark_multi_resources(engine_script_files RES_TO "Resources/src/axmol" FOLDERS ${engine_script_folder}) - set(common_content_files ${common_content_files} ${engine_script_files}) + ax_mark_multi_resources(common_content_files RES_TO "Resources" FOLDERS ${content_folder}) elseif(WINDOWS) - ax_mark_multi_resources(content_files RES_TO "Content" FOLDERS ${content_folder}) - set(common_content_files ${content_files}) - ax_mark_multi_resources(engine_script_files RES_TO "Content/src/axmol" FOLDERS ${engine_script_folder}) - set(common_content_files ${common_content_files} ${engine_script_files}) + ax_mark_multi_resources(common_content_files RES_TO "Content" FOLDERS ${content_folder}) endif() + if(ANDROID) # the APP_NAME should match on AndroidManifest.xml list(APPEND GAME_SOURCE @@ -86,11 +107,10 @@ elseif(WINDOWS) ) list(APPEND GAME_SOURCE proj.win32/main.cpp + ${common_content_files} ) else() ax_setup_winrt_sources() - ax_mark_multi_resources(res_files RES_TO "Content/res" FOLDERS "${_AX_ROOT}/tests/cpp-tests/Content") - list(APPEND common_content_files ${res_files}) endif() list(APPEND GAME_SOURCE ${common_content_files}) elseif(APPLE) @@ -205,7 +225,6 @@ endif() if ((NOT APPLE) AND (NOT WINRT)) ax_get_resource_path(APP_RES_DIR ${APP_NAME}) - ax_sync_lua_scripts(${APP_NAME} ${engine_script_folder} "${content_folder}/src/axmol") ax_sync_target_res(${APP_NAME} LINK_TO ${APP_RES_DIR} FOLDERS ${content_folder} SYM_LINK 1) if((WINDOWS AND (NOT (CMAKE_GENERATOR MATCHES "Ninja")))) @@ -223,7 +242,7 @@ endif() if (_AX_USE_PREBUILT) # support windows and linux use_ax_compile_define(${APP_NAME}) - include(${_AX_ROOT}/cmake/AXLinkHelpers.cmake) + include(AXLinkHelpers) ax_link_lua_prebuilt(${APP_NAME} ${_AX_ROOT} ${AX_PREBUILT_DIR}) endif()