From 12aaad6c504b8939abb7b92ea4c083b86985c622 Mon Sep 17 00:00:00 2001 From: Quentin Bazin Date: Fri, 22 May 2020 16:18:34 +0200 Subject: [PATCH] All dependencies are now included as submodules. Fixes #101. --- .gitmodules | 3 ++ CMakeLists.txt | 66 +++--------------------------------- cmake/FindGLM.cmake | 53 ----------------------------- cmake/FindTinyXml2.cmake | 16 --------- external/gamekit | 2 +- external/lua | 1 + source/client/CMakeLists.txt | 9 ++--- source/common/CMakeLists.txt | 15 ++++++-- source/server/CMakeLists.txt | 14 +++++--- 9 files changed, 37 insertions(+), 142 deletions(-) delete mode 100644 cmake/FindGLM.cmake delete mode 100644 cmake/FindTinyXml2.cmake create mode 160000 external/lua diff --git a/.gitmodules b/.gitmodules index 51dde7929..6c731cec7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ path = external/sol2 url = https://github.com/ThePhD/sol2.git ignore = dirty +[submodule "external/lua"] + path = external/lua + url = https://github.com/walterschell/Lua.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 51f73ad93..04b04366c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,10 +9,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -if (WIN32) - set(WIN_LIBRARIES_PATH "C:/Libraries") -endif () - if (APPLE) add_definitions(-DGL_SILENCE_DEPRECATION=1) endif () @@ -45,74 +41,17 @@ endif() #------------------------------------------------------------------------------ # Packages -#------------------------------------------------------------------------------ -# - Lua -#------------------------------------------------------------------------------ -if (WIN32) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/lua) -endif () - -find_package(Lua REQUIRED) - -if(NOT LUA_FOUND) - message(FATAL_ERROR "Lua is needed to build the project. Please install it correctly.") -endif() - -include_directories(${LUA_INCLUDE_DIR}) -link_directories(${LUA_LIBRARY_DIRS}) - -#------------------------------------------------------------------------------ -# - tinyxml2 -#------------------------------------------------------------------------------ -if (WIN32) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/tinyxml2) -endif () - -find_package(TinyXml2 REQUIRED) - -if(NOT TINYXML2_FOUND) - message(FATAL_ERROR "tinyxml2 is needed to build the project. Please install it correctly.") -endif() - -include_directories(${TINYXML2_INCLUDE_DIRS}) - #------------------------------------------------------------------------------ # - OpenGL #------------------------------------------------------------------------------ set(OpenGL_GL_PREFERENCE "LEGACY") -if (WIN32) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/glm) -endif () - find_package(OpenGL REQUIRED) -find_package(GLM REQUIRED) if(NOT OPENGL_FOUND) message(FATAL_ERROR "OpenGL not found!") endif(NOT OPENGL_FOUND) -if(NOT GLM_FOUND) - message(FATAL_ERROR "glm not found!") -endif(NOT GLM_FOUND) - -include_directories(${GLM_INCLUDE_DIRS}) - -#------------------------------------------------------------------------------ -# - GLEW -#------------------------------------------------------------------------------ -if (WIN32) - set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${WIN_LIBRARIES_PATH}/glew) - - find_package(GLEW REQUIRED) - - if(NOT GLEW_FOUND) - message(FATAL_ERROR "GLEW not found!") - endif(NOT GLEW_FOUND) - - include_directories(${GLEW_INCLUDE_DIRS}) -endif () - #------------------------------------------------------------------------------ # Submodules # from https://cliutils.gitlab.io/modern-cmake/chapters/projects/submodule.html @@ -153,6 +92,11 @@ include_directories(external/gamekit/include) #------------------------------------------------------------------------------ add_subdirectory(external/zlib ${CMAKE_CURRENT_BINARY_DIR}/external/zlib) +#------------------------------------------------------------------------------ +# - lua +#------------------------------------------------------------------------------ +add_subdirectory(external/lua) + #------------------------------------------------------------------------------ # - sol3 (sol2 v3.x) #------------------------------------------------------------------------------ diff --git a/cmake/FindGLM.cmake b/cmake/FindGLM.cmake deleted file mode 100644 index 516dd3413..000000000 --- a/cmake/FindGLM.cmake +++ /dev/null @@ -1,53 +0,0 @@ -# -# Find GLM -# -# Try to find GLM : OpenGL Mathematics. -# This module defines -# - GLM_INCLUDE_DIRS -# - GLM_FOUND -# -# The following variables can be set as arguments for the module. -# - GLM_ROOT_DIR : Root library directory of GLM -# -# References: -# - https://github.com/Groovounet/glm/blob/master/util/FindGLM.cmake -# - https://bitbucket.org/alfonse/gltut/src/28636298c1c0/glm-0.9.0.7/FindGLM.cmake -# - -# Additional modules -include(FindPackageHandleStandardArgs) - -if (WIN32) - # Find include files - find_path( - GLM_INCLUDE_DIR - NAMES glm/glm.hpp - PATHS - $ENV{PROGRAMFILES}/include - ${GLM_ROOT_DIR}/include - DOC "The directory where glm/glm.hpp resides") -else() - # Find include files - find_path( - GLM_INCLUDE_DIR - NAMES glm/glm.hpp - PATHS - /usr/include - /usr/local/include - /sw/include - /opt/local/include - ${GLM_ROOT_DIR}/include - DOC "The directory where glm/glm.hpp resides") -endif() - -# Handle REQUIRD argument, define *_FOUND variable -find_package_handle_standard_args(GLM DEFAULT_MSG GLM_INCLUDE_DIR) - -# Define GLM_INCLUDE_DIRS -if (GLM_FOUND) - set(GLM_INCLUDE_DIRS ${GLM_INCLUDE_DIR}) -endif() - -# Hide some variables -mark_as_advanced(GLM_INCLUDE_DIR) - diff --git a/cmake/FindTinyXml2.cmake b/cmake/FindTinyXml2.cmake deleted file mode 100644 index e51aefef9..000000000 --- a/cmake/FindTinyXml2.cmake +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright (c) 2014 Andrew Kelley -# This file is MIT licensed. -# See http://opensource.org/licenses/MIT - -# TINYXML2_FOUND -# TINYXML2_INCLUDE_DIRS -# TINYXML2_LIBRARIES - -find_path(TINYXML2_INCLUDE_DIRS NAMES tinyxml2.h) -find_library(TINYXML2_LIBRARIES NAMES tinyxml2) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(TinyXml2 DEFAULT_MSG TINYXML2_LIBRARIES TINYXML2_INCLUDE_DIRS) - -mark_as_advanced(TINYXML2_INCLUDE_DIRS TINYXML2_LIBRARIES) - diff --git a/external/gamekit b/external/gamekit index d94eb4c68..77a1df07b 160000 --- a/external/gamekit +++ b/external/gamekit @@ -1 +1 @@ -Subproject commit d94eb4c68a9f7fd7f1ad12a933596b623ae8000c +Subproject commit 77a1df07bc321ee9e86d170fd68f36c0dc263148 diff --git a/external/lua b/external/lua new file mode 160000 index 000000000..722505a73 --- /dev/null +++ b/external/lua @@ -0,0 +1 @@ +Subproject commit 722505a73df1b2f42d5dde5c617b33edf7edbd43 diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index 4e64b6ae9..2173dc166 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -51,15 +51,16 @@ target_link_libraries(${PROJECT_NAME} ${CMAKE_PROJECT_NAME}_server_lib ${CMAKE_PROJECT_NAME}_common gamekit - ${OPENGL_LIBRARIES} - ${TINYXML2_LIBRARIES} - ${GLEW_LIBRARIES} - ${LUA_LIBRARIES} + tinyxml2 + libglew_static + lua_static sfml-system sfml-window sfml-network sfml-graphics sfml-audio zlib + glm + ${OPENGL_LIBRARIES} ${UNIX_LIBS}) diff --git a/source/common/CMakeLists.txt b/source/common/CMakeLists.txt index aae2afa10..67ba7ae6b 100644 --- a/source/common/CMakeLists.txt +++ b/source/common/CMakeLists.txt @@ -18,7 +18,12 @@ endforeach(HEADER_FILE) # Add library #------------------------------------------------------------------------------ add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) -add_dependencies(${PROJECT_NAME} zlib EnTT gamekit) + +add_dependencies(${PROJECT_NAME} + zlib + EnTT + gamekit + lua_static) #------------------------------------------------------------------------------ # Compiler flags @@ -35,5 +40,11 @@ target_compile_options(${PROJECT_NAME} PRIVATE -DSOL_CHECK_ARGUMENTS -DSOL_PRINT # target_compile_options(${PROJECT_NAME} PRIVATE -pg) -target_link_libraries(${PROJECT_NAME} sfml-system sfml-network zlib) +target_link_libraries(${PROJECT_NAME} + sfml-system + sfml-network + tinyxml2 + zlib + lua_static + glm) diff --git a/source/server/CMakeLists.txt b/source/server/CMakeLists.txt index 4497b8a9e..75f8e4550 100644 --- a/source/server/CMakeLists.txt +++ b/source/server/CMakeLists.txt @@ -64,18 +64,22 @@ if (UNIX) set (UNIX_LIBS -ldl) endif () -target_link_libraries(${PROJECT_NAME}_lib sfml-system sfml-network) +target_link_libraries(${PROJECT_NAME}_lib + sfml-system + sfml-network + glm) target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}_lib ${CMAKE_PROJECT_NAME}_common gamekit - ${OPENGL_LIBRARIES} - ${TINYXML2_LIBRARIES} - ${GLEW_LIBRARIES} - ${LUA_LIBRARIES} + tinyxml2 + libglew_static + lua_static sfml-system sfml-network zlib + glm + ${OPENGL_LIBRARIES} ${UNIX_LIBS})