Skip to content

Commit

Permalink
Merge pull request #1001 from illwieckz/daemondir
Browse files Browse the repository at this point in the history
[cmake] make DAEMON_DIR an option, fix #1000
  • Loading branch information
illwieckz committed May 16, 2017
2 parents 497606b + 400d938 commit 9ab1546
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions CMakeLists.txt
Expand Up @@ -34,22 +34,36 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "Building in the source directory is not supported, try building in a 'build' directory. You may have to delete the CMakeCache.txt file and CMakeFiles directory that are next to the CMakeLists.txt.")
endif()

# Check if we need to initialize submodules
file(GLOB DENG_RESULT ${CMAKE_CURRENT_SOURCE_DIR}/daemon)
list(LENGTH ${DENG_RESULT} DENG_RES_LEN)
if(DENG_RES_LEN EQUAL 0)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
find_package(Git REQUIRED)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(SUBMODULE_LIST
"libs/libRocket"
"src/utils/cbse")

set(DAEMON_DIR_STRING "Path to the Daemon Engine source.")
if(NOT DAEMON_DIR)
set(DAEMON_DIR "${CMAKE_CURRENT_SOURCE_DIR}/daemon" CACHE STRING "${DAEMON_DIR_STRING}")
LIST(APPEND SUBMODULE_LIST "daemon")
else()
set(DAEMON_DIR "${DAEMON_DIR}" CACHE STRING "${DAEMON_DIR_STRING}")
endif()

foreach(SUBMODULE_PATH ${SUBMODULE_LIST})
# Check if we need to initialize submodule
file(GLOB DENG_RESULT "${CMAKE_CURRENT_SOURCE_DIR}/${SUBMODULE_PATH}")
list(LENGTH ${DENG_RESULT} DENG_RES_LEN)
if(DENG_RES_LEN EQUAL 0)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
find_package(Git REQUIRED)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive -- "${SUBMODULE_PATH}"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
endif()
endif()
endif()
endif()
endforeach()

set(Daemon_OUT ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(daemon daemon_build)
add_subdirectory("${DAEMON_DIR}" daemon_build)
include(DaemonGame)

set(LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs)
Expand Down

0 comments on commit 9ab1546

Please sign in to comment.