-
Notifications
You must be signed in to change notification settings - Fork 24
/
CMakeLists.txt
114 lines (93 loc) · 3.45 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
project(supertuxkart-editor)
cmake_minimum_required(VERSION 2.8)
if(NOT (CMAKE_MAJOR_VERSION VERSION_LESS 3))
cmake_policy(SET CMP0043 OLD)
endif()
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "No build type selected, default to Release")
set(CMAKE_BUILD_TYPE "Release")
endif()
option(STATIC_PHYSFS "Force build with static physfs library" OFF)
option(STATIC_ZLIB "Force build with static zlib library" OFF)
if(UNIX OR MINGW)
option(DEBUG_SYMBOLS "Compile with debug symbols" OFF)
endif()
# These variables enable MSVC to find libraries located in "dependencies"
if(WIN32)
set(ENV{PATH} "$ENV{PATH};${PROJECT_SOURCE_DIR}/dependencies/include")
set(ENV{LIB} ${PROJECT_SOURCE_DIR}/dependencies/lib)
set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/dependencies)
endif()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(STKTE_SOURCE_DIR "${PROJECT_SOURCE_DIR}/src")
include_directories(${STKTE_SOURCE_DIR})
if(WIN32)
add_definitions(-D_IRR_STATIC_LIB_)
configure_file("${PROJECT_SOURCE_DIR}/src/icon_rc.template" "${PROJECT_BINARY_DIR}/tmp/icon.rc")
endif()
file(GLOB_RECURSE STKTE_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${STKTE_SOURCE_DIR}/*.cpp")
file(GLOB_RECURSE STKTE_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_BINARY_DIR}/tmp/*.rc")
if(UNIX OR MINGW)
if(DEBUG_SYMBOLS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
endif()
endif()
# OpenGL
find_package(OpenGL REQUIRED)
include_directories(${OPENGL_INCLUDE_DIR})
if(NOT OPENGL_FOUND)
message(FATAL_ERROR "OpenGL not found")
endif()
if(WIN32 OR APPLE OR STATIC_ZLIB)
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/zlib")
include_directories("${PROJECT_SOURCE_DIR}/lib/zlib")
set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lib/zlib" "${PROJECT_BINARY_DIR}/lib/zlib/")
set(ZLIB_LIBRARY zlibstatic)
else()
find_package(ZLIB REQUIRED)
endif()
if(WIN32 OR APPLE OR STATIC_PHYSFS)
add_definitions(-DPHYSFS_BUILD_STATIC)
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/physfs")
include_directories("${PROJECT_SOURCE_DIR}/lib/physfs")
set(PHYSFS_LIBRARY physfs-static)
else()
find_package(PhysFS REQUIRED)
endif()
add_subdirectory("${PROJECT_SOURCE_DIR}/lib/irrlicht")
include_directories("${PROJECT_SOURCE_DIR}/lib/irrlicht/include")
if(UNIX AND NOT APPLE)
find_package(X11 REQUIRED)
include_directories(${X11_INCLUDE_DIR})
endif()
if(UNIX OR MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
add_definitions(-DNOMINMAX)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set_property(DIRECTORY PROPERTY COMPILE_DEFINITIONS_DEBUG DEBUG)
else()
if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DDEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
else()
add_definitions(-DNDEBUG)
endif()
endif()
add_executable(${PROJECT_NAME} ${STKTE_SOURCES} ${STKTE_RESOURCES})
file(COPY ${PROJECT_SOURCE_DIR}/src/font/ DESTINATION ${PROJECT_BINARY_DIR}/bin/font)
# Link options
target_link_libraries(${PROJECT_NAME}
irrlicht
${PHYSFS_LIBRARY}
${OPENGL_gl_LIBRARY}
)
if(UNIX AND NOT APPLE)
target_link_libraries(${PROJECT_NAME} ${X11_X11_LIB} ${X11_Xxf86vm_LIB})
elseif(WIN32)
target_link_libraries(${PROJECT_NAME} winmm)
endif()