axmol/core/CMakeLists.txt

211 lines
7.7 KiB
CMake
Raw Normal View History

2019-11-23 20:27:39 +08:00
#/****************************************************************************
# Copyright (c) 2013 cocos2d-x.org
# Copyright (c) 2014 martell malone
# Copyright (c) 2015-2017 Chukong Technologies Inc.
2022-04-24 21:23:28 +08:00
# Copyright (c) 2021-2022 Bytedance Inc.
2021-10-25 23:30:03 +08:00
#
2022-01-04 12:36:20 +08:00
# https://adxeproject.github.io/
2019-11-23 20:27:39 +08:00
#
# 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.
# ****************************************************************************/
# this CMakeLists is to generate Cocos2d-x Engine Library
2021-05-24 19:18:15 +08:00
# build adxe
# build adxelua if AX_ENABLE_EXT_LUA=ON
2019-11-23 20:27:39 +08:00
# The version number
2021-05-18 16:40:30 +08:00
set(ADXE_VERSION 1.0)
2019-11-23 20:27:39 +08:00
2021-05-18 16:40:30 +08:00
if(NOT DEFINED ADXE_CORE_LIB)
set(ADXE_CORE_LIB adxe CACHE INTERNAL "The adxe core lib name" )
endif()
2020-08-12 18:53:33 +08:00
2022-02-17 17:11:17 +08:00
if (NOT DEFINED AX_USE_COMPAT_GL)
set(AX_USE_COMPAT_GL FALSE CACHE INTERNAL "Enabling AX_USE_COMPAT_GL" )
endif()
2022-02-17 17:11:17 +08:00
if (NOT DEFINED AX_ENABLE_MSEDGE_WEBVIEW2)
set(AX_ENABLE_MSEDGE_WEBVIEW2 TRUE CACHE INTERNAL "Enabling windows webview2" )
endif()
if (NOT DEFINED AX_ENABLE_MFMEDIA)
set(AX_ENABLE_MFMEDIA TRUE CACHE INTERNAL "Enabling microsoft media foundation for windows video player" )
endif()
2021-08-12 11:25:01 +08:00
project(adxe_libs)
if(XCODE)
# set(CMAKE_BUILD_WITH_INSTALL_RPATH YES)
# set(CMAKE_INSTALL_RPATH "@executable_path/Frameworks")
set(CMAKE_XCODE_ATTRIBUTE_LD_RUNPATH_SEARCH_PATHS "@executable_path/Frameworks" CACHE INTERNAL "")
endif()
2019-11-23 20:27:39 +08:00
set(ADXE_THIRDPARTY_NAME "thirdparty" CACHE INTERNAL "" )
2021-07-04 21:18:14 +08:00
if (WIN32)
option(WIN32_PATH_USE_ACP "" OFF)
if(NOT WIN32_PATH_USE_ACP)
add_definitions(-DNTCVT_CP_DEFAULT=CP_UTF8)
else()
add_definitions(-DNTCVT_CP_DEFAULT=CP_ACP)
endif()
endif()
2019-11-23 20:27:39 +08:00
include(2d/CMakeLists.txt)
include(3d/CMakeLists.txt)
include(platform/CMakeLists.txt)
include(physics/CMakeLists.txt)
include(physics3d/CMakeLists.txt)
include(math/CMakeLists.txt)
include(navmesh/CMakeLists.txt)
include(renderer/CMakeLists.txt)
include(base/CMakeLists.txt)
include(ui/CMakeLists.txt)
include(network/CMakeLists.txt)
include(audio/CMakeLists.txt)
2021-10-25 18:06:45 +08:00
set(COCOS_HEADER adxe.h
2019-11-23 20:27:39 +08:00
${COCOS_2D_HEADER}
${COCOS_3D_HEADER}
${COCOS_PLATFORM_HEADER}
${COCOS_PHYSICS_HEADER}
${COCOS_PHYSICS3D_HEADER}
${COCOS_MATH_HEADER}
${COCOS_NAVMESH_HEADER}
${COCOS_RENDERER_HEADER}
${COCOS_BASE_HEADER}
${COCOS_AUDIO_HEADER}
${COCOS_UI_HEADER}
${COCOS_NETWORK_HEADER}
)
2021-10-25 18:06:45 +08:00
set(COCOS_SRC adxe.cpp
2019-11-23 20:27:39 +08:00
${COCOS_2D_SRC}
${COCOS_3D_SRC}
${COCOS_PLATFORM_SRC}
${COCOS_PHYSICS_SRC}
${COCOS_PHYSICS3D_SRC}
${COCOS_MATH_SRC}
${COCOS_NAVMESH_SRC}
${COCOS_RENDERER_SRC}
${COCOS_BASE_SRC}
${COCOS_AUDIO_SRC}
${COCOS_UI_SRC}
${COCOS_NETWORK_SRC}
)
list(APPEND COCOS_SRC ${COCOS_HEADER})
2021-05-18 16:40:30 +08:00
add_library(${ADXE_CORE_LIB} ${COCOS_SRC})
2019-11-23 20:27:39 +08:00
# use thirdparty libs
add_subdirectory(${ADXE_ROOT_PATH}/thirdparty ${ENGINE_BINARY_PATH}/thirdparty)
target_link_libraries(${ADXE_CORE_LIB} thirdparty)
2019-11-23 20:27:39 +08:00
# add base macro define and compile options
2021-05-18 16:40:30 +08:00
use_cocos2dx_compile_define(${ADXE_CORE_LIB})
use_cocos2dx_compile_options(${ADXE_CORE_LIB})
2019-11-23 20:27:39 +08:00
# use all platform related system libs
2021-05-18 16:40:30 +08:00
use_cocos2dx_libs_depend(${ADXE_CORE_LIB})
target_include_directories(${ADXE_CORE_LIB}
PUBLIC ${ADXE_ROOT_PATH}
PUBLIC ${ADXE_ROOT_PATH}/thirdparty
2021-05-18 16:40:30 +08:00
PUBLIC ${ADXE_ROOT_PATH}/extensions
2021-12-31 14:39:08 +08:00
PUBLIC ${ADXE_ROOT_PATH}/core
PUBLIC ${ADXE_ROOT_PATH}/core/platform
2021-05-18 16:40:30 +08:00
INTERFACE ${ADXE_ROOT_PATH}/thirdparty
2021-05-18 16:40:30 +08:00
INTERFACE ${ADXE_ROOT_PATH}/extensions
2021-12-31 14:39:08 +08:00
INTERFACE ${ADXE_ROOT_PATH}/core/base
2022-01-03 11:34:58 +08:00
INTERFACE ${ADXE_ROOT_PATH}/core/audio
2021-12-31 14:39:08 +08:00
INTERFACE ${ADXE_ROOT_PATH}/core/platform/${PLATFORM_FOLDER}
2019-11-23 20:27:39 +08:00
)
2021-05-18 16:40:30 +08:00
set_target_properties(${ADXE_CORE_LIB}
2019-11-23 20:27:39 +08:00
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
2021-05-18 16:40:30 +08:00
VERSION "${ADXE_VERSION}"
2019-11-23 20:27:39 +08:00
FOLDER "Internal"
)
## Lua bindings lib
# if(AX_ENABLE_EXT_LUA)
2021-12-31 14:39:08 +08:00
# add_subdirectory(${ADXE_ROOT_PATH}/extensions/scripting/lua-bindings ${ENGINE_BINARY_PATH}/core/lua-bindings)
2020-10-17 16:32:16 +08:00
# endif()
2019-11-23 20:27:39 +08:00
if(XCODE OR VS)
2021-05-18 16:40:30 +08:00
cocos_mark_code_files("${ADXE_CORE_LIB}")
2019-11-23 20:27:39 +08:00
endif()
if(WINDOWS)
# precompiled header. Compilation time speedup ~4x, but don't know how Ninja to support PCH yet and needs help from someone.
if(NOT CMAKE_GENERATOR STREQUAL "Ninja")
target_sources(${ADXE_CORE_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp")
set_target_properties(${ADXE_CORE_LIB} PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h")
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h")
endif()
2019-11-23 20:27:39 +08:00
# compile c as c++. needed for precompiled header
set_source_files_properties(${COCOS_SPINE_SRC} base/ccFPSImages.c PROPERTIES LANGUAGE CXX)
2022-02-17 17:11:17 +08:00
if(AX_ENABLE_MSEDGE_WEBVIEW2)
find_program(NUGET_EXE NAMES nuget
PATHS ${ADXE_ROOT_PATH}/tools/external/nuget)
if(NOT NUGET_EXE)
message("NUGET.EXE not found.")
message(FATAL_ERROR "Please run setup.py again to download NUGET.EXE, and run CMake again.")
endif()
exec_program(${NUGET_EXE}
ARGS install "Microsoft.Web.WebView2" -Version 1.0.992.28 -ExcludeVersion -OutputDirectory ${CMAKE_BINARY_DIR}/packages)
2022-04-26 15:16:02 +08:00
if(CMAKE_GENERATOR STREQUAL "Ninja")
target_link_libraries(${ADXE_CORE_LIB} ${CMAKE_BINARY_DIR}/packages/Microsoft.Web.WebView2/build/native/${ARCH_ALIAS}/WebView2Loader.dll.lib)
target_include_directories(${ADXE_CORE_LIB} PUBLIC ${CMAKE_BINARY_DIR}/packages/Microsoft.Web.WebView2/build/native/include)
else()
target_link_libraries(${ADXE_CORE_LIB} ${CMAKE_BINARY_DIR}/packages/Microsoft.Web.WebView2/build/native/Microsoft.Web.WebView2.targets)
endif()
target_compile_definitions(${ADXE_CORE_LIB} PUBLIC ADXE_HAVE_WEBVIEW2)
endif()
2019-11-23 20:27:39 +08:00
endif()
2020-08-03 20:31:47 +08:00
# engine extensions
2021-05-18 16:40:30 +08:00
add_subdirectory(${ADXE_ROOT_PATH}/extensions ${ENGINE_BINARY_PATH}/extensions)
2020-08-03 20:31:47 +08:00
if(MSVC)
target_sources(${ADXE_CORE_LIB} PRIVATE ../thirdparty/yasio/yasio.natvis)
target_sources(${ADXE_CORE_LIB} PRIVATE ../thirdparty/robin-map/tsl-robin-map.natvis)
target_compile_options(${ADXE_CORE_LIB} PUBLIC "/Zm2000")
endif()
# copy all thirdparty libraries to ${CMAKE_BINARY_DIR}/lib/$<CONFIG>
2020-10-17 16:32:16 +08:00
# if (WINDOWS)
# copy_thirdparty_dlls(libcocos2d ${CMAKE_BINARY_DIR}/lib/$<CONFIG>)
# endif()
2019-11-23 20:27:39 +08:00
#if(XCODE)
# # Later versions of Xcode clang want to compile C++17 with aligned allocation turned on and this is only supported on iOS 11.0+
# # TODO: Only turn this off if ${CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET} < 11.0
2021-05-18 16:40:30 +08:00
# target_compile_options(${ADXE_CORE_LIB} PUBLIC $<$<COMPILE_LANGUAGE:CXX>:-fno-aligned-allocation>)
2019-11-23 20:27:39 +08:00
#endif()