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})
14 IF( NOT PLUGIN_INSTALL_DIR )
15 SET( PLUGIN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/plugins )
16 ENDIF( NOT PLUGIN_INSTALL_DIR )
18 IF( NOT OVERRIDE_INSTALL_DIR )
19 SET( OVERRIDE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/override )
20 ENDIF( NOT OVERRIDE_INSTALL_DIR )
22 IF( NOT GUISCRIPTS_INSTALL_DIR )
23 SET( GUISCRIPTS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/GUIScripts )
24 ENDIF( NOT GUISCRIPTS_INSTALL_DIR )
26 IF( NOT MANPAGE_INSTALL_DIR )
27 SET( MANPAGE_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/man/man6 )
28 ENDIF( NOT MANPAGE_INSTALL_DIR )
30 IF(CMAKE_COMPILER_IS_GNUCXX)
31 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
32 ENDIF(CMAKE_COMPILER_IS_GNUCXX)
34 MESSAGE(STATUS "Looking for Python libraries")
35 INCLUDE(FindPythonLibs)
37 MESSAGE(STATUS "Python Libraries Found")
39 MESSAGE(FATAL_ERROR "Unable to find Python development libraries. Please get it from www.python.org")
42 MESSAGE(STATUS "Looking for openAL libraries")
45 MESSAGE(STATUS "openal found")
47 MESSAGE(ERROR "unable to find openal. please set OPENALDIR environment variable or get it from www.openal.org")
50 MESSAGE(STATUS "Looking for SDL")
53 MESSAGE(STATUS "SDL found")
55 MESSAGE(FATAL_ERROR "unable to find SDL. please get it from www.libsdl.org")
58 MESSAGE( STATUS "Looking for Zlib" )
59 #SET(ZLIB_FIND_REQUIRED TRUE)
62 MESSAGE( STATUS "Looking for libPNG" )
65 MESSAGE( STATUS "libPNG found" )
67 MESSAGE( STATUS "WARNING : GemRB will be built without any PNG support. Get it from www.libpng.org" )
71 MESSAGE(STATUS "Looking for dl library")
72 FIND_LIBRARY(DLD_LIBRARY_PATH dl dld)
74 MESSAGE(STATUS "dl library found")
75 ELSE(DLD_LIBRARY_PATH)
76 MESSAGE(FATAL_ERROR "dl library not found")
77 ENDIF(DLD_LIBRARY_PATH)
80 MESSAGE(STATUS "Looking for Ogg Vorbis support")
81 FIND_LIBRARY(VORBIS_LIBRARY vorbisfile)
83 ADD_DEFINITIONS("-DHAVE_CONFIG_H" -DPLUGINDIR="${PLUGIN_INSTALL_DIR}")
85 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
88 INCLUDE (CheckTypeSize)
89 CHECK_TYPE_SIZE("int" SIZEOF_INT)
90 CHECK_TYPE_SIZE("long int" SIZEOF_LONG_INT)
92 INCLUDE (CheckFunctionExists)
93 CHECK_FUNCTION_EXISTS("snprintf" HAVE_SNPRINTF)
94 CHECK_FUNCTION_EXISTS("strndup" HAVE_STRNDUP)
98 INCLUDE (CheckCXXSourceCompiles)
99 CHECK_CXX_SOURCE_COMPILES("typedef void *(* voidvoid)(void);
103 function = (voidvoid) object;
104 " PERMITS_OBJECT_TO_FUNCTION_CAST)
106 IF( NOT PERMITS_OBJECT_TO_FUNCTION_CAST )
107 SET(HAVE_FORBIDDEN_OBJECT_TO_FUNCTION_CAST 1)
108 ENDIF( NOT PERMITS_OBJECT_TO_FUNCTION_CAST )
112 SET(HAS_VORBIS_SUPPORT 1)
114 SET(VORBIS_LIBRARY "")
115 ENDIF(VORBIS_LIBRARY)
118 FIND_LIBRARY(SDL_MAIN_LIBRARY_PATH SDLmain)
119 FIND_LIBRARY(COCOA_LIBRARY_PATH Cocoa)
122 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
124 #Plugin addition macro
125 MACRO(ADD_GEMRB_PLUGIN plugin_name)
126 ADD_LIBRARY(${plugin_name} MODULE ${ARGN})
127 SET_TARGET_PROPERTIES(${plugin_name} PROPERTIES PREFIX "")
129 TARGET_LINK_LIBRARIES(${plugin_name} gemrb_core)
132 TARGET_LINK_LIBRARIES(${plugin_name} gemrb_core)
134 INSTALL(TARGETS ${plugin_name} DESTINATION ${PLUGIN_INSTALL_DIR})
135 ENDMACRO(ADD_GEMRB_PLUGIN)
137 #gemrb overrides macro
138 MACRO(ADD_GEMRB_OVERRIDE game_name)
139 FILE( GLOB FILES_TO_INSTALL *.2da *.bmp *.ini *.chu *.ids *.bcs *.vvc *.mos *.spl *.wav *.pro)
140 INSTALL( FILES ${FILES_TO_INSTALL} DESTINATION ${OVERRIDE_INSTALL_DIR}/${game_name} )
141 ENDMACRO(ADD_GEMRB_OVERRIDE )
143 ADD_SUBDIRECTORY( gemrb )
144 INSTALL( FILES gemrb.6 DESTINATION ${MANPAGE_INSTALL_DIR} )
147 "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
148 "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
152 ADD_CUSTOM_TARGET( uninstall
153 "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" )