Skip to content

modern cmake, cmake_cleanup_remove_unused_variables #19146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions cmake/Modules/CocosBuildSet.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# Disable in-source builds to prevent source tree corruption.
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
Copy link
Contributor

@drelaptop drelaptop Nov 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest to keep this check, it will prevent In-source builds

or we can select to add a options set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

https://stackoverflow.com/questions/1208681/with-cmake-how-would-you-disable-in-source-builds

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we should not force on user that.
I propose to keep cmake files as simple as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all right, I will add set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) later into only <cocos2d-x-root>/CMakeLists.txt, not include tests project and template project.

message(FATAL_ERROR "
FATAL: In-source builds are not allowed.
You should create a separate directory for build files.
")
endif()

# print cmake debug info
set(CMAKE_DEBUG_TARGET_PROPERTIES
# INCLUDE_DIRECTORIES
Expand All @@ -14,29 +6,14 @@ set(CMAKE_DEBUG_TARGET_PROPERTIES
# AUTOUIC_OPTIONS
# POSITION_INDEPENDENT_CODE
)
# It ensures that when Find*.cmake files included from cmake's Modules dir
# include another *.cmake file with relative path, that file will be included
# also from cmake's Modules dir, to not clash with per-project files.
cmake_policy(SET CMP0017 NEW)

# Use new behaviour with cmake >= 3.1:
# Only interpret if() arguments as variables or keywords when unquoted.
cmake_policy(SET CMP0054 NEW)

# print the info of CMAKE_TOOLCHAIN_FILE, if defined it
if(DEFINED CMAKE_TOOLCHAIN_FILE)
message(STATUS "using toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
endif()

# some useful variables for every one cocos project
set(COCOS_EXTERNAL_DIR ${COCOS2DX_ROOT_PATH}/external)
set(ENGINE_BINARY_PATH ${PROJECT_BINARY_DIR}/engine)

message(STATUS "PROJECT_NAME:" ${PROJECT_NAME})
message(STATUS "PROJECT_SOURCE_DIR:" ${PROJECT_SOURCE_DIR})
message(STATUS "COCOS2DX_ROOT_PATH:" ${COCOS2DX_ROOT_PATH})
message(STATUS "CMAKE_MODULE_PATH:" ${CMAKE_MODULE_PATH})
message(STATUS "COCOS_EXTERNAL_DIR:" ${COCOS_EXTERNAL_DIR})
# delete binary dir if you hope a full clean re-build
message(STATUS "PROJECT_BINARY_DIR:" ${PROJECT_BINARY_DIR})
message(STATUS "ENGINE_BINARY_PATH:" ${ENGINE_BINARY_PATH})
Expand Down
30 changes: 0 additions & 30 deletions cmake/Modules/CocosConfigDefine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,23 @@
#LINUX = Linux
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS TRUE)
set(SYSTEM_STRING "Windows Desktop")
set(PLATFORM_FOLDER win32)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
set(SYSTEM_STRING "Android")
set(PLATFORM_FOLDER android)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if(ANDROID)
set(SYSTEM_STRING "Android")
set(PLATFORM_FOLDER android)
else()
set(LINUX TRUE)
set(SYSTEM_STRING "Linux")
set(PLATFORM_FOLDER linux)
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(IOS)
set(APPLE TRUE)
set(SYSTEM_STRING "IOS")
set(PLATFORM_FOLDER ios)
else()
set(APPLE TRUE)
set(MACOSX TRUE)
set(SYSTEM_STRING "Mac OSX")
set(PLATFORM_FOLDER mac)
endif()
else()
Expand Down Expand Up @@ -78,30 +72,6 @@ define_property(TARGET
FULL_DOCS "use to save depend libs of cocos2d lua project"
)

# check and print compiler infos
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++")
else()
set(COMPILER_STRING "${CMAKE_CXX_COMPILER_ID}")
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 building natively for ${SYSTEM_STRING} with ${COMPILER_STRING}")
endif()
message(STATUS ${BUILDING_STRING})

# check c++ standard
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
Expand Down