diff --git a/CMakeLists.txt b/CMakeLists.txt index 7db3ea143c..bfcb16bc40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ #/**************************************************************************** # Copyright (c) 2013 cocos2d-x.org -# Copyright (c) 2012-2013 martell malone -# +# Copyright (c) 2014 martell malone +# # http://www.cocos2d-x.org # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -28,38 +28,23 @@ project (Cocos2dx) # The version number set(Cocos2dxSamples_VERSION_MAJOR 3) -set(Cocos2dxSamples_VERSION_MINOR 0) +set(Cocos2dxSamples_VERSION_MINOR 1) include(build/BuildHelpers.CMakeLists.txt) -if(WIN32 OR APPLE) +message(${BUILDING_STRING}) 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" OFF) 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_CppTests "Only build TestCpp sample" ON) -option(BUILD_LuaTests "Only build TestLua sample" OFF) -else()#temp - -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_EXTERN_LIBS "Build Box2d, Chipmunk, Tinyxml2 from source" ON) +option(BUILD_CppTests "Build TestCpp samples" ON) option(BUILD_LIBS_LUA "Build lua libraries" 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_CppTests "Only build TestCpp sample" ON) -option(BUILD_LuaTests "Only build TestLua sample" ON) -endif()#temp - +option(BUILD_LuaTests "Build TestLua samples" ON) if(DEBUG_MODE) set(CMAKE_BUILD_TYPE DEBUG) @@ -70,31 +55,25 @@ endif(DEBUG_MODE) set(CMAKE_C_FLAGS_DEBUG "-DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) -if(WIN32) +if(MSVC) + ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710 + -wd4514 -wd4056 -wd4996 -wd4099) +else() + 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} -fno-exceptions -std=c99") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -std=c++11") +endif(MSVC) + +if(WINDOWS) ADD_DEFINITIONS (-D_USRDLL -DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32) - - if(MSVC) - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS - -D_SCL_SECURE_NO_WARNINGS - -wd4251 -wd4244 -wd4334 - -wd4005 -wd4820 -wd4710 - -wd4514 -wd4056 -wd4996 -wd4099) - else(MSVC)#MINGW - - endif(MSVC) -elseif(APPLE) - - -else()#Linux -ADD_DEFINITIONS(-DLINUX) -endif() - - -if(NOT MSVC)# all gcc -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") + set(PLATFORM_FOLDER win32) +elseif(MACOSX) + set(PLATFORM_FOLDER mac) +else(LINUX) + ADD_DEFINITIONS(-DLINUX) + set(PLATFORM_FOLDER linux) endif() if(MINGW) @@ -102,8 +81,12 @@ if(MINGW) add_definitions(-D__SSIZE_T) set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lws2_32") set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lws2_32") -endif() + if(CLANG) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions ") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions ") + endif() +endif() if(USE_CHIPMUNK) message("Using chipmunk ...") @@ -122,14 +105,6 @@ else() set(ARCH_DIR "32-bit") endif() -if(WIN32) # Win32 - set(PLATFORM_FOLDER win32) -elseif(APPLE)# osx or ios - set(PLATFORM_FOLDER mac) -else() # Assume Linux - set(PLATFORM_FOLDER linux) -endif() - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cocos @@ -156,18 +131,18 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external/xxtea ) -if(WIN32 AND NOT MINGW) +if(MSVC) include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/gles/include/OGLES ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/include ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/include external/curl/include/${PLATFORM_FOLDER} ) -elseif(APPLE) +elseif(MACOSX) include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER} + ${CMAKE_CURRENT_SOURCE_DIR}/external/curl/include/${PLATFORM_FOLDER} ) -else() +elseif(LINUX) include_directories( /usr/include /usr/include/GLFW @@ -177,9 +152,8 @@ else() endif() -if(WIN32) +if(MSVC) - if(NOT MINGW) link_directories( ${CMAKE_CURRENT_SOURCE_DIR}/external/jpeg/prebuilt/${PLATFORM_FOLDER} ${CMAKE_CURRENT_SOURCE_DIR}/external/tiff/prebuilt/${PLATFORM_FOLDER} @@ -189,11 +163,8 @@ if(WIN32) ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/icon/prebuilt ${CMAKE_CURRENT_SOURCE_DIR}/external/${PLATFORM_FOLDER}-specific/zlib/prebuilt ) - endif() -elseif(APPLE) - -else() +elseif(LINUX) link_directories( /usr/local/lib @@ -208,17 +179,21 @@ else() endif() +if(BUILD_EXTERN_LIBS) # chipmunk library add_subdirectory(external/chipmunk/src) # box2d library add_subdirectory(external/Box2D) +endif() # unzip library add_subdirectory(external/unzip) +if(BUILD_EXTERN_LIBS) # tinyxml2 library add_subdirectory(external/tinyxml2) +endif() # xxhash library add_subdirectory(external/xxhash) @@ -266,15 +241,13 @@ add_subdirectory(cocos/scripting/lua-bindings) add_subdirectory(external/xxtea) endif(BUILD_LIBS_LUA) -# build tests - -add_subdirectory(tests/cpp-empty-test) - +# build tests if(BUILD_CppTests) +add_subdirectory(tests/cpp-empty-test) add_subdirectory(tests/cpp-tests) endif(BUILD_CppTests) if(BUILD_LuaTests) add_subdirectory(tests/lua-tests/project) add_subdirectory(tests/lua-empty-test/project) -endif(BUILD_LuaTests) +endif(BUILD_LuaTests) \ No newline at end of file diff --git a/build/BuildHelpers.CMakeLists.txt b/build/BuildHelpers.CMakeLists.txt index 6e848d4f29..225e3c7ed7 100644 --- a/build/BuildHelpers.CMakeLists.txt +++ b/build/BuildHelpers.CMakeLists.txt @@ -11,3 +11,59 @@ macro(pre_build TARGET_NAME) add_custom_target( ${TARGET_NAME}_CORE_PRE_BUILD ) add_dependencies( ${TARGET_NAME}_PRE_BUILD ${TARGET_NAME}_CORE_PRE_BUILD ) endmacro() + +#cmake has some strange defaults, this should help us a lot +#Please use them everywhere + +#WINDOWS = Windows Desktop +#WINRT = Windows RT +#WP8 = Windows Phone 8 +#ANDROID = ANDROID +#IOS = IOS +#MACOSX = MAC OSX + +if (${CMAKE_SYSTEM_NAME} MATCHES "Windows") + if(WINRT) + set(SYSTEM_STRING "Windows RT") + elseif(WP8) + set(SYSTEM_STRING "Windows Phone 8") + else() + set(WINDOWS TRUE) + set(SYSTEM_STRING "Windows Desktop") + endif() +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + if(ANDROID) + set(SYSTEM_STRING "Android") + else() + set(LINUX TRUE) + set(SYSTEM_STRING "Linux") + endif() +elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + if(IOS) + set(SYSTEM_STRING "IOS") + else() + set(MACOSX TRUE) + set(SYSTEM_STRING "Mac OSX") + endif() +endif() + +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set(COMPILER_STRING ${CMAKE_CXX_COMPILER_ID}) + set(CLANG TRUE) +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if(MINGW) + set(COMPILER_STRING "Mingw GCC") + else() + set(COMPILER_STRING "GCC") + endif() +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") + set(COMPILER_STRING "${CMAKE_CXX_COMPILER_ID} C++") +elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set(COMPILER_STRING "Visual Studio C++") +endif() + +if(CMAKE_CROSSCOMPILING) + set(BUILDING_STRING "It appears you are cross compiling for ${SYSTEM_STRING} with ${COMPILER_STRING}") +else() + set(BUILDING_STRING "It appears you are builing natively for ${SYSTEM_STRING} with ${COMPILER_STRING}") +endif() diff --git a/build/build-mingw32-clang-make.sh b/build/build-mingw32-clang-make.sh deleted file mode 100644 index acf5961c03..0000000000 --- a/build/build-mingw32-clang-make.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# msys2 Pacman Manager for cocos2d-x - -#/**************************************************************************** -# Copyright (c) 2013-2014 Martell Malone -# -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# ****************************************************************************/ - -set -e - -THISDIR="$(dirname $0)" -test "$THISDIR" = "." && THISDIR=${PWD} -OSTYPE=${OSTYPE//[0-9.]/} -HOST_ARCH=$(uname -m) - -if [ "${HOST_ARCH}" = "i686" ]; then - BITS=32 -elif [ "${HOST_ARCH}" = "x86_64" ]; then - BITS=64 -fi - -if [ "${OSTYPE}" = "msys" ]; then - - CC=clang - CXX=clang++ - PP=mingw-w64-${HOST_ARCH} - - MINGW_PACKAGES=(glfw glew libwebp libjpeg-turbo libpng freetype libiconv zlib curl - make clang binutils headers cmake) - - MINGW_PACKAGES=(${MINGW_PACKAGES[@]/#/${PP}-}) - - pacman -S --force --noconfirm --needed ${MINGW_PACKAGES[@]} - - mkdir -p mingw${BITS}-clang && cd mingw${BITS}-clang - - export PATH=/mingw${BITS}/bin:${PATH} - - cmake -G"MinGW Makefiles" -DCMAKE_MAKE_PROGRAM="mingw32-make" \ - -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" ../.. - - mingw32-make -fi diff --git a/build/build-mingw32-gcc-make.sh b/build/build-mingw32-gcc-make.sh deleted file mode 100644 index 09b0313791..0000000000 --- a/build/build-mingw32-gcc-make.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash - -# msys2 Pacman Manager for cocos2d-x - -#/**************************************************************************** -# Copyright (c) 2012-2013 Martell Malone -# -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -# ****************************************************************************/ - -set -e - -THISDIR="$(dirname $0)" -test "$THISDIR" = "." && THISDIR=${PWD} -OSTYPE=${OSTYPE//[0-9.]/} -HOST_ARCH=$(uname -m) - -if [ "${HOST_ARCH}" = "i686" ]; then - BITS=32 -elif [ "${HOST_ARCH}" = "x86_64" ]; then - BITS=64 -fi - -if [ "${OSTYPE}" = "msys" ]; then - - CC=${HOST_ARCH}-w64-mingw32-gcc - CXX=${HOST_ARCH}-w64-mingw32-g++ - PP=mingw-w64-${HOST_ARCH} - - MINGW_PACKAGES=(glfw glew libwebp libjpeg-turbo libpng freetype libiconv zlib curl - make gcc binutils headers cmake) - - MINGW_PACKAGES=(${MINGW_PACKAGES[@]/#/${PP}-}) - - pacman -S --force --noconfirm --needed ${MINGW_PACKAGES[@]} - - mkdir -p mingw${BITS} && cd mingw${BITS} - - export PATH=/mingw${BITS}/bin:${PATH} - - cmake -G"MinGW Makefiles" -DCMAKE_MAKE_PROGRAM="mingw32-make" \ - -DCMAKE_C_COMPILER="${CC}" -DCMAKE_CXX_COMPILER="${CXX}" ../.. - - mingw32-make -fi diff --git a/cocos/2d/CMakeLists.txt b/cocos/2d/CMakeLists.txt index 2a7ac4d6e6..dbe25302c9 100644 --- a/cocos/2d/CMakeLists.txt +++ b/cocos/2d/CMakeLists.txt @@ -1,9 +1,3 @@ -if(WIN32) - -ADD_DEFINITIONS(-DUNICODE -D_UNICODE) - -endif() - include_directories( ../external/ConvertUTF ) @@ -76,4 +70,3 @@ set(COCOS_2D_SRC 2d/CCTransitionProgress.cpp 2d/CCTweenFunction.cpp ) - diff --git a/cocos/3d/CMakeLists.txt b/cocos/3d/CMakeLists.txt index 20234fe030..ea4d614703 100644 --- a/cocos/3d/CMakeLists.txt +++ b/cocos/3d/CMakeLists.txt @@ -13,4 +13,3 @@ set(COCOS_3D_SRC 3d/CCMeshSkin.cpp 3d/CCBundleReader.cpp ) - diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index 1479931bc8..ea7c654d91 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -1,11 +1,8 @@ -if(WIN32) -ADD_DEFINITIONS(-DUNICODE -D_UNICODE) +if(WINDOWS) + ADD_DEFINITIONS(-DUNICODE -D_UNICODE) endif() - -set(COCOS_SRC - cocos2d.cpp -) +set(COCOS_SRC cocos2d.cpp) include(2d/CMakeLists.txt) include(3d/CMakeLists.txt) @@ -34,60 +31,12 @@ add_library(cocos2d STATIC ${COCOS_DEPRECATED_SRC} ) -if(WIN32) - if(MINGW) - -set(COCOS_LINK - z - jpeg - png - webp - tiff - glfw3 - glew32 - opengl32 - iconv - freetype - bz2 - ) - -else() - - -set(COCOS_LINK - libjpeg - libpng - libwebp - libtiff - freetype250 - glfw3 - glew32 - opengl32 - libiconv - libzlib - ) - -endif() - -elseif(APPLE) - -else() -set(COCOS_LINK - jpeg - webp - tiff - freetype - fontconfig - png - pthread - glfw - GLEW - GL - X11 - rt - z -) + set(COCOS_LINK z jpeg png webp tiff glfw3 glew32 opengl32 iconv freetype bz2) +elseif(WINDOWS) + set(COCOS_LINK libjpeg libpng libwebp libtiff freetype250 glfw3 glew32 opengl32 libiconv libzlib) +elseif(LINUX) + set(COCOS_LINK jpeg webp tiff freetype fontconfig png pthread glfw GLEW GL X11 rt z) endif() target_link_libraries(cocos2d @@ -105,4 +54,3 @@ set_target_properties(cocos2d ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) - diff --git a/cocos/audio/CMakeLists.txt b/cocos/audio/CMakeLists.txt index 42ebc3a9a7..c2e15dfaa8 100644 --- a/cocos/audio/CMakeLists.txt +++ b/cocos/audio/CMakeLists.txt @@ -1,29 +1,26 @@ # architecture -if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) -set(ARCH_DIR "64-bit") -else() -set(ARCH_DIR "32-bit") -endif() +#if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) +#set(ARCH_DIR "64-bit") +#else() +#set(ARCH_DIR "32-bit") +#endif() -if(WIN32) +if(WINDOWS) set(AUDIO_SRC win32/SimpleAudioEngine.cpp win32/MciPlayer.cpp - win32/MciPlayer.h + win32/MciPlayer.h ) -elseif(APPLE) -else() +elseif(LINUX) set(AUDIO_SRC linux/SimpleAudioEngineFMOD.cpp linux/FmodAudioPlayer.cpp - linux/FmodAudioPlayer.h - linux/AudioPlayer.h + linux/FmodAudioPlayer.h + linux/AudioPlayer.h ) - include_directories( - ../../external/linux-specific/fmod/include/${ARCH_DIR} - ) + include_directories( ../../external/linux-specific/fmod/include/${ARCH_DIR} ) endif() @@ -33,28 +30,23 @@ add_library(audio STATIC include/SimpleAudioEngine.h ) -if((NOT APPLE) AND (NOT WIN32)) +if(LINUX) -if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) -set(FMOD_LIB "fmodex64") -else() -set(FMOD_LIB "fmodex") + if ( CMAKE_SIZEOF_VOID_P EQUAL 8 ) + set(FMOD_LIB "fmodex64") + else() + set(FMOD_LIB "fmodex") + endif() + + target_link_libraries(audio ${FMOD_LIB}) +elseif(WINDOWS) + target_link_libraries(audio Winmm) endif() -target_link_libraries(audio - ${FMOD_LIB} -) - set_target_properties(audio PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) -elseif(WIN32) -target_link_libraries(audio - Winmm -) - -endif() diff --git a/cocos/editor-support/cocosbuilder/CMakeLists.txt b/cocos/editor-support/cocosbuilder/CMakeLists.txt index 6d41d29579..607c85be8e 100644 --- a/cocos/editor-support/cocosbuilder/CMakeLists.txt +++ b/cocos/editor-support/cocosbuilder/CMakeLists.txt @@ -23,17 +23,12 @@ set(CCB_SRC CCNode+CCBRelativePositioning.cpp ) -include_directories( - .. -) +include_directories( .. ) -add_library(cocosbuilder STATIC - ${CCB_SRC} -) +add_library(cocosbuilder STATIC ${CCB_SRC}) set_target_properties(cocosbuilder PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" ) - diff --git a/cocos/editor-support/cocostudio/CMakeLists.txt b/cocos/editor-support/cocostudio/CMakeLists.txt index aa662393ef..fc722a7c7b 100644 --- a/cocos/editor-support/cocostudio/CMakeLists.txt +++ b/cocos/editor-support/cocostudio/CMakeLists.txt @@ -55,16 +55,11 @@ set(CS_SRC ActionTimeline/CCTimeLine.cpp ) -include_directories( - .. -) +include_directories( .. ) -add_library(cocostudio STATIC - ${CS_SRC} -) +add_library(cocostudio STATIC ${CS_SRC} ) -target_link_libraries(cocostudio -) +target_link_libraries(cocostudio) set_target_properties(cocostudio PROPERTIES diff --git a/cocos/editor-support/spine/CMakeLists.txt b/cocos/editor-support/spine/CMakeLists.txt index c3d96e8b61..4ce0a73646 100644 --- a/cocos/editor-support/spine/CMakeLists.txt +++ b/cocos/editor-support/spine/CMakeLists.txt @@ -32,13 +32,9 @@ set(SPINE_SRC SkeletonBounds.cpp ) -include_directories( - .. -) +include_directories( .. ) -add_library(spine STATIC - ${SPINE_SRC} -) +add_library(spine STATIC ${SPINE_SRC}) set_target_properties(spine PROPERTIES diff --git a/cocos/network/CMakeLists.txt b/cocos/network/CMakeLists.txt index 5bcf40d79e..38f0ff9a53 100644 --- a/cocos/network/CMakeLists.txt +++ b/cocos/network/CMakeLists.txt @@ -1,37 +1,13 @@ -if(WIN32) - set(PLATFORM_SRC - network/WebSocket.cpp - ) - - set(PLATFORM_LINK - websockets - ) -elseif(NOT APPLE) - set(PLATFORM_SRC - network/WebSocket.cpp - ) - - set(PLATFORM_LINK - websockets - ssl - crypto - ) +if(WINDOWS) + set(PLATFORM_LINK websockets) +elseif(LINUX) + set(PLATFORM_LINK websockets ssl crypto) endif() -set(COCOS_NETWORK_SRC - network/HttpClient.cpp - network/SocketIO.cpp - ${PLATFORM_SRC} -) +set(COCOS_NETWORK_SRC network/HttpClient.cpp network/SocketIO.cpp network/WebSocket.cpp) -IF (WIN32 AND NOT MINGW) - set(COCOS_NETWORK_LINK - libcurl_imp - ${PLATFORM_LINK} - ) -ELSE() - set(COCOS_NETWORK_LINK - curl - ${PLATFORM_LINK} - ) -ENDIF() +if(MSVC) + set(COCOS_NETWORK_LINK libcurl_imp ${PLATFORM_LINK}) +else() + set(COCOS_NETWORK_LINK curl ${PLATFORM_LINK} ) +endif() diff --git a/cocos/platform/win32/CCDevice.cpp b/cocos/platform/win32/CCDevice.cpp index 70f7f1d1c7..f6bce3bac5 100644 --- a/cocos/platform/win32/CCDevice.cpp +++ b/cocos/platform/win32/CCDevice.cpp @@ -405,7 +405,8 @@ Data Device::getTextureDataForText(const char * text, const FontDefinition& text } // draw text - SIZE size = {textDefinition._dimensions.width, textDefinition._dimensions.height}; + // does changing to SIZE here affects the font size by rounding from float? + SIZE size = {(LONG) textDefinition._dimensions.width,(LONG) textDefinition._dimensions.height}; CC_BREAK_IF(! dc.drawText(text, size, align)); int dataLen = size.cx * size.cy * 4; diff --git a/cocos/platform/win32/CCStdC.h b/cocos/platform/win32/CCStdC.h index ad0be3dc4d..1a4de0d996 100644 --- a/cocos/platform/win32/CCStdC.h +++ b/cocos/platform/win32/CCStdC.h @@ -124,12 +124,14 @@ inline int vsnprintf_s(char *buffer, size_t sizeOfBuffer, size_t count, const char *format, va_list argptr) { return vsnprintf(buffer, sizeOfBuffer, format, argptr); } + +#ifndef __clang__ inline errno_t strcpy_s(char *strDestination, size_t numberOfElements, const char *strSource) { strcpy(strDestination, strSource); return 0; } - +#endif #endif // __MINGW32__ // Conflicted with cocos2d::MessageBox, so we need to undef it. diff --git a/cocos/renderer/CMakeLists.txt b/cocos/renderer/CMakeLists.txt index b86e1aed6c..fd794aa25d 100644 --- a/cocos/renderer/CMakeLists.txt +++ b/cocos/renderer/CMakeLists.txt @@ -16,4 +16,3 @@ set(COCOS_RENDERER_SRC renderer/CCTextureAtlas.cpp renderer/CCTextureCache.cpp ) - diff --git a/cocos/storage/CMakeLists.txt b/cocos/storage/CMakeLists.txt index 68f06b7a0f..180df106ae 100644 --- a/cocos/storage/CMakeLists.txt +++ b/cocos/storage/CMakeLists.txt @@ -1,9 +1,2 @@ - -set(COCOS_STORAGE_SRC - storage/local-storage/LocalStorage.cpp - ) - -set(COCOS_STORAGE_LINK - sqlite3 -) - +set(COCOS_STORAGE_SRC storage/local-storage/LocalStorage.cpp) +set(COCOS_STORAGE_LINK sqlite3 ) diff --git a/cocos/ui/CMakeLists.txt b/cocos/ui/CMakeLists.txt index 02829ab86a..5457fd19be 100644 --- a/cocos/ui/CMakeLists.txt +++ b/cocos/ui/CMakeLists.txt @@ -24,4 +24,3 @@ set(COCOS_UI_SRC ui/UIDeprecated.cpp ui/UIScale9Sprite.cpp ) - diff --git a/tests/cpp-empty-test/CMakeLists.txt b/tests/cpp-empty-test/CMakeLists.txt index 88ebaceb4e..8221cc32c1 100644 --- a/tests/cpp-empty-test/CMakeLists.txt +++ b/tests/cpp-empty-test/CMakeLists.txt @@ -1,34 +1,38 @@ set(APP_NAME cpp-empty-test) -if(QT) - set(PLATFORM_SRC - proj.qt/main.cpp - ) -elseif(ANDROID) +if(ANDROID) + set(PLATFORM_SRC proj.android/jni/hellocpp/main.cpp ) -elseif(WIN32) + +elseif(WINDOWS) + set(PLATFORM_SRC proj.win32/main.cpp ) -elseif(APPLE) - if(IOS) - set(PLATFORM_SRC - proj.ios/main.m - proj.ios/AppController.mm - proj.ios/RootViewController.mm - ) - else() - set(PLATFORM_SRC - proj.mac/main.m - ) - endif() -else() + +elseif(IOS) + + set(PLATFORM_SRC + proj.ios/main.m + proj.ios/AppController.mm + proj.ios/RootViewController.mm + ) + +elseif(MACOSX) + + set(PLATFORM_SRC + proj.mac/main.m + ) + +elseif(LINUX) + set(PLATFORM_SRC proj.linux/main.cpp ) - endif() + +endif() set(SAMPLE_SRC ${PLATFORM_SRC} @@ -41,7 +45,8 @@ add_executable(${APP_NAME} ${SAMPLE_SRC} ) -if(WIN32 AND MSVC) +if(MSVC) + #get our resources add_custom_command(TARGET ${APP_NAME} PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory @@ -60,7 +65,9 @@ if(WIN32 AND MSVC) #Visual Studio Defaults to wrong type set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") set_target_properties(${APP_NAME} PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") + else() + set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin/${APP_NAME}") set_target_properties(${APP_NAME} PROPERTIES