[CMakeLists.txt] Splitted into two new files.
- One for `external` folder - One for `tests` folder
This commit is contained in:
parent
e62b94beab
commit
3b83399843
114
CMakeLists.txt
114
CMakeLists.txt
@ -65,121 +65,13 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
endif()
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Packages
|
||||
#------------------------------------------------------------------------------
|
||||
# - OpenGL
|
||||
#------------------------------------------------------------------------------
|
||||
set(OpenGL_GL_PREFERENCE "LEGACY")
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
if(NOT OPENGL_FOUND)
|
||||
message(FATAL_ERROR "OpenGL not found!")
|
||||
endif(NOT OPENGL_FOUND)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# 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 sync --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
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()
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - EnTT
|
||||
#------------------------------------------------------------------------------
|
||||
add_subdirectory(external/entt)
|
||||
include_directories(external/entt/src)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - SFML
|
||||
#------------------------------------------------------------------------------
|
||||
set(SFML_STATIC TRUE)
|
||||
|
||||
set(SFML_BUILD_AUDIO FALSE CACHE BOOL "")
|
||||
set(SFML_BUILD_GRAPHICS FALSE CACHE BOOL "")
|
||||
set(SFML_BUILD_NETWORK TRUE CACHE BOOL "")
|
||||
set(SFML_BUILD_WINDOW FALSE CACHE BOOL "")
|
||||
|
||||
add_subdirectory(external/SFML)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - gamekit
|
||||
#------------------------------------------------------------------------------
|
||||
add_subdirectory(external/gamekit)
|
||||
include_directories(external/gamekit/include)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - zlib
|
||||
#------------------------------------------------------------------------------
|
||||
set(ZLIB_STATIC ON)
|
||||
|
||||
add_subdirectory(external/zlib ${CMAKE_CURRENT_BINARY_DIR}/external/zlib)
|
||||
include_directories(external/zlib ${CMAKE_CURRENT_BINARY_DIR}/external/zlib)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - lua
|
||||
#------------------------------------------------------------------------------
|
||||
add_subdirectory(external/lua)
|
||||
include_directories(external/lua/src)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - sol3 (sol2 v3.x)
|
||||
#------------------------------------------------------------------------------
|
||||
add_subdirectory(external/sol2)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - FastNoiseLite
|
||||
#------------------------------------------------------------------------------
|
||||
include_directories(SYSTEM external/FastNoiseLite)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Subdirectories
|
||||
#------------------------------------------------------------------------------
|
||||
add_subdirectory(external)
|
||||
|
||||
add_subdirectory(source/common)
|
||||
add_subdirectory(source/server)
|
||||
add_subdirectory(source/client)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Unit testing
|
||||
#------------------------------------------------------------------------------
|
||||
if(OM_BUILD_TESTS)
|
||||
find_package(CxxTest QUIET)
|
||||
|
||||
if(CXXTEST_FOUND)
|
||||
include_directories(${CXXTEST_INCLUDE_DIRS})
|
||||
enable_testing()
|
||||
|
||||
file(GLOB_RECURSE HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/source/*.hpp")
|
||||
foreach(HEADER_FILE ${HEADER_FILES})
|
||||
get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY)
|
||||
include_directories(${HEADER_DIRECTORY})
|
||||
endforeach(HEADER_FILE)
|
||||
|
||||
file(GLOB_RECURSE TEST_FILES "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.hpp")
|
||||
CXXTEST_ADD_TEST(${CMAKE_PROJECT_NAME}_tests unit-test.cpp ${TEST_FILES})
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}_tests ${CMAKE_PROJECT_NAME}_common ${CMAKE_PROJECT_NAME}_server_lib)
|
||||
else()
|
||||
message(WARNING "CxxTest not found!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_subdirectory(tests)
|
||||
|
78
external/CMakeLists.txt
vendored
Normal file
78
external/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,78 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Packages
|
||||
#------------------------------------------------------------------------------
|
||||
# - OpenGL
|
||||
#------------------------------------------------------------------------------
|
||||
set(OpenGL_GL_PREFERENCE "LEGACY")
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
if(NOT OPENGL_FOUND)
|
||||
message(FATAL_ERROR "OpenGL not found!")
|
||||
endif(NOT OPENGL_FOUND)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# 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 sync --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
|
||||
WORKING_DIRECTORY ${PROJECT_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()
|
||||
|
||||
set(BUILD_SHARED_LIBS OFF)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - EnTT
|
||||
#------------------------------------------------------------------------------
|
||||
add_subdirectory(entt)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - SFML
|
||||
#------------------------------------------------------------------------------
|
||||
set(SFML_STATIC TRUE)
|
||||
|
||||
set(SFML_BUILD_AUDIO FALSE CACHE BOOL "")
|
||||
set(SFML_BUILD_GRAPHICS FALSE CACHE BOOL "")
|
||||
set(SFML_BUILD_NETWORK TRUE CACHE BOOL "")
|
||||
set(SFML_BUILD_WINDOW FALSE CACHE BOOL "")
|
||||
|
||||
add_subdirectory(SFML)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - gamekit
|
||||
#------------------------------------------------------------------------------
|
||||
add_subdirectory(gamekit)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - zlib
|
||||
#------------------------------------------------------------------------------
|
||||
set(ZLIB_STATIC ON)
|
||||
|
||||
add_subdirectory(zlib ${CMAKE_CURRENT_BINARY_DIR}/external/zlib)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - lua
|
||||
#------------------------------------------------------------------------------
|
||||
add_subdirectory(lua)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# - sol3 (sol2 v3.x)
|
||||
#------------------------------------------------------------------------------
|
||||
add_subdirectory(sol2)
|
||||
|
@ -29,6 +29,13 @@ add_dependencies(${PROJECT_NAME}
|
||||
sol2
|
||||
)
|
||||
|
||||
# FIXME: Use target_include_directories(PUBLIC ...) in gamekit/zlib/lua
|
||||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${PROJECT_SOURCE_DIR}/external/entt/src)
|
||||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${PROJECT_SOURCE_DIR}/external/gamekit/include)
|
||||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${PROJECT_SOURCE_DIR}/external/zlib ${CMAKE_CURRENT_BINARY_DIR}/external/zlib)
|
||||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${PROJECT_SOURCE_DIR}/external/lua/src)
|
||||
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC ${PROJECT_SOURCE_DIR}/external/FastNoiseLite)
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Compiler flags
|
||||
#------------------------------------------------------------------------------
|
||||
|
25
tests/CMakeLists.txt
Normal file
25
tests/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# Unit testing
|
||||
#------------------------------------------------------------------------------
|
||||
if(OM_BUILD_TESTS)
|
||||
find_package(CxxTest QUIET)
|
||||
|
||||
if(CXXTEST_FOUND)
|
||||
include_directories(${CXXTEST_INCLUDE_DIRS})
|
||||
enable_testing()
|
||||
|
||||
file(GLOB_RECURSE HEADER_FILES "${PROJECT_SOURCE_DIR}/source/*.hpp")
|
||||
foreach(HEADER_FILE ${HEADER_FILES})
|
||||
get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY)
|
||||
include_directories(${HEADER_DIRECTORY})
|
||||
endforeach(HEADER_FILE)
|
||||
|
||||
file(GLOB_RECURSE TEST_FILES "${PROJECT_SOURCE_DIR}/tests/*.hpp")
|
||||
CXXTEST_ADD_TEST(${CMAKE_PROJECT_NAME}_tests unit-test.cpp ${TEST_FILES})
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME}_tests ${CMAKE_PROJECT_NAME}_common ${CMAKE_PROJECT_NAME}_server_lib)
|
||||
else()
|
||||
message(WARNING "CxxTest not found!")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user