mirror of https://github.com/axmolengine/axmol.git
fix cmake win32 macro definitions, and improve (#18856)
* fix win32 macro error, improve cmake macro define * add more comments
This commit is contained in:
parent
cc145cb852
commit
1f1664ae27
|
@ -58,6 +58,7 @@
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# check and print compiler infos
|
||||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
set(COMPILER_STRING ${CMAKE_CXX_COMPILER_ID})
|
set(COMPILER_STRING ${CMAKE_CXX_COMPILER_ID})
|
||||||
set(CLANG TRUE)
|
set(CLANG TRUE)
|
||||||
|
@ -74,23 +75,17 @@
|
||||||
else()
|
else()
|
||||||
set(COMPILER_STRING "${CMAKE_CXX_COMPILER_ID}")
|
set(COMPILER_STRING "${CMAKE_CXX_COMPILER_ID}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_CROSSCOMPILING)
|
if(CMAKE_CROSSCOMPILING)
|
||||||
set(BUILDING_STRING "It appears you are cross compiling for ${SYSTEM_STRING} with ${COMPILER_STRING}")
|
set(BUILDING_STRING "It appears you are cross compiling for ${SYSTEM_STRING} with ${COMPILER_STRING}")
|
||||||
else()
|
else()
|
||||||
set(BUILDING_STRING "It appears you are building natively for ${SYSTEM_STRING} with ${COMPILER_STRING}")
|
set(BUILDING_STRING "It appears you are building natively for ${SYSTEM_STRING} with ${COMPILER_STRING}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message(STATUS ${BUILDING_STRING})
|
message(STATUS ${BUILDING_STRING})
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DCOCOS2D_DEBUG=1")
|
# Set compiler options
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
|
||||||
|
|
||||||
# Compiler options
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} /MDd")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /MD")
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrt /NODEFAULTLIB:libcmt")
|
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:msvcrt /NODEFAULTLIB:libcmt")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmt")
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmt")
|
||||||
|
|
||||||
|
@ -106,33 +101,37 @@
|
||||||
string(REGEX REPLACE "/Z[iI7]" "" CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG}")
|
string(REGEX REPLACE "/Z[iI7]" "" CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG}")
|
||||||
set(CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG} /Z7")
|
set(CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG} /Z7")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -Wall")
|
||||||
add_definitions(-DCOCOS2D_DEBUG=1)
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_C_FLAGS_DEBUG}")
|
||||||
endif()
|
|
||||||
set(CMAKE_C_FLAGS_DEBUG "-g -Wall")
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -fPIC")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -fPIC")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder -Wno-invalid-offsetof -fPIC")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-deprecated-declarations -Wno-reorder -Wno-invalid-offsetof -fPIC")
|
||||||
if(CLANG AND NOT ANDROID)
|
if(CLANG AND NOT ANDROID)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||||
endif()
|
endif()
|
||||||
if(CLANG AND ANDROID AND ANDROID_ARM_MODE STREQUAL thumb AND ANDROID_ABI STREQUAL armeabi)
|
# specail options for android
|
||||||
string(REPLACE "-mthumb" "-marm" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
if(ANDROID)
|
||||||
string(REPLACE "-mthumb" "-marm" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -fexceptions")
|
||||||
|
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} -latomic")
|
||||||
|
if(CLANG AND ANDROID_ARM_MODE STREQUAL thumb AND ANDROID_ABI STREQUAL armeabi)
|
||||||
|
string(REPLACE "-mthumb" "-marm" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||||
|
string(REPLACE "-mthumb" "-marm" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif(MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
# Some macro definitions
|
# Set common macro definitions
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
add_definitions(-DCOCOS2D_DEBUG=1)
|
||||||
|
endif()
|
||||||
|
# Set macro definitions for special platforms
|
||||||
if(WINDOWS)
|
if(WINDOWS)
|
||||||
|
|
||||||
if(BUILD_SHARED_LIBS)
|
if(BUILD_SHARED_LIBS)
|
||||||
add_definitions(-D_USRDLL -D_EXPORT_DLL_ -D_USEGUIDLL -D_USREXDLL -D_USRSTUDIODLL)
|
add_definitions(-D_USRDLL -D_EXPORT_DLL_ -D_USEGUIDLL -D_USREXDLL -D_USRSTUDIODLL)
|
||||||
else()
|
else()
|
||||||
add_definitions(-DCC_STATIC)
|
add_definitions(-DCC_STATIC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32 -D_WIN32)
|
add_definitions(-DCOCOS2DXWIN32_EXPORTS -D_WINDOWS -DWIN32 -D_WIN32)
|
||||||
set(PLATFORM_FOLDER win32)
|
set(PLATFORM_FOLDER win32)
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
|
@ -141,27 +140,16 @@
|
||||||
add_definitions(-DTARGET_OS_MAC)
|
add_definitions(-DTARGET_OS_MAC)
|
||||||
set(PLATFORM_FOLDER mac)
|
set(PLATFORM_FOLDER mac)
|
||||||
elseif(IOS)
|
elseif(IOS)
|
||||||
# TARGET_OS_IOS
|
add_definitions(-DTARGET_OS_IPHONE)
|
||||||
# add_definitions(-DTARGET_OS_IPHONE)
|
|
||||||
add_definitions(-DTARGET_OS_IOS)
|
add_definitions(-DTARGET_OS_IOS)
|
||||||
set(PLATFORM_FOLDER ios)
|
set(PLATFORM_FOLDER ios)
|
||||||
endif(MACOSX)
|
endif(MACOSX)
|
||||||
|
|
||||||
elseif(LINUX)
|
elseif(LINUX)
|
||||||
add_definitions(-DLINUX)
|
add_definitions(-DLINUX)
|
||||||
set(PLATFORM_FOLDER linux)
|
set(PLATFORM_FOLDER linux)
|
||||||
elseif(ANDROID)
|
elseif(ANDROID)
|
||||||
add_definitions(-DUSE_FILE32API)
|
add_definitions(-DUSE_FILE32API)
|
||||||
set(PLATFORM_FOLDER android)
|
set(PLATFORM_FOLDER android)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsigned-char -fexceptions")
|
|
||||||
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} -latomic")
|
|
||||||
|
|
||||||
if(CLANG AND ANDROID_ARM_MODE STREQUAL thumb AND ANDROID_ABI STREQUAL armeabi)
|
|
||||||
string(REPLACE "-mthumb" "-marm" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
|
||||||
string(REPLACE "-mthumb" "-marm" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unsupported platform, CMake will exit")
|
message(FATAL_ERROR "Unsupported platform, CMake will exit")
|
||||||
return()
|
return()
|
||||||
|
@ -172,6 +160,7 @@
|
||||||
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${COCOS_EXTERNAL_DIR})
|
set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${COCOS_EXTERNAL_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# extra config for windows
|
||||||
if(WINDOWS)
|
if(WINDOWS)
|
||||||
# folder much targets
|
# folder much targets
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
@ -194,11 +183,10 @@
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# check use prebuilt config
|
# check prebuilt config
|
||||||
if(GEN_COCOS_PREBUILT AND USE_COCOS_PREBUILT)
|
if(GEN_COCOS_PREBUILT AND USE_COCOS_PREBUILT)
|
||||||
message(FATAL_ERROR "can't generate prebuilt libs and use prebuilt libs at the same time")
|
message(FATAL_ERROR "can't generate prebuilt libs and use prebuilt libs at the same time")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GEN_COCOS_PREBUILT OR USE_COCOS_PREBUILT)
|
if(GEN_COCOS_PREBUILT OR USE_COCOS_PREBUILT)
|
||||||
if(DEFINED COCOS_PREBUILT_ROOT)
|
if(DEFINED COCOS_PREBUILT_ROOT)
|
||||||
message(STATUS "pre-defined COCOS_PREBUILT_ROOT: ${COCOS_PREBUILT_ROOT}")
|
message(STATUS "pre-defined COCOS_PREBUILT_ROOT: ${COCOS_PREBUILT_ROOT}")
|
||||||
|
|
Loading…
Reference in New Issue