From d6d041f561b2677dc600cdb41407c784ba7b2c88 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 6 Nov 2013 19:15:20 +0800 Subject: [PATCH] issue #3113: [Linux] Adding options for modules. --- CMakeLists.txt | 73 ++++++++++++++++++++++++++++--- cocos/scripting/CMakeLists.txt | 6 +++ external/Box2D/CMakeLists.txt | 6 +++ external/lua/lua/CMakeLists.txt | 8 +++- external/lua/tolua/CMakeLists.txt | 5 +++ samples/CMakeLists.txt | 12 ++++- 6 files changed, 101 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e07f618e27..f75d56a708 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.6) -project (Cocos2dxSamples) +project (Cocos2dx) # The version number set(Cocos2dxSamples_VERSION_MAJOR 3) @@ -7,14 +7,45 @@ set(Cocos2dxSamples_VERSION_MINOR 0) include(build/BuildHelpers.CMakeLists.txt) -set(CMAKE_BUILE_TYPE DEBUG) +option(USE_CHIPMUNK "Use chipmunk for physics library" ON) +option(USE_BOX2D "Use box2d for physics library" OFF) +option(DEBUG_MODE "Debug or release?" ON) +option(BUILD_LIBS_LUA "Build lua libraries" ON) +option(BUILD_GUI "Build GUI library" ON) +option(BUILD_NETWORK "Build network library" ON) +option(BUILD_EXTENSIONS "Build extension library" ON) +option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) +option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) +option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) + + +option(BUILD_HelloCpp "Only build HelloCpp sample" ON) +option(BUILD_TestCpp "Only build TestCpp sample" ON) +option(BUILD_HelloLua "Only build HelloLua sample" ON) +option(BUILD_TestLua "Only build TestLua sample" ON) + + +if(DEBUG_MODE) + set(CMAKE_BUILE_TYPE DEBUG) +else(DEBUG_MODE) + set(CMAKE_BUILE_TYPE RELEASE) +endif(DEBUG_MODE) + set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-std=c99") set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++11") -add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1) +if(USE_CHIPMUNK) + message("Using chipmunk ...") + add_definitions(-DLINUX -DCC_ENABLE_CHIPMUNK_INTEGRATION=1) +elseif(USE_BOX2D) + message("Using box2d ...") + add_definitions(-DLINUX -DCC_ENABLE_BOX2D_INTEGRATION=1) +else(USE_CHIPMUNK) + message(FATAL_ERROR "Must choose a physics library.") +endif(USE_CHIPMUNK) # architecture if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) @@ -58,6 +89,7 @@ link_directories( ${CMAKE_SOURCE_DIR}/external/linux-specific/fmod/prebuilt/${ARCH_DIR} ) + # kazmath add_subdirectory(cocos/math/kazmath) @@ -73,8 +105,6 @@ add_subdirectory(external/unzip) # tinyxml2 library add_subdirectory(external/tinyxml2) -add_subdirectory(external/json) - # audio add_subdirectory(cocos/audio) @@ -84,22 +114,51 @@ add_subdirectory(cocos/base) # cocos 2d library add_subdirectory(cocos/2d) +if(BUILD_GUI) +# gui add_subdirectory(cocos/gui) +endif(BUILD_GUI) +if(BUILD_NETWORK) +# network add_subdirectory(cocos/network) +endif(BUILD_NETWORK) +if(BUILD_EXTENSIONS) +# extensions add_subdirectory(extensions) +endif(BUILD_EXTENSIONS) +## Editor Support + +if(BUILD_EDITOR_SPINE) +# spine add_subdirectory(cocos/editor-support/spine) +endif(BUILD_EDITOR_SPINE) + +if(BUILD_EDITOR_COCOSBUILDER) +# cocosbuilder add_subdirectory(cocos/editor-support/cocosbuilder) +endif(BUILD_EDITOR_COCOSBUILDER) + +if(BUILD_EDITOR_COCOSTUDIO) +# cocostudio add_subdirectory(cocos/editor-support/cocostudio) +# jsoncpp library, cocostuido depends on jsoncpp +add_subdirectory(external/json) +endif(BUILD_EDITOR_COCOSTUDIO) - +if(BUILD_LIBS_LUA) +## Scripting +# lua add_subdirectory(external/lua/lua) + +# tolua add_subdirectory(external/lua/tolua) +# luabinding add_subdirectory(cocos/scripting) +endif(BUILD_LIBS_LUA) # build samples add_subdirectory(samples) - diff --git a/cocos/scripting/CMakeLists.txt b/cocos/scripting/CMakeLists.txt index 478ae9a039..612d728162 100644 --- a/cocos/scripting/CMakeLists.txt +++ b/cocos/scripting/CMakeLists.txt @@ -36,3 +36,9 @@ target_link_libraries(luabinding tolua lua ) + +set_target_properties(luabinding + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" +) diff --git a/external/Box2D/CMakeLists.txt b/external/Box2D/CMakeLists.txt index 94a1fffb50..fd1f63dc64 100644 --- a/external/Box2D/CMakeLists.txt +++ b/external/Box2D/CMakeLists.txt @@ -53,3 +53,9 @@ include_directories( add_library(box2d STATIC ${BOX2D_SRC} ) + +set_target_properties(box2d + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" +) diff --git a/external/lua/lua/CMakeLists.txt b/external/lua/lua/CMakeLists.txt index faba14e849..c63d80a7b2 100644 --- a/external/lua/lua/CMakeLists.txt +++ b/external/lua/lua/CMakeLists.txt @@ -33,4 +33,10 @@ set(LUA_SRC add_library(lua STATIC ${LUA_SRC} -) \ No newline at end of file +) + +set_target_properties(lua + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" +) diff --git a/external/lua/tolua/CMakeLists.txt b/external/lua/tolua/CMakeLists.txt index 481bdd1247..b12e144e75 100644 --- a/external/lua/tolua/CMakeLists.txt +++ b/external/lua/tolua/CMakeLists.txt @@ -15,3 +15,8 @@ add_library(tolua STATIC ${TOLUA_SRC} ) +set_target_properties(tolua + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/lib" +) diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt index d73334ce7e..198764a991 100644 --- a/samples/CMakeLists.txt +++ b/samples/CMakeLists.txt @@ -1,5 +1,15 @@ - +if(BUILD_HelloCpp) add_subdirectory(Cpp/HelloCpp) +endif(BUILD_HelloCpp) + +if(BUILD_TestCpp) add_subdirectory(Cpp/TestCpp) +endif(BUILD_TestCpp) + +if(BUILD_HelloLua) add_subdirectory(Lua/HelloLua) +endif(BUILD_HelloLua) + +if(BUILD_TestLua) add_subdirectory(Lua/TestLua) +endif(BUILD_TestLua) \ No newline at end of file