-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
85 lines (76 loc) · 2.89 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "")
set(APP_VERSION "1.0.0.0" CACHE STRING "Application Version" FORCE)
set(APP_NAME "ramp-up")
project(${APP_NAME} VERSION ${APP_VERSION})
# Includes
include(cmake/platform.cmake)
include(cmake/utils.cmake)
option(DOWNLOAD_SFML "Download SFML to ext/sfml (x64 Win/Linux only)" ON)
if(DOWNLOAD_SFML)
set(SFML_EXT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/sfml/lib/cmake/SFML")
if(NOT EXISTS ${SFML_EXT_DIR})
if(GCC_RUNTIME)
set(SFML_URL https://www.sfml-dev.org/files/SFML-2.5.1-linux-gcc-64-bit.tar.gz)
set(SFML_ARCHIVE sfml-2.5.1.tar.gz)
elseif(MSVC_RUNTIME)
set(SFML_URL https://www.sfml-dev.org/files/SFML-2.5.1-windows-vc15-64-bit.zip)
set(SFML_ARCHIVE sfml-2.5.1.zip)
else()
message(FATAL_ERROR "Unsupported build environment; provide SFML binaries manually!")
endif()
set(SFML_ROOT SFML-2.5.1)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ext/${SFML_ARCHIVE}")
file(MAKE_DIRECTORY ext)
message(STATUS "Downloading to ext/${SFML_ARCHIVE} from ${SFML_URL}")
file(DOWNLOAD ${SFML_URL} "${CMAKE_CURRENT_SOURCE_DIR}/ext/${SFML_ARCHIVE}")
endif()
unzip_archive(${SFML_ARCHIVE} "${CMAKE_CURRENT_SOURCE_DIR}/ext")
file(RENAME "${CMAKE_CURRENT_SOURCE_DIR}/ext/${SFML_ROOT}" "${CMAKE_CURRENT_SOURCE_DIR}/ext/sfml")
endif()
if(NOT EXISTS ${SFML_EXT_DIR})
message(WARNING "Failed to download/setup SFML!")
else()
set(SFML_DIR ${SFML_EXT_DIR})
endif()
endif()
# Dependencies
if(PLATFORM STREQUAL "Windows")
set(SFML_STATIC_LIBRARIES ON CACHE BOOL "" FORCE)
endif()
find_package(SFML REQUIRED COMPONENTS graphics audio)
# Git operations
set(GIT_COMMIT_HASH "[unknown]")
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
get_git_commit_hash(GIT_COMMIT_HASH)
if ("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
option(GIT_UPDATE_SUBMODULES "Init/Update submodules during generation" ON)
else()
option(GIT_UPDATE_SUBMODULES "Init/Update submodules during generation" OFF)
endif()
if(GIT_UPDATE_SUBMODULES)
update_git_submodules(1)
endif()
endif()
# Constants
set(GIT_COMMIT_HASH ${GIT_COMMIT_HASH} CACHE STRING "Commit hash" FORCE)
# Interface
include(cmake/interface.cmake)
# Header text
set(BUILD_CONFIG ${CMAKE_BUILD_TYPE})
if(CMAKE_CONFIGURATION_TYPES)
set(BUILD_CONFIG "Multi-config")
endif()
message(STATUS "[${CMAKE_SYSTEM_PROCESSOR}] [${PLATFORM}] [${CMAKE_GENERATOR}] [${CMAKE_CXX_COMPILER_ID}] [${BUILD_CONFIG}]")
if(CI_BUILD)
message(STATUS "== CI Build ==")
endif()
# Executable
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.*pp")
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})
add_executable(${APP_NAME} ${SOURCES})
target_link_libraries(${APP_NAME} PRIVATE sfml-graphics sfml-audio interface-lib)
if(W_MSBUILD)
set_property(DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${APP_NAME})
endif()