Skip to content

Commit

Permalink
Pre-built CMake configuration fixes (axmolengine#2058)
Browse files Browse the repository at this point in the history
  • Loading branch information
IamSanjid authored Jul 28, 2024
1 parent 4de7e28 commit 1553121
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
17 changes: 11 additions & 6 deletions cmake/Modules/AXBuildHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ function(ax_sync_target_res ax_target)
set(oneValueArgs LINK_TO SYNC_TARGET_ID)
set(multiValueArgs FOLDERS)
cmake_parse_arguments(opt "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (NOT DEFINED opt_SYNC_TARGET_ID)
set(sync_target_name "SYNC_RESOURCE-${ax_target}")
else()
set(sync_target_name "SYNC_RESOURCE-${ax_target}-${opt_SYNC_TARGET_ID}")
endif()

ax_def_sync_resource_target(${ax_target} ${sync_target_name})

if(NOT TARGET ${sync_target_name})
message(WARNING "SyncResource targe for ${ax_target} is not defined")
return()
Expand Down Expand Up @@ -291,7 +291,7 @@ function(ax_mark_resources)
# MakeAppx.exe require deployment location path rule
# - must full quailfied windows style path
# - can't start with .\xxx.txt, must be xxx.txt
#
#
# Otherwise, will fail with:
# MakeAppx : error : 0x8007007b - The filename, directory name, or volume label syntax is incorrect.
if (opt_RESOURCEBASE STREQUAL ".")
Expand Down Expand Up @@ -439,7 +439,7 @@ function(ax_setup_app_config app_name)
# windows: visual studio/LLVM-clang default is Console app, but we need Windows app
set(_win32_linker_flags "")
set(_win32_console_app FALSE)

if (NOT opt_CONSOLE OR WINRT)
set(_win32_linker_flags "/SUBSYSTEM:WINDOWS")
else()
Expand Down Expand Up @@ -571,9 +571,14 @@ macro (ax_setup_app_props app_name)
foreach(FOLDER IN LISTS _APP_RES_FOLDER)
string(APPEND EMSCRIPTEN_LINK_FLAGS " --preload-file ${FOLDER}/@/")
endforeach()

set_target_properties(${app_name} PROPERTIES LINK_FLAGS "${EMSCRIPTEN_LINK_FLAGS}")
endif()

if(MSVC)
# explicit set source charset to utf-8 for windows targets
target_compile_options(${APP_NAME} PRIVATE "/utf-8")
endif()
endmacro()

# if cc_variable not set, then set it cc_value
Expand All @@ -590,7 +595,7 @@ macro(ax_setup_winrt_sources )

get_target_depends_ext_dlls(3rdparty prebuilt_dlls)

if (NOT prebuilt_dlls)
if (NOT prebuilt_dlls)
set(prebuilt_dlls
${_AX_ROOT}/${_AX_THIRDPARTY_NAME}/zlib/_x/lib/${PLATFORM_NAME}/${ARCH_ALIAS}/zlib1.dll
${_AX_ROOT}/${_AX_THIRDPARTY_NAME}/openssl/_x/lib/${PLATFORM_NAME}/${ARCH_ALIAS}/libssl-3-x64.dll
Expand Down
13 changes: 10 additions & 3 deletions cmake/Modules/AXConfigDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (WINDOWS)
set(CMAKE_C_STANDARD 11)
else()
# windows sdk < 10.0.22000.0, The c11 header stdalign.h was missing, so workaroud fallback C standard to 99
# refer to:
# refer to:
# - https://github.com/axmolengine/axmol/issues/991
# - https://github.com/axmolengine/axmol/issues/1246
message(WARNING "Forcing set CMAKE_C_STANDARD to 99 when winsdk < 10.0.22000.0")
Expand Down Expand Up @@ -132,20 +132,27 @@ function(use_ax_compile_define target)
if(AX_USE_GL)
target_compile_definitions(${target}
PUBLIC AX_USE_GL=1
PUBLIC AX_GLES_PROFILE=${AX_GLES_PROFILE}
PUBLIC GL_SILENCE_DEPRECATION=1
)
if(NOT _AX_USE_PREBUILT)
target_compile_definitions(${target} PUBLIC AX_GLES_PROFILE=${AX_GLES_PROFILE})
endif()
endif()
elseif(LINUX)
ax_config_pred(${target} AX_ENABLE_VLC_MEDIA)
target_compile_definitions(${target} PUBLIC _GNU_SOURCE)
elseif(ANDROID)
if(NOT _AX_USE_PREBUILT)
target_compile_definitions(${target} PUBLIC AX_GLES_PROFILE=${AX_GLES_PROFILE})
endif()
target_compile_definitions(${target} PUBLIC AX_GLES_PROFILE=${AX_GLES_PROFILE})
target_compile_definitions(${target} PUBLIC USE_FILE32API)
elseif(EMSCRIPTEN)
target_compile_definitions(${target} PUBLIC AX_GLES_PROFILE=${AX_GLES_PROFILE})
elseif(WINDOWS)
target_compile_definitions(${target} PUBLIC AX_GLES_PROFILE=${AX_GLES_PROFILE})
if(NOT _AX_USE_PREBUILT)
target_compile_definitions(${target} PUBLIC AX_GLES_PROFILE=${AX_GLES_PROFILE})
endif()
ax_config_pred(${target} AX_ENABLE_VLC_MEDIA)
target_compile_definitions(${target}
PUBLIC WIN32
Expand Down
20 changes: 10 additions & 10 deletions cmake/Modules/AXLinkHelpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ function(ax_link_cxx_prebuilt APP_NAME AX_ROOT_DIR AX_PREBUILT_DIR)
message(STATUS "AX_ENABLE_EXT_EFFEKSEER=${AX_ENABLE_EXT_EFFEKSEER}")
message(STATUS "AX_ENABLE_EXT_LUA=${AX_ENABLE_EXT_LUA}")
message(STATUS "AX_ENABLE_EXT_DRAWNODEEX=${AX_ENABLE_EXT_DRAWNODEEX}")

# compile defines can't inherit when link prebuits, so need add manually
target_compile_definitions(${APP_NAME}
target_compile_definitions(${APP_NAME}
PRIVATE AX_GLES_PROFILE=${AX_GLES_PROFILE}
PRIVATE OPENSSL_SUPPRESS_DEPRECATED=1
PRIVATE NOUNCRYPT=1
Expand Down Expand Up @@ -156,8 +156,8 @@ function(ax_link_cxx_prebuilt APP_NAME AX_ROOT_DIR AX_PREBUILT_DIR)
websocket-parser
)

ax_link_ext(AX_ENABLE_EXT_DRAGONBONES "DragonBones""${AX_ROOT_DIR}/extensions/DragonBones/src")
ax_link_ext(AX_ENABLE_EXT_COCOSTUDIO "cocosstudio" "${AX_ROOT_DIR}/extensions/cocostudio/src")
ax_link_ext(AX_ENABLE_EXT_DRAGONBONES "DragonBones" "${AX_ROOT_DIR}/extensions/DragonBones/src")
ax_link_ext(AX_ENABLE_EXT_COCOSTUDIO "cocostudio" "${AX_ROOT_DIR}/extensions/cocostudio/src")
ax_link_ext(AX_ENABLE_EXT_ASSETMANAGER "assets-manager" "${AX_ROOT_DIR}/extensions/assets-manager/src")
ax_link_ext(AX_ENABLE_EXT_PARTICLE3D "particle3d" "${AX_ROOT_DIR}/extensions/Particle3D/src")
ax_link_ext(AX_ENABLE_EXT_INSPECTOR "Inspector" "${AX_ROOT_DIR}/extensions/Inspector/src")
Expand Down Expand Up @@ -188,11 +188,11 @@ function(ax_link_cxx_prebuilt APP_NAME AX_ROOT_DIR AX_PREBUILT_DIR)
libssl
libcurl_imp
)

if (AX_ENABLE_AUDIO)
target_link_libraries(${APP_NAME}
OpenAL32
)
)
endif()
else()
target_link_libraries(${APP_NAME}
Expand All @@ -203,12 +203,12 @@ function(ax_link_cxx_prebuilt APP_NAME AX_ROOT_DIR AX_PREBUILT_DIR)
ssl
crypto
)

if (AX_ENABLE_AUDIO)
target_link_libraries(${APP_NAME}
openal
)
endif()
)
endif()
endif()

target_link_libraries(${APP_NAME} debug fmtd optimized fmt)
Expand All @@ -231,7 +231,7 @@ function(ax_link_cxx_prebuilt APP_NAME AX_ROOT_DIR AX_PREBUILT_DIR)
add_custom_command(TARGET ${APP_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${AX_ROOT_DIR}/${AX_PREBUILT_DIR}/bin/${BUILD_CONFIG_DIR}OpenAL32.dll"
$<TARGET_FILE_DIR:${APP_NAME}>)
$<TARGET_FILE_DIR:${APP_NAME}>)
endif()

if (BUILD_SHARED_LIBS)
Expand Down

0 comments on commit 1553121

Please sign in to comment.