diff --git a/.gitmodules b/.gitmodules index 533fba78a..dd37435a0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,11 @@ [submodule "external/entt"] path = external/entt url = git://github.com/Unarelith/entt.git + ignore = dirty +[submodule "external/SFML"] + path = external/SFML + url = git://github.com/SFML/SFML.git + ignore = dirty +[submodule "external/gamekit"] + path = external/gamekit + url = git://github.com/Unarelith/GameKit.git diff --git a/CMakeLists.txt b/CMakeLists.txt index d50dd9470..3a893d60c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,8 @@ endif () set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) +include_directories(external) + #------------------------------------------------------------------------------ # Compiler flags #------------------------------------------------------------------------------ @@ -55,21 +57,6 @@ endif() include_directories(${LUA_INCLUDE_DIR}) link_directories(${LUA_LIBRARY_DIRS}) -#------------------------------------------------------------------------------ -# - gamekit -#------------------------------------------------------------------------------ -if (WIN32) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/gamekit) -endif () - -find_package(GameKit REQUIRED) - -if(NOT GAMEKIT_FOUND) - message(FATAL_ERROR "gamekit is needed to build the project. Please install it correctly.") -endif() - -include_directories(${GAMEKIT_INCLUDE_DIR}) - #------------------------------------------------------------------------------ # - tinyxml2 #------------------------------------------------------------------------------ @@ -148,25 +135,6 @@ include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_MIXER_INCLUDE_DIRS} ${SDL2_TTF_INCLUDE_DIRS}) -#------------------------------------------------------------------------------ -# - SFML network -#------------------------------------------------------------------------------ -if (WIN32) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/SFML) -endif () - -if (MINGW) - set(SFML_STATIC_LIBRARIES TRUE) -endif () - -find_package(SFML COMPONENTS system network) - -if(NOT SFML_FOUND) - message(FATAL_ERROR "SFML is needed to build the project. Please install it correctly.") -endif() - -include_directories(${SFML_INCLUDE_DIRS}) - #------------------------------------------------------------------------------ # - GLEW #------------------------------------------------------------------------------ @@ -183,10 +151,53 @@ if (WIN32) endif () #------------------------------------------------------------------------------ -# Subdirectories +# Submodules +# from https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html +#------------------------------------------------------------------------------ +find_package(Git QUIET) + +if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + option(GIT_SUBMODULE "Check submodules during build" ON) + if(GIT_SUBMODULE) + message(STATUS "Submodule update") + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT) + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update --init failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") + endif() + endif() +endif() + +if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/gamekit/CMakeLists.txt") + message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") +endif() + +#------------------------------------------------------------------------------ +# - EnTT #------------------------------------------------------------------------------ add_subdirectory(external/entt) +include_directories(external/entt/single_include) + +#------------------------------------------------------------------------------ +# - gamekit +#------------------------------------------------------------------------------ +add_subdirectory(external/gamekit) + +#------------------------------------------------------------------------------ +# - SFML network +#------------------------------------------------------------------------------ +set(SFML_BUILD_AUDIO FALSE) +set(SFML_BUILD_GRAPHICS FALSE) +set(SFML_BUILD_WINDOW FALSE) +set(BUILD_SHARED_LIBS ON) + +add_subdirectory(external/SFML) + +#------------------------------------------------------------------------------ +# Subdirectories +#------------------------------------------------------------------------------ add_subdirectory(source/common) add_subdirectory(source/server) add_subdirectory(source/client) diff --git a/external/SFML b/external/SFML new file mode 160000 index 000000000..50e173e40 --- /dev/null +++ b/external/SFML @@ -0,0 +1 @@ +Subproject commit 50e173e403ef8912e3d8ac3c7ab3e27e32243339 diff --git a/external/gamekit b/external/gamekit new file mode 160000 index 000000000..d39510fa3 --- /dev/null +++ b/external/gamekit @@ -0,0 +1 @@ +Subproject commit d39510fa3920197ddff588aacf5a15175e67887a diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 17eb259a1..ad7b23ae2 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -9,8 +9,6 @@ set(PROJECT_NAME ${CMAKE_PROJECT_NAME}) file(GLOB_RECURSE SOURCE_FILES *.cpp) file(GLOB_RECURSE HEADER_FILES *.hpp ../server/*.hpp ../common/*.hpp) -include_directories(../../external ../../external/entt/single_include) - foreach(HEADER_FILE ${HEADER_FILES}) get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY) include_directories(${HEADER_DIRECTORY}) diff --git a/source/common/CMakeLists.txt b/source/common/CMakeLists.txt index bfadc9203..a86c3abea 100644 --- a/source/common/CMakeLists.txt +++ b/source/common/CMakeLists.txt @@ -9,8 +9,6 @@ set(PROJECT_NAME ${CMAKE_PROJECT_NAME}_common) file(GLOB_RECURSE SOURCE_FILES *.cpp) file(GLOB_RECURSE HEADER_FILES *.hpp) -include_directories(../../external ../../external/entt/single_include) - foreach(HEADER_FILE ${HEADER_FILES}) get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY) include_directories(${HEADER_DIRECTORY}) @@ -20,7 +18,7 @@ endforeach(HEADER_FILE) # Add library #------------------------------------------------------------------------------ add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) -add_dependencies(${PROJECT_NAME} EnTT) +add_dependencies(${PROJECT_NAME} EnTT sfml-network gamekit) #------------------------------------------------------------------------------ # Compiler flags