91 ${CMAKE_CURRENT_BINARY_DIR}/config.inc |
91 ${CMAKE_CURRENT_BINARY_DIR}/config.inc |
92 ) |
92 ) |
93 |
93 |
94 if(${LIBENGINE}) |
94 if(${LIBENGINE}) |
95 message(WARNING "Engine will be built as library (experimental)") |
95 message(WARNING "Engine will be built as library (experimental)") |
96 set(pascal_flags "-dHWLIBRARY" ${pascal_flags}) |
96 list(APPEND pascal_flags "-dHWLIBRARY") |
97 |
97 |
98 # create position independent code, only required for x68_64 builds, similar to -fPIC |
98 # create position independent code, only required for x68_64 builds, similar to -fPIC |
99 if(CMAKE_SIZEOF_VOID_P MATCHES "8") |
99 if(CMAKE_SIZEOF_VOID_P MATCHES "8") |
100 set(pascal_flags "-Cg" ${pascal_flags}) |
100 list(APPEND pascal_flags "-Cg") |
101 endif(CMAKE_SIZEOF_VOID_P MATCHES "8") |
101 endif(CMAKE_SIZEOF_VOID_P MATCHES "8") |
102 |
102 |
103 # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail |
103 # due to compiler/linker issues on Max OS X 10.6 -k-no_order_inits is needed to avoid linking fail |
104 if(APPLE AND current_macosx_version VERSION_GREATER "10.5") |
104 if(APPLE AND current_macosx_version VERSION_GREATER "10.5") |
105 set(pascal_flags "-k-no_order_inits" ${pascal_flags}) |
105 list(APPEND pascal_flags "-k-no_order_inits") |
106 endif() |
106 endif() |
107 set(destination_dir ${target_library_install_dir}) |
107 set(destination_dir ${target_library_install_dir}) |
108 else(${LIBENGINE}) |
108 else(${LIBENGINE}) |
109 set(destination_dir ${target_binary_install_dir}) |
109 set(destination_dir ${target_binary_install_dir}) |
110 endif(${LIBENGINE}) |
110 endif(${LIBENGINE}) |
144 |
144 |
145 if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND") |
145 if(SDLMAIN_LIB MATCHES "SDLMAIN_LIB-NOTFOUND") |
146 include_directories(${SDL_INCLUDE_DIR}) |
146 include_directories(${SDL_INCLUDE_DIR}) |
147 add_library (SDLmain STATIC sdlmain_osx/SDLMain.m) |
147 add_library (SDLmain STATIC sdlmain_osx/SDLMain.m) |
148 #add a dependency to the hwengine target |
148 #add a dependency to the hwengine target |
149 set(engine_sources ${engine_sources} SDLmain) |
149 list(APPEND engine_sources SDLmain) |
150 set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a") |
150 set(SDLMAIN_LIB "${LIBRARY_OUTPUT_PATH}/libSDLmain.a") |
151 endif() |
151 endif() |
152 |
152 |
153 set(pascal_flags "-k${SDLMAIN_LIB}" ${pascal_flags}) |
153 list(APPEND pascal_flags "-k${SDLMAIN_LIB}") |
154 endif() |
154 endif() |
155 endif(APPLE) |
155 endif(APPLE) |
156 |
156 |
157 if(NOT NOPNG) |
157 if(NOT NOPNG) |
158 find_package(PNG) |
158 find_package(PNG) |
159 if(${PNG_FOUND}) |
159 if(${PNG_FOUND}) |
160 set(pascal_flags "-dPNG_SCREENSHOTS" ${pascal_flags}) |
160 list(APPEND pascal_flags "-dPNG_SCREENSHOTS") |
161 if(APPLE) # fpc png unit doesn't pull the library (see bug 21833) |
161 if(APPLE) # fpc png unit doesn't pull the library (see bug 21833) |
162 set(pascal_flags "-k${PNG_LIBRARY}" ${pascal_flags}) |
162 list(APPEND pascal_flags "-k${PNG_LIBRARY}") |
163 endif() |
163 endif() |
164 else() |
164 else() |
165 message(WARNING "Screenshots will be in BMP format because libpng was not found") |
165 message(WARNING "Screenshots will be in BMP format because libpng was not found") |
166 endif() |
166 endif() |
167 else() |
167 else() |
189 # fpc will take care of linking but we need to have this library installed |
189 # fpc will take care of linking but we need to have this library installed |
190 find_package(GLUT REQUIRED) |
190 find_package(GLUT REQUIRED) |
191 |
191 |
192 #TODO: convert avwrapper to .pas unit so we can skip this step |
192 #TODO: convert avwrapper to .pas unit so we can skip this step |
193 include_directories(${FFMPEG_INCLUDE_DIR}) |
193 include_directories(${FFMPEG_INCLUDE_DIR}) |
194 set(pascal_flags "-dUSE_VIDEO_RECORDING" ${pascal_flags}) |
194 list(APPEND pascal_flags "-dUSE_VIDEO_RECORDING") |
195 IF (WIN32) |
195 IF (WIN32) |
196 # there are some problems with linking our avwrapper as static lib, so link it as shared |
196 # there are some problems with linking our avwrapper as static lib, so link it as shared |
197 add_library(avwrapper SHARED videorec/avwrapper.c) |
197 add_library(avwrapper SHARED videorec/avwrapper.c) |
198 target_link_libraries(avwrapper ${FFMPEG_LIBRARIES}) |
198 target_link_libraries(avwrapper ${FFMPEG_LIBRARIES}) |
199 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir}) |
199 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_SHARED_LIBRARY_PREFIX}avwrapper${CMAKE_SHARED_LIBRARY_SUFFIX}" DESTINATION ${target_library_install_dir}) |
200 ELSE() |
200 ELSE() |
201 add_library(avwrapper STATIC videorec/avwrapper.c) |
201 add_library(avwrapper STATIC videorec/avwrapper.c) |
202 set(pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}" ${pascal_flags}) |
202 list(APPEND pascal_flags "-k${FFMPEG_LIBAVCODEC}" "-k${FFMPEG_LIBAVFORMAT}" "-k${FFMPEG_LIBAVUTIL}") |
203 ENDIF() |
203 ENDIF() |
204 else() |
204 else() |
205 message(WARNING "Could NOT find FFMPEG/LibAV, video recording will be disabled") |
205 message(WARNING "Could NOT find FFMPEG/LibAV, video recording will be disabled") |
206 endif() |
206 endif() |
207 else() |
207 else() |
220 DEPENDS ${engine_sources} |
220 DEPENDS ${engine_sources} |
221 ) |
221 ) |
222 else() |
222 else() |
223 #these are the dependencies for building a universal binary on Mac OS X |
223 #these are the dependencies for building a universal binary on Mac OS X |
224 foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build}) |
224 foreach (build_arch ${powerpc_build} ${i386_build} ${x86_64_build}) |
225 set(lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" ${lipo_args_list}) |
225 list(APPEND lipo_args_list "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}") |
226 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" |
226 add_custom_command(OUTPUT "${EXECUTABLE_OUTPUT_PATH}/hwengine.${build_arch}" |
227 COMMAND "${FPC_EXECUTABLE}" |
227 COMMAND "${FPC_EXECUTABLE}" |
228 ARGS ${fpc_flags} -ohwengine.${build_arch} -P${build_arch} |
228 ARGS ${fpc_flags} -ohwengine.${build_arch} -P${build_arch} |
229 MAIN_DEPENDENCY ${hwengine_project} |
229 MAIN_DEPENDENCY ${hwengine_project} |
230 DEPENDS ${engine_sources} |
230 DEPENDS ${engine_sources} |
243 DEPENDS ${lipo_args_list} |
243 DEPENDS ${lipo_args_list} |
244 ) |
244 ) |
245 endif() |
245 endif() |
246 |
246 |
247 |
247 |
248 add_custom_target(${engine_output_name} ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}") |
248 add_custom_target(hwengine ALL DEPENDS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}") |
249 |
249 |
250 #when system Lua is not found we need to compile it before engine |
250 #when system Lua is not found we need to compile it before engine |
251 if(NOT LUA_FOUND) |
251 if(NOT LUA_FOUND) |
252 add_dependencies(${engine_output_name} lua) |
252 add_dependencies(hwengine lua) |
253 endif() |
253 endif() |
254 |
254 |
255 # compile physfs before engine |
255 # compile physfs before engine |
256 add_dependencies(${engine_output_name} physfs) |
256 add_dependencies(hwengine physfs) |
257 |
257 |
258 #when ffmpeg/libav is found we need to compile it before engine |
258 #when ffmpeg/libav is found we need to compile it before engine |
259 #TODO: convert avwrapper to .pas unit so we can skip this step |
259 #TODO: convert avwrapper to .pas unit so we can skip this step |
260 if(${FFMPEG_FOUND}) |
260 if(${FFMPEG_FOUND}) |
261 add_dependencies(${engine_output_name} avwrapper) |
261 add_dependencies(hwengine avwrapper) |
262 endif() |
262 endif() |
263 |
263 |
264 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6 |
264 #this command is a workaround to some inlining issues present in older FreePascal versions and fixed in 2.6 |
265 if((FPC_VERSION VERSION_LESS "2.6") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND})) |
265 if((FPC_VERSION VERSION_LESS "2.6") AND (NOVIDEOREC OR NOT ${FFMPEG_FOUND})) |
266 add_dependencies(${engine_output_name} ENGINECLEAN) |
266 add_dependencies(hwengine ENGINECLEAN) |
267 endif() |
267 endif() |
268 |
268 |
269 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir}) |
269 install(PROGRAMS "${EXECUTABLE_OUTPUT_PATH}/${engine_output_name}" DESTINATION ${destination_dir}) |