From 1d02270c218d7872f8448ab6355b63fbf6beec1a Mon Sep 17 00:00:00 2001 From: Anton Sokolchenko Date: Tue, 14 Oct 2014 19:17:00 +0300 Subject: [PATCH 1/2] fix CMakeLists for Mac Os --- cocos/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index a2988999ae..6aaf58bf60 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -126,7 +126,7 @@ elseif(WINDOWS) elseif(LINUX) set(PLATFORM_SPECIFIC_LIBS jpeg webp tiff freetype curl websockets fontconfig png pthread glfw GLEW GL X11 rt z protobuf ${FMOD_LIB}) -elseif(MACOSX) +elseif(APPLE) INCLUDE_DIRECTORIES ( /System/Library/Frameworks ) From fc35cc2efe04d753f4de6f51292e387ecc190b28 Mon Sep 17 00:00:00 2001 From: Anton Sokolchenko Date: Wed, 15 Oct 2014 00:19:29 +0300 Subject: [PATCH 2/2] CMake fix for Mac Os X. You can open project with CLion and see that everything works. --- CMakeLists.txt | 2 +- cocos/2d/CCMenu.cpp | 1 - cocos/2d/CMakeLists.txt | 2 +- cocos/CMakeLists.txt | 19 +++++++++++++++++-- cocos/base/CMakeLists.txt | 2 +- cocos/platform/CCPlatformConfig.h | 2 +- cocos/platform/CMakeLists.txt | 2 +- tests/cpp-empty-test/CMakeLists.txt | 2 +- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24910f8884..f22763e666 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,7 +87,7 @@ if(WINDOWS) ADD_DEFINITIONS (-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32) set(PLATFORM_FOLDER win32) -elseif(MACOSX) +elseif(MACOSX OR APPLE) ADD_DEFINITIONS (-DCC_TARGET_OS_MAC) ADD_DEFINITIONS (-DUSE_FILE32API) set(PLATFORM_FOLDER mac) diff --git a/cocos/2d/CCMenu.cpp b/cocos/2d/CCMenu.cpp index 7d9141edc6..b484e34b16 100644 --- a/cocos/2d/CCMenu.cpp +++ b/cocos/2d/CCMenu.cpp @@ -32,7 +32,6 @@ THE SOFTWARE. #include "deprecated/CCString.h" #include -#include using namespace std; diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 356c94dbad..e315252dde 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -1,5 +1,5 @@ include_directories( - ../external/ConvertUTF + ../external/ConvertUTF, . ) set(COCOS_2D_SRC diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index 6aaf58bf60..53be4b483a 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -25,6 +25,8 @@ # this CMakeLists is to generate libcocos2d.a +cmake_minimum_required(VERSION 2.7) + if(WINDOWS) ADD_DEFINITIONS(-DUNICODE -D_UNICODE) endif() @@ -74,6 +76,19 @@ set(COCOS_SRC cocos2d.cpp ${COCOS_EXTENSIONS_SRC} ) +if(MACOSX OR APPLE) + + include(FindFreetype REQUIRED) + IF(NOT FREETYPE_FOUND) + FIND_LIBRARY(FREETYPE_LIBRARIES NAMES libfreetype freetype.dll PATHS "../external/freetype2/prebuilt/mac" "../external/freetype2/prebuilt/ios" DOC "Freetype includes") + find_path(FREETYPE_INCLUDE_DIRS ft2build.h "../external/freetype2/include/mac" "../external/freetype2/include/mac/freetype" "../external/freetype2/include/ios" "../external/freetype2/include/ios/freetype" DOC "Freetype includes") + ENDIF(NOT FREETYPE_FOUND) + + find_package(Freetype) + include_directories(${FREETYPE_INCLUDE_DIRS}) + +endif() + if(MINGW) find_package(Freetype REQUIRED) find_package(WebP REQUIRED) @@ -126,8 +141,8 @@ elseif(WINDOWS) elseif(LINUX) set(PLATFORM_SPECIFIC_LIBS jpeg webp tiff freetype curl websockets fontconfig png pthread glfw GLEW GL X11 rt z protobuf ${FMOD_LIB}) -elseif(APPLE) - +elseif(MACOSX OR APPLE) + set (CMAKE_CXX_FLAGS "-std=c++11 -stdlib=libc++") INCLUDE_DIRECTORIES ( /System/Library/Frameworks ) FIND_LIBRARY(COCOA_LIBRARY Cocoa) diff --git a/cocos/base/CMakeLists.txt b/cocos/base/CMakeLists.txt index e6031747d4..680c9a2cc0 100644 --- a/cocos/base/CMakeLists.txt +++ b/cocos/base/CMakeLists.txt @@ -1,5 +1,5 @@ -if(MACOSX) +if(MACOSX OR APPLE) set(COCOS_BASE_SPECIFIC_SRC base/CCUserDefault-apple.mm) endif() diff --git a/cocos/platform/CCPlatformConfig.h b/cocos/platform/CCPlatformConfig.h index c3545df2da..5ca81425b5 100644 --- a/cocos/platform/CCPlatformConfig.h +++ b/cocos/platform/CCPlatformConfig.h @@ -57,7 +57,7 @@ THE SOFTWARE. #define CC_TARGET_PLATFORM CC_PLATFORM_UNKNOWN // mac -#if defined(CC_TARGET_OS_MAC) +#if defined(CC_TARGET_OS_MAC) || defined(__APPLE__) #undef CC_TARGET_PLATFORM #define CC_TARGET_PLATFORM CC_PLATFORM_MAC #endif diff --git a/cocos/platform/CMakeLists.txt b/cocos/platform/CMakeLists.txt index f9ff5a3c3d..c9d4cb9a89 100644 --- a/cocos/platform/CMakeLists.txt +++ b/cocos/platform/CMakeLists.txt @@ -10,7 +10,7 @@ set(COCOS_PLATFORM_SPECIFIC_SRC platform/desktop/CCGLViewImpl-desktop.cpp ) -elseif(MACOSX) +elseif(MACOSX OR APPLE) set(COCOS_PLATFORM_SPECIFIC_SRC platform/mac/CCApplication-mac.mm diff --git a/tests/cpp-empty-test/CMakeLists.txt b/tests/cpp-empty-test/CMakeLists.txt index a8fb93181e..b1199a8070 100644 --- a/tests/cpp-empty-test/CMakeLists.txt +++ b/tests/cpp-empty-test/CMakeLists.txt @@ -17,7 +17,7 @@ elseif(IOS) proj.ios/RootViewController.mm ) -elseif(MACOSX) +elseif(MACOSX OR APPLE) set(PLATFORM_SRC proj.mac/main.cpp )