1 cmake_minimum_required(VERSION 2.4.4)
2 if(COMMAND cmake_policy)
3 cmake_policy(SET CMP0003 NEW)
4 cmake_policy(SET CMP0005 NEW)
5 endif(COMMAND cmake_policy)
10 SET(PREFIX CACHE PATH "Abbreviation for CMAKE_INSTALL_PREFIX.")
11 SET(CMAKE_INSTALL_PREFIX ${PREFIX})
20 endif (NOT "${LAYOUT}")
22 SET(LAYOUT CACHE STRING "Directory layout.")
24 if (${LAYOUT} MATCHES "home")
26 SET( PLUGIN_DIR ${CMAKE_INSTALL_PREFIX}/plugins )
27 ENDIF( NOT PLUGIN_DIR )
29 SET( DATA_DIR ${CMAKE_INSTALL_PREFIX} )
32 SET( MAN_DIR ${CMAKE_INSTALL_PREFIX}/man/man6 )
35 SET( BIN_DIR ${CMAKE_INSTALL_PREFIX} )
38 SET( SYSCONF_DIR ${CMAKE_INSTALL_PREFIX} )
39 ENDIF( NOT SYSCONF_DIR )
41 SET( LIB_DIR ${CMAKE_INSTALL_PREFIX} )
43 elseif (${LAYOUT} MATCHES "fhs")
45 SET( LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib/gemrb )
48 SET( PLUGIN_DIR ${LIB_DIR}/plugins )
49 ENDIF( NOT PLUGIN_DIR )
51 SET( DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/gemrb )
54 SET( MAN_DIR ${CMAKE_INSTALL_PREFIX}/share/man/man6 )
57 SET( BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin )
60 SET( SYSCONF_DIR ${CMAKE_INSTALL_PREFIX}/etc/gemrb )
61 ENDIF( NOT SYSCONF_DIR )
62 else (${LAYOUT} MATCHES "opt")
64 SET( LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib )
67 SET( PLUGIN_DIR ${LIB_DIR}/plugins )
68 ENDIF( NOT PLUGIN_DIR )
70 SET( DATA_DIR ${CMAKE_INSTALL_PREFIX}/share/ )
73 SET( MAN_DIR ${CMAKE_INSTALL_PREFIX}/man/man6 )
76 SET( BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin )
79 SET( SYSCONF_DIR ${CMAKE_INSTALL_PREFIX}/etc )
80 ENDIF( NOT SYSCONF_DIR )
81 endif (${LAYOUT} MATCHES "home")
84 IF(CMAKE_COMPILER_IS_GNUCXX)
85 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
86 ENDIF(CMAKE_COMPILER_IS_GNUCXX)
88 MESSAGE(STATUS "Looking for Python libraries")
89 INCLUDE(FindPythonLibs)
91 MESSAGE(STATUS "Python Libraries Found")
93 MESSAGE(FATAL_ERROR "Unable to find Python development libraries. Please get it from www.python.org")
96 MESSAGE(STATUS "Looking for openAL libraries")
99 MESSAGE(STATUS "openal found")
101 MESSAGE(ERROR "unable to find openal. please set OPENALDIR environment variable or get it from www.openal.org")
104 MESSAGE(STATUS "Looking for SDL")
107 MESSAGE(STATUS "SDL found")
109 MESSAGE(FATAL_ERROR "unable to find SDL. please get it from www.libsdl.org")
112 MESSAGE( STATUS "Looking for Zlib" )
113 #SET(ZLIB_FIND_REQUIRED TRUE)
116 MESSAGE( STATUS "Looking for libPNG" )
119 MESSAGE( STATUS "libPNG found" )
121 MESSAGE( STATUS "WARNING : GemRB will be built without any PNG support. Get it from www.libpng.org" )
125 MESSAGE(STATUS "Looking for dl library")
126 FIND_LIBRARY(DLD_LIBRARY_PATH dl dld)
128 MESSAGE(STATUS "dl library found")
129 ELSE(DLD_LIBRARY_PATH)
130 MESSAGE(FATAL_ERROR "dl library not found")
131 ENDIF(DLD_LIBRARY_PATH)
134 MESSAGE(STATUS "Looking for Ogg Vorbis support")
135 FIND_LIBRARY(VORBIS_LIBRARY vorbisfile)
137 ADD_DEFINITIONS("-DHAVE_CONFIG_H")
139 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
142 INCLUDE (CheckTypeSize)
143 CHECK_TYPE_SIZE("int" SIZEOF_INT)
144 CHECK_TYPE_SIZE("long int" SIZEOF_LONG_INT)
146 INCLUDE (CheckFunctionExists)
147 CHECK_FUNCTION_EXISTS("snprintf" HAVE_SNPRINTF)
148 CHECK_FUNCTION_EXISTS("strndup" HAVE_STRNDUP)
152 INCLUDE (CheckCXXSourceCompiles)
153 CHECK_CXX_SOURCE_COMPILES("typedef void *(* voidvoid)(void);
157 function = (voidvoid) object;
158 " PERMITS_OBJECT_TO_FUNCTION_CAST)
160 IF( NOT PERMITS_OBJECT_TO_FUNCTION_CAST )
161 SET(HAVE_FORBIDDEN_OBJECT_TO_FUNCTION_CAST 1)
162 ENDIF( NOT PERMITS_OBJECT_TO_FUNCTION_CAST )
166 SET(HAS_VORBIS_SUPPORT 1)
168 SET(VORBIS_LIBRARY "")
169 ENDIF(VORBIS_LIBRARY)
172 FIND_LIBRARY(SDL_MAIN_LIBRARY_PATH SDLmain)
173 FIND_LIBRARY(COCOA_LIBRARY_PATH Cocoa)
176 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
178 #Plugin addition macro
179 MACRO(ADD_GEMRB_PLUGIN plugin_name)
180 ADD_LIBRARY(${plugin_name} MODULE ${ARGN})
181 SET_TARGET_PROPERTIES(${plugin_name} PROPERTIES PREFIX "")
183 TARGET_LINK_LIBRARIES(${plugin_name} gemrb_core)
186 TARGET_LINK_LIBRARIES(${plugin_name} gemrb_core)
188 INSTALL(TARGETS ${plugin_name} DESTINATION ${PLUGIN_DIR})
189 ENDMACRO(ADD_GEMRB_PLUGIN)
191 #gemrb overrides macro
192 MACRO(ADD_GEMRB_OVERRIDE game_name)
193 FILE( GLOB FILES_TO_INSTALL *.2da *.bmp *.ini *.chu *.ids *.bcs *.vvc *.mos *.spl *.wav *.pro)
194 INSTALL( FILES ${FILES_TO_INSTALL} DESTINATION ${DATA_DIR}/override/${game_name} )
195 ENDMACRO(ADD_GEMRB_OVERRIDE )
197 ADD_SUBDIRECTORY( gemrb )
198 INSTALL( FILES gemrb.6 DESTINATION ${MAN_DIR} )
201 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
202 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
206 ADD_CUSTOM_TARGET( uninstall
207 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )