From eb0159b2b752e9b79362ed62e0d8c6169d3c3e89 Mon Sep 17 00:00:00 2001 From: Vladimir Timofeev Date: Sat, 15 Nov 2014 13:17:23 +0300 Subject: [PATCH] Unify usage of chipmunk library * cmake/Modules/FindChipmunk.cmake now can find prebuilt chipmunk libs * follow USE_CHIPMUNK variable (although at the moment cocos can't build without chipmunk) * come cleanups and formatting --- CMakeLists.txt | 16 +++++++++------- cmake/Modules/FindChipmunk.cmake | 23 +++++++++++++++++++++++ cocos/CMakeLists.txt | 12 +++++++----- extensions/CMakeLists.txt | 13 ------------- 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 552ecf35ec..bdbff7c1af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -168,11 +168,9 @@ include_directories( # GLFW3 used on Mac, Windows and Linux desktop platforms if(LINUX OR MACOSX OR WINDOWS) - find_package(GLFW3 REQUIRED) message(STATUS "GLFW3 include dirs: ${GLFW3_INCLUDE_DIRS}") include_directories(${GLFW3_INCLUDE_DIRS}) - endif(LINUX OR MACOSX OR WINDOWS) # Freetype required on all platforms @@ -182,16 +180,21 @@ include_directories(${FREETYPE_INCLUDE_DIRS}) # WebP required if used if(USE_WEBP) -find_package(WebP REQUIRED) -message(STATUS "WebP include dirs: ${WEBP_INCLUDE_DIRS}") -endif() + find_package(WebP REQUIRED) + message(STATUS "WebP include dirs: ${WEBP_INCLUDE_DIRS}") +endif(USE_WEBP) + +if(USE_CHIPMUNK) + find_package(Chipmunk REQUIRED) + message(STATUS "Chipmunk include dirs: ${CHIPMUNK_INCLUDE_DIRS}") + add_definitions(-DCC_ENABLE_CHIPMUNK_INTEGRATION=1) +endif(USE_CHIPMUNK) if(NOT MINGW) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external/tinyxml2 - ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/include/chipmunk ${CMAKE_CURRENT_SOURCE_DIR}/external/box2d/include ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/include/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/png/include/${PLATFORM_FOLDER} @@ -208,7 +211,6 @@ if(NOT MINGW) ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER_ARCH} ${CMAKE_CURRENT_SOURCE_DIR}/external/png/prebuilt/${PLATFORM_FOLDER_ARCH} ${CMAKE_CURRENT_SOURCE_DIR}/external/websockets/prebuilt/${PLATFORM_FOLDER_ARCH} - ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk/prebuilt/${PLATFORM_FOLDER_ARCH} ${CMAKE_CURRENT_SOURCE_DIR}/external/box2d/prebuilt/${PLATFORM_FOLDER_ARCH} ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/prebuilt/${PLATFORM_FOLDER_ARCH} diff --git a/cmake/Modules/FindChipmunk.cmake b/cmake/Modules/FindChipmunk.cmake index 31fc02f489..b194f7ed7f 100644 --- a/cmake/Modules/FindChipmunk.cmake +++ b/cmake/Modules/FindChipmunk.cmake @@ -27,6 +27,29 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) +if(USE_PREBUILT_LIBS) + find_path(CHIPMUNK_INCLUDE_DIR chipmunk.h + PATH_SUFFIXES + include/chipmunk + include + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk + NO_DEFAULT_PATH + ) + find_library(CHIPMUNK_LIBRARY + NAMES chipmunk libchipmunk + PATH_SUFFIXES + prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR} + prebuilt/${PLATFORM_FOLDER} + PATHS ${CMAKE_CURRENT_SOURCE_DIR}/external/chipmunk + NO_DEFAULT_PATH + ) + # cleanup if not found (prevent from mix prebuilt include paths and system installed libraries) + if(NOT CHIPMUNK_INCLUDE_DIR OR NOT CHIPMUNK_LIBRARY) + unset(CHIPMUNK_INCLUDE_DIR CACHE) + unset(CHIPMUNK_LIBRARY CACHE) + endif() +endif(USE_PREBUILT_LIBS) + FIND_PATH(CHIPMUNK_INCLUDE_DIR chipmunk.h HINTS ENV CHIPMUNK_DIR diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index b4a597bc4f..0a31f3552c 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -88,13 +88,10 @@ if(MINGW) find_package(ZLIB REQUIRED) - find_package(Chipmunk REQUIRED) - message( STATUS "ZLIB dirs: ${ZLIB_INCLUDE_DIRS}") - message( STATUS "Chipmunk dirs: ${CHIPMUNK_INCLUDE_DIRS}") message( STATUS "Protobuf dirs: ${PROTOBUF_INCLUDE_DIRS}") - include_directories(${ZLIB_INCLUDE_DIRS} ${CHIPMUNK_INCLUDE_DIRS} ${PROTOBUF_INCLUDE_DIRS}) + include_directories(${ZLIB_INCLUDE_DIRS} ${PROTOBUF_INCLUDE_DIRS}) else() @@ -163,7 +160,7 @@ if(LINUX OR MACOSX OR WINDOWS) list(APPEND PLATFORM_SPECIFIC_LIBS ${GLFW3_LIBRARIES}) endif() -target_link_libraries(cocos2d chipmunk box2d protobuf tinyxml2 unzip xxhash ${FREETYPE_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS}) +target_link_libraries(cocos2d box2d protobuf tinyxml2 unzip xxhash ${FREETYPE_LIBRARIES} ${PLATFORM_SPECIFIC_LIBS}) if(USE_WEBP) add_definitions(-DCC_USE_WEBP=1) @@ -173,6 +170,11 @@ else() add_definitions(-DCC_USE_WEBP=0) endif() +if(USE_CHIPMUNK) + include_directories(${CHIPMUNK_INCLUDE_DIRS}) + target_link_libraries(cocos2d ${CHIPMUNK_LIBRARIES}) +endif() + set_target_properties(cocos2d PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index fd212cba4e..5a2ef4f2a9 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -2,19 +2,6 @@ if(WINDOWS AND NOT BUILD_STATIC) ADD_DEFINITIONS (-D_USREXDLL) endif() -if(WINDOWS) - -# set(PLATFORM_EXTENSIONS_SRC -# ../extensions/proj.win32/Win32InputBox.cpp -# ) - -elseif(MACOSX) - -else() -# set(PLATFORM_EXTENSIONS_SRC -# ../../extensions/GUI/CCEditBox/CCEditBoxImplNone.cpp) -endif() - include_directories( ../../extensions )