Add CMake macro BUILD_TESTS=OFF to support exclude all tests project

This commit is contained in:
halx99 2021-04-24 22:47:37 +08:00
parent 540c9375ff
commit 5ab0b04d01
1 changed files with 17 additions and 13 deletions

View File

@ -40,6 +40,8 @@ include(PreventInSourceBuilds)
# works before build libcocos2d
include(CocosBuildSet)
option(BUILD_TESTS "Build cpp & lua tests" ON)
set(BUILD_LUA_LIBS ON)
add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)
@ -47,18 +49,20 @@ add_subdirectory(${COCOS2DX_ROOT_PATH}/cocos ${ENGINE_BINARY_PATH}/cocos/core)
# prevent tests project to build "cocos2d-x/cocos" again
set(BUILD_ENGINE_DONE ON)
# add cpp tests default
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/cpp-empty-test ${ENGINE_BINARY_PATH}/tests/cpp-empty-test)
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/cpp-tests ${ENGINE_BINARY_PATH}/tests/cpp-tests)
if(BUILD_TESTS)
# add cpp tests default
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/cpp-empty-test ${ENGINE_BINARY_PATH}/tests/cpp-empty-test)
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/cpp-tests ${ENGINE_BINARY_PATH}/tests/cpp-tests)
if(BUILD_EXTENSION_FAIRYGUI)
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/fairygui-tests ${ENGINE_BINARY_PATH}/tests/fairygui-tests)
if(BUILD_EXTENSION_FAIRYGUI)
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/fairygui-tests ${ENGINE_BINARY_PATH}/tests/fairygui-tests)
endif()
if(BUILD_LUA_LIBS)
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/lua-empty-test/project ${ENGINE_BINARY_PATH}/tests/lua-empty-test)
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/lua-tests/project ${ENGINE_BINARY_PATH}/tests/lua-test)
endif(BUILD_LUA_LIBS)
# add cpp-template-default into project(Cocos2d-x) for tmp test
add_subdirectory(${COCOS2DX_ROOT_PATH}/templates/cpp-template-default ${ENGINE_BINARY_PATH}/tests/HelloCpp)
endif()
if(BUILD_LUA_LIBS)
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/lua-empty-test/project ${ENGINE_BINARY_PATH}/tests/lua-empty-test)
add_subdirectory(${COCOS2DX_ROOT_PATH}/tests/lua-tests/project ${ENGINE_BINARY_PATH}/tests/lua-test)
endif(BUILD_LUA_LIBS)
# add cpp-template-default into project(Cocos2d-x) for tmp test
add_subdirectory(${COCOS2DX_ROOT_PATH}/templates/cpp-template-default ${ENGINE_BINARY_PATH}/tests/HelloCpp)