diff --git a/templates/cpp-template-default/CMakeLists.txt b/templates/cpp-template-default/CMakeLists.txt index 3c4a78b805..5fb54f22a2 100644 --- a/templates/cpp-template-default/CMakeLists.txt +++ b/templates/cpp-template-default/CMakeLists.txt @@ -36,7 +36,12 @@ if(XCODE) endif() if(NOT DEFINED BUILD_ENGINE_DONE) # to test HelloCpp into root project - set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d) + if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) + message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") + set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") + else + message(FATAL_ERROR "Please add system env var 'COCOS2DX_ROOT' to specific the engine root") + endif() set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) include(CocosBuildSet) diff --git a/templates/lua-template-default/CMakeLists.txt b/templates/lua-template-default/CMakeLists.txt index ba776c86ff..947926916d 100644 --- a/templates/lua-template-default/CMakeLists.txt +++ b/templates/lua-template-default/CMakeLists.txt @@ -33,8 +33,15 @@ if(XCODE) endif() endif() +if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) + message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") + set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") +else + message(FATAL_ERROR "Please add system env var 'COCOS2DX_ROOT' to specific the engine root") +endif() + set(RUNTIME_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/runtime-src) -set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/cocos2d-x) + set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) include(CocosBuildSet) diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 7520723195..df8e1e6a70 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -11,7 +11,13 @@ if(XCODE) endif() if(NOT DEFINED BUILD_ENGINE_DONE) - set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..) + if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) + message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") + set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") + else + set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..) + endif() + set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) include(CocosBuildSet) diff --git a/tests/fairygui-tests/CMakeLists.txt b/tests/fairygui-tests/CMakeLists.txt index 47b48b373a..eccc3a5de8 100644 --- a/tests/fairygui-tests/CMakeLists.txt +++ b/tests/fairygui-tests/CMakeLists.txt @@ -34,7 +34,12 @@ if(XCODE) endif() if(NOT DEFINED BUILD_ENGINE_DONE) - set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..) + if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) + message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") + set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") + else + set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..) + endif() set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) include(CocosBuildSet) diff --git a/tests/lua-tests/project/CMakeLists.txt b/tests/lua-tests/project/CMakeLists.txt index 5b755e9537..30edc9f281 100644 --- a/tests/lua-tests/project/CMakeLists.txt +++ b/tests/lua-tests/project/CMakeLists.txt @@ -11,7 +11,12 @@ if(XCODE) endif() if(NOT DEFINED BUILD_ENGINE_DONE) - set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../..) + if(NOT ("$ENV{COCOS2DX_ROOT}" STREQUAL "")) + message(STATUS "Using system env var COCOS2DX_ROOT=$ENV{COCOS2DX_ROOT}") + set(COCOS2DX_ROOT_PATH "$ENV{COCOS2DX_ROOT}") + else + set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../..) + endif() set(CMAKE_MODULE_PATH ${COCOS2DX_ROOT_PATH}/cmake/Modules/) include(CocosBuildSet)