9 set(QT_USE_QTXML FALSE) |
9 set(QT_USE_QTXML FALSE) |
10 set(QT_USE_QTOPENGL FALSE) |
10 set(QT_USE_QTOPENGL FALSE) |
11 set(QT_USE_QTMAIN TRUE) |
11 set(QT_USE_QTMAIN TRUE) |
12 |
12 |
13 find_package(Qt4 REQUIRED) |
13 find_package(Qt4 REQUIRED) |
14 if (NOT CROSSAPPLE) |
14 include(${QT_USE_FILE}) |
15 include(${QT_USE_FILE}) |
|
16 endif() |
|
17 |
15 |
18 find_package(SDL REQUIRED) #video in SDLInteraction |
16 find_package(SDL REQUIRED) #video in SDLInteraction |
19 find_package(SDL_mixer REQUIRED) #audio in SDLInteraction |
17 find_package(SDL_mixer REQUIRED) #audio in SDLInteraction |
20 find_package(SDL_net REQUIRED) #network frontlib |
18 find_package(SDL_net REQUIRED) #network frontlib |
21 if(NOT NOVIDEOREC) |
19 if(NOT NOVIDEOREC) |
22 find_package(FFMPEG) |
20 find_package(FFMPEG) |
|
21 if(${FFMPEG_FOUND}) |
|
22 add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS) |
|
23 endif() |
23 endif() |
24 endif() |
24 |
25 |
25 include_directories(.) |
26 include_directories(.) |
26 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/model) |
27 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/model) |
27 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/net) |
28 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/net) |
33 include_directories(${SDL_INCLUDE_DIR}) |
34 include_directories(${SDL_INCLUDE_DIR}) |
34 include_directories(${SDLMIXER_INCLUDE_DIR}) |
35 include_directories(${SDLMIXER_INCLUDE_DIR}) |
35 include_directories(${FFMPEG_INCLUDE_DIR}) |
36 include_directories(${FFMPEG_INCLUDE_DIR}) |
36 include_directories(${CMAKE_SOURCE_DIR}/misc/physfs/src) |
37 include_directories(${CMAKE_SOURCE_DIR}/misc/physfs/src) |
37 include_directories(${CMAKE_SOURCE_DIR}/misc/physfs/extras) |
38 include_directories(${CMAKE_SOURCE_DIR}/misc/physfs/extras) |
38 include_directories(${CMAKE_SOURCE_DIR}/project_files/frontlib) |
|
39 if(UNIX) |
39 if(UNIX) |
40 # HACK: in freebsd cannot find iconv.h included via SDL.h |
40 # HACK: in freebsd cannot find iconv.h included via SDL.h |
41 include_directories("/usr/local/include") |
41 include_directories("/usr/local/include") |
42 endif(UNIX) |
42 endif(UNIX) |
43 |
43 |
44 |
44 #directory for resources, relative to the one above on certain platforms/configurations |
45 if(WIN32 AND NOT UNIX) |
45 if(DEFINED DATA_INSTALL_DIR OR WIN32 OR APPLE) |
46 set(HEDGEWARS_BINDIR ".") |
46 set(HEDGEWARS_DATADIR ${SHAREPATH}) |
47 set(HEDGEWARS_DATADIR "../share/") |
|
48 add_definitions(-DUSE_XFIRE) |
|
49 else() |
47 else() |
50 set(HEDGEWARS_BINDIR ${CMAKE_INSTALL_PREFIX}) |
48 set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/${SHAREPATH}/) |
51 if(DEFINED DATA_INSTALL_DIR) |
49 endif() |
52 set(HEDGEWARS_DATADIR ${DATA_INSTALL_DIR}) |
50 |
53 else() |
51 #only the cocoa version of qt supports building 64 bit apps |
54 set(HEDGEWARS_DATADIR ${CMAKE_INSTALL_PREFIX}/share/) |
52 if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64*") AND (NOT QT_MAC_USE_COCOA)) |
55 endif() |
53 message(FATAL_ERROR "Building the 64 bit version of Hedgewars *requires* the Cocoa variant of QT on Mac OS X") |
56 #only the cocoa version of qt supports building 64 bit apps |
54 endif() |
57 if(APPLE AND (CMAKE_OSX_ARCHITECTURES MATCHES "x86_64*") AND (NOT QT_MAC_USE_COCOA)) |
55 #endif() |
58 message(FATAL_ERROR "Building the 64 bit version of Hedgewars *requires* the Cocoa variant of QT on Mac OS X") |
|
59 endif() |
|
60 endif() |
|
61 |
56 |
62 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp) |
57 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/hwconsts.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/hwconsts.cpp) |
63 |
58 |
64 file(GLOB NetCpp net/*.cpp) |
59 file(GLOB NetCpp net/*.cpp) |
65 file(GLOB ModelCpp model/*.cpp) |
60 file(GLOB ModelCpp model/*.cpp) |
66 file(GLOB_RECURSE UIcpp ui/*.cpp) |
61 file(GLOB_RECURSE UIcpp ui/*.cpp) |
67 file(GLOB UtilCpp util/*.cpp) |
62 file(GLOB UtilCpp util/*.cpp) |
68 |
|
69 if(${FFMPEG_FOUND}) |
|
70 add_definitions(-DVIDEOREC -D__STDC_CONSTANT_MACROS) |
|
71 endif() |
|
72 |
63 |
73 set(hwfr_src |
64 set(hwfr_src |
74 ${ModelCpp} |
65 ${ModelCpp} |
75 ${NetCpp} |
66 ${NetCpp} |
76 ${UIcpp} |
67 ${UIcpp} |
95 endif(WIN32) |
86 endif(WIN32) |
96 |
87 |
97 if(MINGW) |
88 if(MINGW) |
98 # resource compilation for mingw |
89 # resource compilation for mingw |
99 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o |
90 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o |
100 COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR} |
91 COMMAND windres -I ${CMAKE_CURRENT_SOURCE_DIR} |
101 -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc |
92 -i ${CMAKE_CURRENT_SOURCE_DIR}/hedgewars.rc |
102 -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o) |
93 -o ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o) |
103 set(hwfr_src ${hwfr_src} ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o) |
94 set(hwfr_src ${hwfr_src} ${CMAKE_CURRENT_BINARY_DIR}/hedgewars_rc.o) |
104 else(MINGW) |
95 else(MINGW) |
105 set(hwfr_src ${hwfr_src} hedgewars.rc) |
96 set(hwfr_src ${hwfr_src} hedgewars.rc) |
106 endif(MINGW) |
97 endif(MINGW) |
107 |
98 |
136 campaign.h |
127 campaign.h |
137 ) |
128 ) |
138 |
129 |
139 set(hwfr_rez hedgewars.qrc) |
130 set(hwfr_rez hedgewars.qrc) |
140 |
131 |
|
132 if(${BUILD_ENGINE_LIBRARY}) |
|
133 add_definitions(-DHWLIBRARY=1) |
|
134 set(hwlibname "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}hwengine${CMAKE_SHARED_LIBRARY_SUFFIX}") |
|
135 set(HW_LINK_LIBS ${hwlibname} ${HW_LINK_LIBS}) |
|
136 endif() |
|
137 |
141 qt4_add_resources(hwfr_rez_src ${hwfr_rez}) |
138 qt4_add_resources(hwfr_rez_src ${hwfr_rez}) |
142 |
139 |
143 qt4_wrap_cpp(hwfr_moc_srcs ${hwfr_moc_hdrs}) |
140 qt4_wrap_cpp(hwfr_moc_srcs ${hwfr_moc_hdrs}) |
144 |
141 |
145 |
142 |
146 if(APPLE OR CROSSAPPLE) |
143 if(APPLE) |
147 set(hwfr_src ${hwfr_src} InstallController.cpp CocoaInitializer.mm M3Panel.mm M3InstallController.m NSWorkspace_RBAdditions.m) |
144 find_library(iokit_framework NAMES IOKit) |
148 set(HW_LINK_LIBS IOKit ${HW_LINK_LIBS}) |
145 set(HW_LINK_LIBS ${iokit_framework} ${HW_LINK_LIBS}) |
149 |
146 set(hwfr_src ${hwfr_src} CocoaInitializer.mm |
|
147 InstallController.cpp |
|
148 M3Panel.mm |
|
149 M3InstallController.m |
|
150 NSWorkspace_RBAdditions.m |
|
151 ) |
150 if(NOT NOAUTOUPDATE) |
152 if(NOT NOAUTOUPDATE) |
151 find_package(Sparkle) |
153 find_package(Sparkle) |
152 if(SPARKLE_FOUND) |
154 if(SPARKLE_FOUND) |
153 add_definitions(-DSPARKLE_ENABLED) |
155 add_definitions(-DSPARKLE_ENABLED) |
154 set(hwfr_src ${hwfr_src} AutoUpdater.cpp SparkleAutoUpdater.mm) |
156 set(hwfr_src ${hwfr_src} AutoUpdater.cpp SparkleAutoUpdater.mm) |
155 set(HW_LINK_LIBS ${SPARKLE_LIBRARY} ${HW_LINK_LIBS}) |
157 set(HW_LINK_LIBS ${SPARKLE_LIBRARY} ${HW_LINK_LIBS}) |
156 endif() |
158 endif() |
157 endif() |
159 endif() |
158 endif() |
160 endif() |
159 |
161 |
160 if(LIBENGINE) |
162 #when debugging, always prompt a console to see fronted messages |
|
163 #TODO: check it doesn't interfere on UNIX |
|
164 if(CMAKE_BUILD_TYPE MATCHES "RELEASE") |
|
165 set(console_access "WIN32") |
|
166 endif(CMAKE_BUILD_TYPE MATCHES "RELEASE") |
|
167 if(${LIBENGINE}) |
161 add_definitions(-DHWLIBRARY) |
168 add_definitions(-DHWLIBRARY) |
162 set(HW_LINK_LIBS hwengine ${HW_LINK_LIBS}) |
169 set(HW_LINK_LIBS hwengine ${HW_LINK_LIBS}) |
163 link_directories(${EXECUTABLE_OUTPUT_PATH}) |
170 link_directories(${EXECUTABLE_OUTPUT_PATH}) |
164 endif() |
171 endif() |
165 |
172 |
166 |
173 add_executable(hedgewars ${console_access} |
167 add_executable(hedgewars WIN32 |
|
168 ${hwfr_src} |
174 ${hwfr_src} |
169 ${hwfr_moc_srcs} |
175 ${hwfr_moc_srcs} |
170 ${hwfr_hdrs} |
176 ${hwfr_hdrs} |
171 ${hwfr_rez_src} |
177 ${hwfr_rez_src} |
172 ) |
178 ) |
173 |
179 |
|
180 if((UNIX AND NOT APPLE) AND ${LIBENGINE}) |
|
181 set_target_properties(hedgewars PROPERTIES LINK_FLAGS "-Wl,-rpath,${CMAKE_INSTALL_PREFIX}/${target_library_install_dir}") |
|
182 endif() |
174 |
183 |
175 set(HW_LINK_LIBS |
184 set(HW_LINK_LIBS |
176 physfs |
185 physfs |
177 frontlib |
|
178 ${QT_LIBRARIES} |
186 ${QT_LIBRARIES} |
179 ${SDL_LIBRARY} |
187 ${SDL_LIBRARY} |
180 ${SDLMIXER_LIBRARY} |
188 ${SDLMIXER_LIBRARY} |
181 ${SDLNET_LIBRARY} |
|
182 ${FFMPEG_LIBRARIES} |
189 ${FFMPEG_LIBRARIES} |
183 ${HW_LINK_LIBS} |
190 ${HW_LINK_LIBS} |
184 ) |
191 ) |
185 |
192 |
186 if(WIN32 AND NOT UNIX) |
193 if(WIN32 AND NOT UNIX) |