-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
81 lines (72 loc) · 2.13 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
cmake_minimum_required(VERSION 3.13.4)
project("main")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_DEBUG_POSTFIX "d")
# DOWNLOAD SUBMODULES
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_SUBMODULE_RESULT}.")
endif()
endif()
endif()
# CHECK ALL THE SUBMODULES
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/external/Physics2D/CMakeLists.txt")
message(FATAL_ERROR "The Physics2D submodule was not downloaded!")
endif()
add_subdirectory("external/Physics2D")
add_subdirectory(json-develop)
if (UNIX)
#add_compile_options(-O1 -g -fsanitize=address -fno-omit-frame-pointer)
add_compile_options(-Wall -Wno-reorder)
endif()
add_subdirectory("src")
target_link_directories(${PROJECT_NAME} PRIVATE lib)
target_include_directories(${PROJECT_NAME}
PRIVATE include
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
PRIVATE external/Physics2D/include
)
target_link_libraries(${PROJECT_NAME}
Texture
Shader
Glad
Physics2D
)
target_link_libraries(${PROJECT_NAME} nlohmann_json::nlohmann_json)
# Install defines
install(TARGETS "${PROJECT_NAME}" DESTINATION bin)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/assets" DESTINATION ./)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/src/shaders" DESTINATION ./)
if (MSVC)
target_link_libraries(${PROJECT_NAME}
opengl32
debug Debug/glfw3d optimized Release/glfw3
debug Debug/zlibstaticd optimized Release/zlibstatic
debug Debug/tinyxml2d optimized Release/tinyxml2
debug Debug/tmxparser optimized Release/tmxparser
debug Debug/freetyped optimized Release/freetype
)
include(CPack)
elseif (UNIX)
target_link_libraries(${PROJECT_NAME}
glfw
GL
X11
pthread
Xrandr
Xi
dl
m
tinyxml2
z
debug tmxparserd optimized tmxparser
freetype
)
endif()