Skip to content

Commit

Permalink
SFML and GameKit are now used as git submodules.
Browse files Browse the repository at this point in the history
  • Loading branch information
Unarelith committed Apr 13, 2020
1 parent fd7f880 commit 096a9d3
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 40 deletions.
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
81 changes: 46 additions & 35 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ endif ()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

include_directories(external)

#------------------------------------------------------------------------------
# Compiler flags
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -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
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -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
#------------------------------------------------------------------------------
Expand All @@ -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)
1 change: 1 addition & 0 deletions external/SFML
Submodule SFML added at 50e173
1 change: 1 addition & 0 deletions external/gamekit
Submodule gamekit added at d39510
2 changes: 0 additions & 2 deletions source/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
4 changes: 1 addition & 3 deletions source/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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
Expand Down

0 comments on commit 096a9d3

Please sign in to comment.