-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
164 lines (103 loc) · 3.8 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
cmake_minimum_required(VERSION 2.8)
project(sdl_console)
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
# COMMON PARAMS
#
include_directories (
${PROJECT_SOURCE_DIR}
)
message("dest dir:" ${CMAKE_INSTALL_PREFIX})
if(MSVC)
MESSAGE ("********* MSVC ************" )
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
#disable C4103 warning because is perfectly valid. Only MSVC complains about it
add_definitions(/wd4103)
add_definitions(/wd4800)
add_definitions(/wd4244)
else()
SET( COMMON_PARAMS " ${COMMON_PARAMS} -D__STDC_CONSTANT_MACROS -std=c++1y -Wall")
if (MINGW)
MESSAGE ("********* MINGW CONF ************" )
message("mingw path: $ENV{MINGWDIR} ")
set(CMAKE_LEGACY_MINGW_WIN32 0)
set(CMAKE_PREFIX_PATH " $ENV{MINGWDIR}/local32/lib ")
find_library(SDL2_LIB SDL2)
find_library(SDL2_MAIN_LIB SDL2main)
MESSAGE ("include" ${include_directories})
SET( COMMON_PARAMS " ${COMMON_PARAMS} ")
endif()
include_directories (
$ENV{MINGWDIR}/local32/include
)
LINK_DIRECTORIES (
/usr/local/lib
$ENV{MINGWDIR}/local32/lib
)
endif()
#
# COMMON PARAMS
#
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#
# RELEASE PARAMS
#
IF ( "${TARGET}" STREQUAL "")
SET ( TARGET "release" )
ENDIF ()
if(MSVC)
IF ( "${TARGET}" STREQUAL "debug")
add_definitions(/bigobj)
ENDIF()
else()
set(TARGET_FLAGS " -O2 ")
set( POST_NAME "")
# -D_GLIBCXX_DEBUG
IF ( "${TARGET}" STREQUAL "debug")
set( POST_NAME "_d")
set(TARGET_FLAGS " -O0 ")
set(TARGET_FLAGS " ${TARGET_FLAGS} -g -fomit-frame-pointer ")
ENDIF ()
# Compile for x86 target by default ...
set(TARGET_FLAGS " ${TARGET_FLAGS} ")
if ( "${EMSCRIPTEN}" STREQUAL "yes" )
message("emscripten path: $ENV{EMSCRIPTENDIR} ")
MESSAGE ("********* EMSCRIPTEN CONF ************" )
set(TARGET_FLAGS " -O2 ")
set(CMAKE_C_COMPILER "$ENV{EMSCRIPTENDIR}/emcc")
set(CMAKE_CXX_COMPILER "$ENV{EMSCRIPTENDIR}/em++")
SET( COMMON_PARAMS " ${COMMON_PARAMS} -I$ENV{EMSCRIPTENDIR}/system/lib/libcxxabi/include/ -s USE_SDL=2 -s DEMANGLE_SUPPORT=1 -s ASSERTIONS=2 -s VERBOSE=1 ")
set( POST_NAME ${POST_NAME}.html)
endif()
SET(CMAKE_C_FLAGS " ")
SET(CMAKE_CXX_FLAGS " ${TARGET_FLAGS} ${COMMON_PARAMS} " )
MESSAGE ("Target : " ${TARGET})
#Redefine output dir ...
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${TARGET})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${TARGET})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${TARGET})
LINK_DIRECTORIES(${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})
endif()
#
# RELEASE PARAMS
#
#--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#----------------------------------------------------------------------------------------------------------------------------------------------------
#
# SOURCE UTILS
#
# ENGINE EXAMPLE
add_executable(sdl_console${POST_NAME}
${PROJECT_SOURCE_DIR}/main.cpp
${PROJECT_SOURCE_DIR}/CConsole.cpp
${PROJECT_SOURCE_DIR}/CImage.cpp
${PROJECT_SOURCE_DIR}/CInput.cpp
${PROJECT_SOURCE_DIR}/CFont.cpp
)
# Library
if (MINGW)
find_library(SDL2_LIB NAMES SDL2 )
target_link_libraries(sdl_console${POST_NAME} mingw32 SDL2main SDL2)
else()
target_link_libraries(sdl_console${POST_NAME} SDL2main SDL2)
endif()