#/**************************************************************************** # Copyright (c) 2013 cocos2d-x.org # Copyright (c) 2014 martell malone # Copyright (c) 2015-2017 Chukong Technologies Inc. # # http://www.cocos2d-x.org # # 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 # build libcocos2d # build luacocos2d if BUILD_LUA_LIBS=ON # The version number set(COCOS2D_X_VERSION 4.0) set(COCOS_CORE_LIB cocos2d) project(cocos2d_libs) option(CC_USE_ALSOFT_ON_APPLE "Use openal-soft on apple platform" OFF) set(CC_USE_ALSOFT_ON_APPLE ${CC_USE_ALSOFT_ON_APPLE} CACHE BOOL "Use openal-soft on apple platform" FORCE) if(CC_USE_ALSOFT_ON_APPLE) add_definitions(-DCC_USE_ALSOFT_ON_APPLE=1) endif() 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) set(COCOS_HEADER cocos2d.h ${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} ) set(COCOS_SRC cocos2d.cpp ${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}) add_library(cocos2d ${COCOS_SRC}) # use external libs add_subdirectory(${COCOS2DX_ROOT_PATH}/external ${ENGINE_BINARY_PATH}/external) target_link_libraries(cocos2d external) # add base macro define and compile options use_cocos2dx_compile_define(cocos2d) use_cocos2dx_compile_options(cocos2d) # use all platform related system libs use_cocos2dx_libs_depend(cocos2d) target_include_directories(cocos2d PUBLIC ${COCOS2DX_ROOT_PATH} PUBLIC ${COCOS2DX_ROOT_PATH}/external PUBLIC ${COCOS2DX_ROOT_PATH}/extensions PUBLIC ${COCOS2DX_ROOT_PATH}/cocos PUBLIC ${COCOS2DX_ROOT_PATH}/cocos/platform INTERFACE ${COCOS2DX_ROOT_PATH}/extensions INTERFACE ${COCOS2DX_ROOT_PATH}/cocos/base INTERFACE ${COCOS2DX_ROOT_PATH}/cocos/audio/include INTERFACE ${COCOS2DX_ROOT_PATH}/cocos/platform/${PLATFORM_FOLDER} ) set_target_properties(cocos2d PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" VERSION "${COCOS2D_X_VERSION}" FOLDER "Internal" ) ## Lua bindings lib if(BUILD_LUA_LIBS) add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos/scripting/lua-bindings ${ENGINE_BINARY_PATH}/cocos/lua-bindings) endif() if(XCODE OR VS) cocos_mark_code_files("cocos2d") endif() if(WINDOWS) # precompiled header. Compilation time speedup ~4x. target_sources(cocos2d PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp") set_target_properties(cocos2d PROPERTIES COMPILE_FLAGS "/Yuprecheader.h /FIprecheader.h") set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/precheader.cpp" PROPERTIES COMPILE_FLAGS "/Ycprecheader.h") # compile c as c++. needed for precompiled header set_source_files_properties(${COCOS_SPINE_SRC} base/ccFPSImages.c PROPERTIES LANGUAGE CXX) endif() # engine extensions add_subdirectory(${COCOS2DX_ROOT_PATH}/extensions ${ENGINE_BINARY_PATH}/extensions) #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 # target_compile_options(cocos2d PUBLIC $<$:-fno-aligned-allocation>) #endif()