Fix build on mingw again, disable USE_PREBUILT_LIBS with mingw (mingw can not link this libs). Eliminate some Find* modules, we can tune prebuilts without modify their code.

This commit is contained in:
Vladimir Timofeev 2014-11-19 03:28:41 +03:00
parent fe25c860cb
commit 2bf77c10e8
5 changed files with 45 additions and 141 deletions

View File

@ -36,7 +36,12 @@ message(${BUILDING_STRING})
set(USE_WEBP_DEFAULT ON)
if(WINRT OR WP8)
set(USE_WEBP_DEFAULT OFF)
set(USE_WEBP_DEFAULT OFF)
endif()
set(USE_PREBUILT_LIBS_DEFAULT ON)
if(MINGW)
set(USE_PREBUILT_LIBS_DEFAULT OFF)
endif()
option(USE_CHIPMUNK "Use chipmunk for physics library" ON)
@ -51,8 +56,11 @@ option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON)
option(BUILD_CPP_TESTS "Build TestCpp samples" ON)
option(BUILD_LUA_LIBS "Build lua libraries" ON)
option(BUILD_LUA_TESTS "Build TestLua samples" ON)
option(USE_PREBUILT_LIBS "Use prebuilt libraries in external directory" ${USE_PREBUILT_LIBS_DEFAULT})
option(USE_PREBUILT_LIBS "Use prebuilt libraries in external directory" ON)
if(USE_PREBUILT_LIBS AND MINGW)
message(FATAL_ERROR "Prebuilt windows libs can't be used with mingw, please use packages.")
endif()
if(DEBUG_MODE)
set(CMAKE_BUILD_TYPE DEBUG)
@ -89,7 +97,7 @@ if(WINDOWS)
ADD_DEFINITIONS (-DCC_STATIC)
endif()
ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32)
ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32 -D_WIN32)
set(PLATFORM_FOLDER win32)
elseif(MACOSX OR APPLE)
ADD_DEFINITIONS (-DCC_TARGET_OS_MAC)
@ -145,6 +153,10 @@ if(LINUX OR MACOSX OR WINDOWS)
message(STATUS "OpenGL include dirs: ${OPENGL_INCLUDE_DIRS}")
if(LINUX OR WINDOWS)
if(USE_PREBUILT_LIBS AND WINDOWS)
set(GLEW_INCLUDE_DIR ${COCOS_EXTERNAL_DIR}/${PLATFORM_FOLDER}-specific/gles/include/OGLES)
set(GLEW_LIBRARY ${COCOS_EXTERNAL_DIR}/${PLATFORM_FOLDER}-specific/gles/prebuilt/glew32.lib)
endif()
find_package(GLEW REQUIRED)
message(STATUS "GLEW libs: ${GLEW_LIBRARIES}")
endif()
@ -237,6 +249,13 @@ message(STATUS "TinyXML2 include dirs: ${TinyXML2_INCLUDE_DIRS}")
find_package(JPEG REQUIRED)
message(STATUS "JPEG include dirs: ${JPEG_INCLUDE_DIRS}")
if(USE_PREBUILT_LIBS)
set(ZLIB_PREBUILT_ROOT ${COCOS_EXTERNAL_DIR}/${PLATFORM_FOLDER}-specific/zlib)
#set(CMAKE_INCLUDE_PATH ${ZLIB_PREBUILT_ROOT} ${CMAKE_INCLUDE_PATH})
#set(CMAKE_LIBRARY_PATH ${ZLIB_PREBUILT_ROOT}/prebuilt ${CMAKE_LIBRARY_PATH})
set(ZLIB_INCLUDE_DIR ${ZLIB_PREBUILT_ROOT}/include)
set(ZLIB_LIBRARY ${ZLIB_PREBUILT_ROOT}/prebuilt/libzlib.lib)
endif()
find_package(ZLIB REQUIRED)
message(STATUS "ZLIB include dirs: ${ZLIB_INCLUDE_DIRS}")

View File

@ -61,7 +61,11 @@ if(USE_PREBUILT_LIBS)
NO_DEFAULT_PATH
)
# cleanup if not found (prevent from mix prebuilt include paths and system installed libraries)
if(NOT FREETYPE_INCLUDE_DIR_ft2build OR NOT FREETYPE_INCLUDE_DIR_freetype2 OR NOT FREETYPE_LIBRARY)
if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_LIBRARY)
set(FREETYPE_FOUND 1)
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
set(FREETYPE_LIBRARIES ${FREETYPE_LIBRARY})
else()
unset(FREETYPE_INCLUDE_DIR_ft2build CACHE)
unset(FREETYPE_INCLUDE_DIR_freetype2 CACHE)
unset(FREETYPE_LIBRARY CACHE)
@ -69,8 +73,10 @@ if(USE_PREBUILT_LIBS)
endif(USE_PREBUILT_LIBS)
# Try pkg-config first (because it provided deps info)
find_package(PkgConfig)
pkg_search_module(FREETYPE freetype2)
if(NOT FREETYPE_FOUND)
find_package(PkgConfig)
pkg_search_module(FREETYPE freetype2)
endif()
if(NOT FREETYPE_FOUND)
# Ugh, FreeType seems to use some #include trickery which

View File

@ -1,124 +0,0 @@
#.rst:
# FindZLIB
# --------
#
# Find zlib
#
# Find the native ZLIB includes and library. Once done this will define
#
# ::
#
# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
# ZLIB_LIBRARIES - List of libraries when using zlib.
# ZLIB_FOUND - True if zlib found.
#
#
#
# ::
#
# ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
# ZLIB_VERSION_MAJOR - The major version of zlib
# ZLIB_VERSION_MINOR - The minor version of zlib
# ZLIB_VERSION_PATCH - The patch version of zlib
# ZLIB_VERSION_TWEAK - The tweak version of zlib
#
#
#
# The following variable are provided for backward compatibility
#
# ::
#
# ZLIB_MAJOR_VERSION - The major version of zlib
# ZLIB_MINOR_VERSION - The minor version of zlib
# ZLIB_PATCH_VERSION - The patch version of zlib
#
#
#
# An includer may set ZLIB_ROOT to a zlib installation root to tell this
# module where to look.
#=============================================================================
# Copyright 2001-2011 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
set(ZLIB_NAMES z zlib zdll zlib1 zlibd zlibd1)
if(USE_PREBUILT_LIBS)
set(search PATHS ${COCOS_EXTERNAL_DIR}/zlib ${COCOS_EXTERNAL_DIR}/${ARCH_DIR}-specific/zlib NO_DEFAULT_PATH)
find_path(ZLIB_INCLUDE_DIR NAMES zlib.h ${search} PATH_SUFFIXES include/${PLATFORM_FOLDER} include)
find_library(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ${search}
PATH_SUFFIXES
prebuilt/${PLATFORM_FOLDER}/${ARCH_DIR}
prebuilt/${PLATFORM_FOLDER}
prebuilt
)
# cleanup if not found (prevent from mix prebuilt include paths and system installed libraries)
if(NOT ZLIB_INCLUDE_DIR OR NOT ZLIB_LIBRARY)
unset(ZLIB_INCLUDE_DIR CACHE)
unset(ZLIB_LIBRARY CACHE)
endif()
endif()
set(_ZLIB_SEARCHES)
# Search ZLIB_ROOT first if it is set.
if(ZLIB_ROOT)
set(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH)
list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT)
endif()
# Normal search.
set(_ZLIB_SEARCH_NORMAL
PATHS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]"
"$ENV{PROGRAMFILES}/zlib"
)
list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
# Try each search configuration.
foreach(search ${_ZLIB_SEARCHES})
find_path(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include)
find_library(ZLIB_LIBRARY NAMES ${ZLIB_NAMES} ${${search}} PATH_SUFFIXES lib)
endforeach()
mark_as_advanced(ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$")
string(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}")
string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}")
string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}")
set(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}")
# only append a TWEAK version if it exists:
set(ZLIB_VERSION_TWEAK "")
if( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}")
set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}")
endif()
set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}")
set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}")
set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}")
endif()
# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if
# all listed variables are TRUE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZLIB REQUIRED_VARS ZLIB_LIBRARY ZLIB_INCLUDE_DIR
VERSION_VAR ZLIB_VERSION_STRING)
if(ZLIB_FOUND)
set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
endif()

View File

@ -1,4 +1,8 @@
set(cocos_root ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
set(cocos_root ${Cocos2d-X_SOURCE_DIR})
if(WINDOWS)
add_definitions(-DLUASOCKET_INET_ATON -DLUASOCKET_INET_PTON)
endif()
include_directories(
${cocos_root}/external/lua/tolua
@ -17,13 +21,12 @@ include_directories(
${cocos_root}/cocos/editor-support
${cocos_root}/cocos/platform
${cocos_root}/cocos/audio/include
${CMAKE_CURRENT_SOURCE_DIR}/manual
${CMAKE_CURRENT_SOURCE_DIR}/manual/extension
${CMAKE_CURRENT_SOURCE_DIR}/manual/cocostudio
${CMAKE_CURRENT_SOURCE_DIR}/manual/ui
${CMAKE_CURRENT_SOURCE_DIR}/ui
${CMAKE_CURRENT_SOURCE_DIR}/manual/cocos2d
${CMAKE_CURRENT_SOURCE_DIR}/auto
manual
manual/extension
manual/cocostudio
manual/ui
manual/cocos2d
auto
)
file(GLOB lua_cocos2d_source_files
@ -120,7 +123,7 @@ endif()
set(lua_bindings_files ${lua_cocos2d_source_files} ${lua_bindings_manual_files} ${lua_bindings_auto_files})
add_library(luacocos2d STATIC ${lua_bindings_files})
add_library(luacocos2d ${lua_bindings_files})
target_link_libraries(luacocos2d cocos2d)
set_target_properties(luacocos2d
PROPERTIES

View File

@ -54,8 +54,8 @@ else()
pre_build(${APP_NAME}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../res ${APP_BIN_DIR}${RES_PREFIX}/res
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}${RES_PREFIX}/src
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/ ${APP_BIN_DIR}${RES_PREFIX}/src/cocos
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/../src ${APP_BIN_DIR}${RES_PREFIX}/Resources/src
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/cocos/scripting/lua-bindings/script/ ${APP_BIN_DIR}/Resources/src/cocos
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/tests/cpp-tests/Resources ${APP_BIN_DIR}${RES_PREFIX}/res
)