axmol/cmake/Modules/CocosBuildSet.cmake

83 lines
2.8 KiB
CMake
Raw Normal View History

V3 android cmake support, add mac/ios support (#18646) * CMake build improvements * android cmake support * Enable proguard for cocos2d * examples & test cmake support * add android build type param to gradle.properties file * less warnings * update all android configs to recomended settings * fix network cmake error * fix js-tests cmake error * android build config, add cmake * android build config, add cmake * add lua share lib * android lua cmake build fix * fix * luajit test * run fail, still * fix js-warning * correct lua main include * lua test project cmake support android * try to add lua-template cmake support * lua template fix * js_tests support cmake on android * js-tests improve * cmake support js-template * test to realise prebuild * cmake improve, no feature * improve templates cmake * refactor cmake struct * correct cpp-tests cmake * cpp-templates cmake improve * typo fix * cmake struct refator * change default option * adapt new project struct * uniform cmake test style * add_dependencies to support make -j * little struct improve * little fix * adapt cmake bin dir * little improve about cmake version * change build all tests condition * add source_group for Xcode * add mark source files * add more mark source code * add template project to test * add macos info.plist template * add pak macos for all project * lua test icon fix * not consider lua project for now * modify pak method * add another ios toolchain * add ios system library * update ios toolchain, and reduce ios compile errors * reduce error * make ios engine lib compile pass * cpp-empty-test ios bundle * cpp-tests ios support * js-tests ios support * templates project support ios * fix the way of lua-tests package * try to fix lua-template on macOS * comment lua-template sim file * improve display on xcode * update cmake readme * check android compile again * fix android compile error * fix linux cmake res error * update deps version, for cmake * fix lua_template linux compile error * close android cmake support for now * review template android share library name * change PROP_BUILD_TOOLS_VERSION version to 27.0.1 * change android compile version * make `PROP_APP_PLATFORM` back, add comments for android native build * Revert "make `PROP_APP_PLATFORM` back, add comments for android native build" This reverts commit 272ddc19886891b9502cde070753a870c0fdb588.
2018-02-08 09:24:33 +08:00
# Disable in-source builds to prevent source tree corruption.
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "
FATAL: In-source builds are not allowed.
You should create a separate directory for build files.
")
endif()
macro(CocosBuildSet)
# It ensures that when Find*.cmake files included from cmake's Modules dir
# include another *.cmake file with relative path, that file will be included
# also from cmake's Modules dir, to not clash with per-project files.
cmake_policy(SET CMP0017 NEW)
# Use new behaviour with cmake >= 3.1:
# Only interpret if() arguments as variables or keywords when unquoted.
cmake_policy(SET CMP0054 NEW)
# Use new behaviour with cmake >= 3.1:
# Only interpret if() arguments as variables or keywords when unquoted.
if(CMAKE_VERSION VERSION_GREATER 3.1)
cmake_policy(SET CMP0054 NEW)
endif()
# some useful variables for every one cocos project
set(COCOS_EXTERNAL_DIR ${COCOS2DX_ROOT_PATH}/external)
set(ENGINE_BINARY_PATH ${PROJECT_BINARY_DIR}/engine)
set(COCOS_PREBUILT_LIBS_PATH ${COCOS2DX_ROOT_PATH}/prebuilt)
message(STATUS "COCOS2DX_ROOT_PATH:" ${COCOS2DX_ROOT_PATH})
message(STATUS "CMAKE_MODULE_PATH:" ${CMAKE_MODULE_PATH})
message(STATUS "COCOS_EXTERNAL_DIR:" ${COCOS_EXTERNAL_DIR})
message(STATUS "ENGINE_BINARY_PATH:" ${ENGINE_BINARY_PATH})
# architecture
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH_DIR "64-bit")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ARCH_DIR "32-bit")
else()
message(WARN "CMAKE_SIZEOF_VOID_P: ${CMAKE_SIZEOF_VOID_P}")
endif()
# CMAKE_BUILD_TYPE has precedence over DEBUG_MODE
# Still supporting DEBUG_MODE for backwards compatibility
if(NOT CMAKE_BUILD_TYPE)
if(DEBUG_MODE)
set(CMAKE_BUILD_TYPE DEBUG)
else(DEBUG_MODE)
set(CMAKE_BUILD_TYPE RELEASE)
endif(DEBUG_MODE)
endif(NOT CMAKE_BUILD_TYPE)
# Define other useful variables not defined by CMake
if(CMAKE_GENERATOR STREQUAL Xcode)
set (XCODE TRUE)
elseif(CMAKE_GENERATOR MATCHES Visual)
set (VS TRUE)
endif()
include(CocosBuildHelpers)
# SelectModule() is a macro to select building modules
include(SelectModule)
SelectModule()
# set compiler options
include(SetCompilerOptions)
SetCompilerOptions()
if(CMAKE_FIND_ROOT_PATH AND USE_EXTERNAL_PREBUILT_LIBS)
# Adds cocos2d-x external folder to the list of valid include/library paths when cross-compiling and using prebuilds
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${COCOS_EXTERNAL_DIR})
endif()
if(USE_EXTERNAL_PREBUILT_LIBS)
include(CocosUsePrebuiltLibs)
endif()
include(BuildModules)
BuildModules()
endmacro(CocosBuildSet)