Skip to content

Commit

Permalink
Improve cmake scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
halx99 committed Apr 29, 2024
1 parent b679238 commit 4c59349
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion cmake/Modules/AXBuildHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion cmake/Modules/AXGLSLCC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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} <None Include=\"${compiled_shader}\">\n")
file(TO_NATIVE_PATH "${compiled_shader}" compiled_shader_path)
set(app_all_shaders_json "${app_all_shaders_json} <None Include=\"${compiled_shader_path}\">\n")
# set(app_all_shaders_json "${app_all_shaders_json} <Link>Content\\axslc\\%(FileName)%(Extension)</Link>\n")
set(app_all_shaders_json "${app_all_shaders_json} <Link>${compiled_shader_target_dir}</Link>\n")
set(app_all_shaders_json "${app_all_shaders_json} <DeploymentContent Condition=\"'\$(Configuration)|\$(Platform)'=='Debug|x64'\">true</DeploymentContent>\n")
Expand Down
55 changes: 37 additions & 18 deletions tests/lua-tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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"))))
Expand All @@ -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()

Expand Down

0 comments on commit 4c59349

Please sign in to comment.