fe497933f8
* hack to make sprite3d test work * support cull face * support setting front face winding * convert depth compare function type * clean codes * remove usage of glprogramstate * pass needed information to Material::draw() * add 3d textures * enable animation * 3D: compile on windows (#179) * exclude source files from extensions/ * enable assets and 3D * run on windows * update comments * use std::vector instead of raw pointer void * * compile on mac * revert cmake * fix bufferdata * add todos * remove dirty flag from uniform buffer * argument type const & * enable more tests * update shader * save: failed to compile * pass compilation * fix type convert * save stage * save stage 2 * remove VertexData & IndexBuffer & VertexBuffer * comment out _meshCommand * comment bindPredefinedVertexAttribs() * fix xcode project file * simple refactor * remove unused files * revert sprite3d testcase position * revert change * remove ProgramGL::bindPredefinedVertexAttribs() * add header <string> * fix uniform size |
||
---|---|---|
.. | ||
Modules | ||
README.md | ||
ios.toolchain.cmake |
README.md
CMake Guide
CMake is an open-source, cross-platform family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files, and generates native makefiles and workspaces that can be used in the compiler environment of your choice.
Requirement
- Open your terminal and execute:
cmake --version
if the CMake version is lower than 3.6, please upgrade.
- You should use out-of-source builds, this means you need to create a different directory than cocos2d-x to execute the
cmake
command.
Step by Step
Linux
cd cocos2d-x
mkdir linux-build && cd linux-build
cmake ..
make
Execute make help
to see all build targets, make <target>
build specified target
Generate Visual Studio projects
cd cocos2d-x
mkdir win32-build && cd win32-build
cmake .. -G"Visual Studio 15 2017" -Tv141
Execute cmake --build .
to compile,
cmake --build . --config Debug
cmake --build . --config Release
or open Cocos2d-x.sln in Explorer to use the generated project.
If can't found MSVCR110.dll
issue occurs to you, please install this Visual C++ Runtime Libraries, when runing the cpp-tests project
Generate macOS Project
cd cocos2d-x
mkdir mac-build && cd mac-build
cmake .. -GXcode
open Cocos2d-x.xcodeproj
Generate iOS Project
cd cocos2d-x
mkdir ios-build && cd ios-build
cmake .. -GXcode -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.toolchain.cmake
open Cocos2d-x.xcodeproj
The default build is for running on iOS device, if you want to run in the simulator, please add -DIOS_PLATFORM=SIMULATOR
for architecture i386 or -DIOS_PLATFORM=SIMULATOR64
for x86_64, but remember you can't run metal-support app in simulator because Apple limitation.
if you want to sign iOS app in CMake, you will need to fill development team ID into set_xcode_property(${APP_NAME} DEVELOPMENT_TEAM "")
, or select to sign in Xcode after project files generated.
Android Studio
We use the Gradle for Android applications, and Gradle use cmake to build the native code, see gradle.properties: PROP_NDK_MODE
, it controls how native builds work.
# android native code build type
# none, native code will never be compiled.
# cmake, native code will be compiled by CMakeLists.txt
# ndk-build, native code will be compiled by Android.mk
PROP_BUILD_TYPE=cmake
If you want to add cmake build arguments, please add it at external Native Build block of app/build.gradle file.
Build Options
CMake Common Build Options
-
-G
, generate native build project you specified, for example-GXcode
generate Xcode project files.-GVisual Studio 15 2017
generate Visual Studio 2017 project, the default toolset is v141, add-T
option to specify toolset, like this-Tv140
-
CMAKE_BUILD_TYPE
, specify the build mode, Debug or Release-DCMAKE_BUILD_TYPE=Release
to generate the Release mode project, the default build mode is Debug
-
-H -B
,-H
specify the CMake project Home directory,-B
specify CMake-generated project binary directory. for example-H..\cocos2d-x -Bmsvc_build
the generated native project's location will bemsvc_build
directory.
-
--build <dir>
, build a CMake-generated project binary tree, for examplecmake --build ./msvc_build
, cmake will sellect corresponding build tools.
Tips
- Use
cmake ..
to refersh resources and code files, after you modifyResources
orCMakeLists.txt
. - Don't need
CMAKE_BUILD_TYPE
options when-G
Xcode or Visual Studio, CMake scripts will generate both configurations, so you can switchDebug
andRelease
in IDE.
Useful Links
-
CMake Official website: cmake.org
-
CMake Documentation: cmake.org/documentation
-
CMake FAQ: Wiki/CMake_FAQ