forked from gecube/opencaesar3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
155 lines (127 loc) · 5.27 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
project(opencaesar3)
cmake_minimum_required(VERSION 2.6)
# Find revision ID and hash of the sourcetree
include(cmake/Modules/GenerateVersionHPP.cmake)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
#set(NO_USE_SYSTEM_ZLIB ON)
aux_source_directory(. SRC_LIST)
file(GLOB INC_LIST "*.hpp")
if(OPENCAESAR3_CROSSCOMPILING)
MESSAGE("Prepare wintoolchain for cross compilation")
set(DEP_URL "https://www.dropbox.com/s/4ozo2q3yewga64n/dependencies-mingw.7z" )
set(DEP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies")
set(DEP_DOWNLOAD_PATH "${DEP_DIR}/dependencies-mingw.7z")
if(NOT EXISTS "${DEP_DOWNLOAD_PATH}")
MESSAGE("Can't find ${DEP_DOWNLOAD_PATH}")
MESSAGE("Try download dependencies-mingw.7z from ${DEP_URL}")
file( DOWNLOAD ${DEP_URL} ${DEP_DOWNLOAD_PATH} )
endif()
execute_process( COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/cmake/xcompile/getdeps.sh )
endif(OPENCAESAR3_CROSSCOMPILING)
find_package(SDL REQUIRED)
find_package(SDL_mixer REQUIRED)
find_package(SDL_ttf REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Libintl REQUIRED)
find_package(PNG REQUIRED)
find_package(zlib REQUIRED)
set(APPEND_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/source" )
set(UTILS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/utils" )
include_directories(
${APPEND_SOURCE_DIR}
${UTILS_SOURCE_DIR}
${SDL_INCLUDE_DIR}
${SDL_MIXER_INCLUDE_DIR}
${SDL_TTF_INCLUDE_DIR}
${OpenGL_INCLUDE_DIR}
${LIBINTL_INCLUDE_DIR}
${PNG_INCLUDE_DIR}
)
link_libraries(
${SDL_LIBRARY}
${SDL_MIXER_LIBRARY}
${SDL_TTF_LIBRARY}
${OPENGL_LIBRARIES}
${LIBINTL_LIBRARIES}
${PNG_LIBRARY}
)
set(UTILS_SRC_LIST)
if(NO_USE_SYSTEM_ZLIB)
add_definitions(-DNO_USE_SYSTEM_ZLIB)
file(GLOB ZLIB_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/utils/zlib/*.c")
foreach( name ${ZLIB_SRC_LIST} )
list( APPEND UTILS_SRC_LIST ${name} )
endforeach()
else(NO_USE_SYSTEM_ZLIB)
link_libraries(${ZLIB_LIBRARY})
endif(NO_USE_SYSTEM_ZLIB)
file(GLOB GLDM_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/utils/aesGladman/*.cpp")
foreach( name ${GLDM_SRC_LIST} )
list( APPEND UTILS_SRC_LIST ${name} )
endforeach()
file(GLOB BZIP2_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/utils/bzip2/*.c")
foreach( name ${BZIP2_SRC_LIST} )
list( APPEND UTILS_SRC_LIST ${name} )
endforeach()
file(GLOB LZMA_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/utils/lzma/*.c")
foreach( name ${LZMA_SRC_LIST} )
list( APPEND UTILS_SRC_LIST ${name} )
endforeach()
file(GLOB EVENTS_SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/events/*.*")
file(GLOB CORE_SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/core/*.*")
file(GLOB GUI_SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/gui/*.*")
file(GLOB GAME_SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/game/*.*")
file(GLOB VFS_SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/vfs/*.*")
file(GLOB GFX_SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/gfx/*.*")
file(GLOB SOUND_SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/sound/*.*")
file(GLOB SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/*.*")
file(GLOB BUILDING_SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/building/*.*")
file(GLOB WALKER_SOURCES_LIST "${CMAKE_CURRENT_SOURCE_DIR}/source/walker/*.*")
file(GLOB GAME_MODELS_LIST "${CMAKE_CURRENT_SOURCE_DIR}/models/game/*.model")
file(GLOB GUI_MODELS_LIST "${CMAKE_CURRENT_SOURCE_DIR}/models/gui/*.gui")
add_executable(${PROJECT_NAME} ${SRC_LIST} ${INC_LIST} ${UTILS_SRC_LIST}
${GAME_MODELS_LIST} ${GUI_MODELS_LIST} ${EVENTS_SOURCES_LIST}
${CORE_SOURCES_LIST} ${GUI_SOURCES_LIST} ${WALKER_SOURCES_LIST}
${BUILDING_SOURCES_LIST} ${GAME_SOURCES_LIST} ${VFS_SOURCES_LIST}
${GFX_SOURCES_LIST} ${SOURCES_LIST} ${SOUND_SOURCES_LIST} )
set_property(TARGET ${PROJECT_NAME} PROPERTY OUTPUT_NAME "caesar3")
# set compiler options
if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wno-unused-value")
endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# Copy DLL to build output directory
if(WIN32)
if(MSVC)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} /Wall")
include_directories( "${CMAKE_CURRENT_SOURCE_DIR}/dependecies/msvc-include/" )
endif(MSVC)
set(_LIBS_FOR_DLL_SOURCE
${SDL_LIBRARY}
${SDL_MIXER_LIBRARY}
${SDL_TTF_LIBRARY}
${LIBINTL_LIBRARIES}
${PNG_LIBRARY}
)
if(NO_USE_SYSTEM_ZLIB)
#
else(NO_USE_SYSTEM_ZLIB)
list( APPEND _LIBS_FOR_DLL_SOURCE ${ZLIB_LIBRARY} )
endif(NO_USE_SYSTEM_ZLIB)
foreach(_lib ${_LIBS_FOR_DLL_SOURCE})
GET_FILENAME_COMPONENT(_lib_abs ${_lib} ABSOLUTE)
GET_FILENAME_COMPONENT(_lib_path ${_lib} PATH)
# Gather list of all .xml and .conf files in "/config"
file(GLOB DLLs ${_lib_path}/*.dll
${_lib_path}/../bin/*.dll)
foreach(dll ${DLLs})
#MESSAGE (DLL: ${dll})
add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${dll} $<TARGET_FILE_DIR:${PROJECT_NAME}>)
endforeach()
endforeach(_lib)
# Set resource path in Visual Studio as debuging argument
if (MSVC)
set(DEBUG_ARGS "-R \"${CMAKE_CURRENT_SOURCE_DIR}/resources\"")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/vs/opencaesar3.vcxproj.user" "${CMAKE_CURRENT_BINARY_DIR}/opencaesar3.vcxproj.user" @ONLY)
endif(MSVC)
endif(WIN32)