WID comments
[Lilanci.git] / CMakeLists.txt
blob9d00603e54e7e7d39895739d0915452f314e926a
1 CMAKE_MINIMUM_REQUIRED ( VERSION 2.4.0 )
3 PROJECT(Lilanci C)
4 # -DINSTALLLESS=path we don't want to install it anywhere, just run it from
5 # data in source tree, path is path to source
6 SET( APPNAME "lilanci" )
9 IF ( INSTALLLESS )
10         MESSAGE ( "*****************************")
11         MESSAGE ( "INSTALLLESS")
12         MESSAGE ( "please don't run make install" )
13         MESSAGE ( "*****************************")
15         SET ( CMAKE_CONF_PATH "/etc" CACHE PATH "Config path prefix" )
16         SET ( CMAKE_INSTALL_PREFIX "/usr/local/" CACHE PATH "Install path prefix" )
17         SET ( CMAKE_DOC_PATH "${INSTALLLESS}/doc" CACHE PATH "Data path prefix" )
18         SET ( CMAKE_LOCALE_PATH "${INSTALLLESS}/locale" CACHE PATH "Locale path prefix" )
19         SET ( CMAKE_DATA_PATH "${INSTALLLESS}/" CACHE PATH "Data path prefix" )
20         SET ( CMAKE_DATA_PATH_DIR "${INSTALLLESS}/" CACHE PATH "Data path prefix" )
21         SET ( CMAKE_LIB_PATH "${INSTALLLESS}/lib/" CACHE PATH "Library path prefix" )
22         SET ( LIB_INSTALL_DIR "${INSTALLLESS}" )
23         SET ( CMAKE_FONT "${INSTALLLESS}/font/DejaVuSans.ttf" CACHE PATH "Font" )
24         SET ( CMAKE_INSTALL_ETCDIR ${CMAKE_CONF_PATH} )
25         SET ( CMAKE_INSTALL_BINDIR bin )
26         SET ( CMAKE_INSTALL_LOCALEDIR ${CMAKE_LOCALE_PATH} )
27         SET ( CMAKE_INSTALL_DATADIR ${CMAKE_DATA_PATH} )
28         SET ( CMAKE_INSTALL_DATADIRDIR ${CMAKE_DATA_PATH_DIR} )
29         SET ( CMAKE_INSTALL_LIBDIR ${LIB_INSTALL_DIR} )
30         SET ( CMAKE_INSTALL_DOCDIR ${CMAKE_DOC_PATH} )
31 ELSE ( INSTALLLESS )
32         SET ( CMAKE_CONF_PATH "/etc" CACHE PATH "Config path prefix" )
33         SET ( CMAKE_INSTALL_PREFIX "/usr/local/" CACHE PATH "Install path prefix" )
34         SET ( CMAKE_DOC_PATH "${CMAKE_INSTALL_PREFIX}/share/doc" CACHE PATH "Data path prefix" )
35         SET ( CMAKE_LOCALE_PATH "${CMAKE_INSTALL_PREFIX}/share/locale" CACHE PATH "Locale path prefix" )
36         SET ( CMAKE_DATA_PATH "${CMAKE_INSTALL_PREFIX}/share/" CACHE PATH "Data path prefix" )
37         SET ( CMAKE_DATA_PATH_DIR "${CMAKE_DATA_PATH}/${APPNAME}/" CACHE PATH "Data path" )
38         SET ( CMAKE_LIB_PATH "${CMAKE_INSTALL_PREFIX}/lib/" CACHE PATH "Library path prefix" )
39         SET ( LIB_INSTALL_DIR "${CMAKE_LIB_PATH}" )
41         SET ( CMAKE_FONT "${CMAKE_DATA_PATH}/${APPNAME}/font/DejaVuSans.ttf" CACHE PATH "Font" )
42         SET ( CMAKE_INSTALL_ETCDIR ${CMAKE_CONF_PATH} )
43         SET ( CMAKE_INSTALL_BINDIR bin )
44         SET ( CMAKE_INSTALL_LOCALEDIR ${CMAKE_LOCALE_PATH} )
45         SET ( CMAKE_INSTALL_DATADIR ${CMAKE_DATA_PATH} )
46         SET ( CMAKE_INSTALL_DATADIRDIR ${CMAKE_DATA_PATH_DIR} )
47         SET ( CMAKE_INSTALL_LIBDIR ${LIB_INSTALL_DIR} )
48         SET ( CMAKE_INSTALL_DOCDIR ${CMAKE_DOC_PATH} )
49 ENDIF ( INSTALLLESS )
51 #INCLUDE(UsePkgConfig)
52 #PKGCONFIG(glu GLU_INCLUDE_DIR GLU_LIBRARY_DIR GLU_LINK_FLAGS GLU_CFLAGS)
53 #PKGCONFIG(sdl SDL_INCLUDE_DIR SDL_LIBRARY_DIR SDL_LINK_FLAGS SDL_CFLAGS)
54 #PKGCONFIG(cairo CAIRO_INCLUDE_DIR CAIRO_LIBRARY_DIR CAIRO_LINK_FLAGS CAIRO_CFLAGS)
55 #PKGCONFIG(librsvg-2.0 RSVG_INCLUDE_DIR RSVG_LIBRARY_DIR RSVG_LINK_FLAGS RSVG_CFLAGS)
56 #FIND_PACKAGE ( GLU REQUIRED )
57 INCLUDE(FindPkgConfig OPTIONAL RESULT_VARIABLE PKGCONFIGFOUND)
58 FIND_PACKAGE ( OpenGL REQUIRED )
59 FIND_PACKAGE ( SDL REQUIRED )
60 FIND_PACKAGE ( SDL_mixer REQUIRED )
61 INCLUDE_DIRECTORIES (
62         ${SDL_INCLUDE_DIR}
63         ${OPENGL_INCLUDE_DIR}
64         ${SDLMIXER_INCLUDE_DIR}
66 LINK_LIBRARIES (
67         ${SDL_LIBRARY}
68         ${OPENGL_LIBRARY}
69         ${SDLMIXER_LIBRARY}
71 IF ( "${PKGCONFIGFOUND}" STREQUAL "NOTFOUND")
72         MESSAGE ("We don't have FindPkgConfig, failing back on UsePkgConfig")
73         INCLUDE(UsePkgConfig)
74         PKGCONFIG(cairo CAIRO_INCLUDE_DIRS CAIRO_LIBRARY_DIR CAIRO_LINK_FLAGS CAIRO_CFLAGS)
75         PKGCONFIG(librsvg-2.0 RSVG_INCLUDE_DIRS RSVG_LIBRARY_DIR RSVG_LINK_FLAGS RSVG_CFLAGS)
76         PKGCONFIG(ftgl FTGL_INCLUDE_DIRS FTGL_LIBRARY_DIR FTGL_LINK_FLAGS FTGL_CFLAGS)
77 ELSE ( "${PKGCONFIGFOUND}" STREQUAL "NOTFOUND")
78         PKG_CHECK_MODULES( CAIRO cairo )
79         PKG_CHECK_MODULES( RSVG librsvg-2.0 )
80         PKG_CHECK_MODULES( FTGL ftgl )
81         LINK_LIBRARIES (
82                 ${CAIRO_LIBRARIES}
83                 ${RSVG_LIBRARIES}
84                 ${FTGL_LIBRARIES}
85         )
86         INCLUDE_DIRECTORIES (
87                 ${CAIRO_INCLUDE_DIRS}
88                 ${RSVG_INCLUDE_DIRS}
89                 ${FTGL_INCLUDE_DIRS}
90                 ${CMAKE_BINARY_DIR}
91         )
92 ENDIF ( "${PKGCONFIGFOUND}" STREQUAL "NOTFOUND")
95 #LINK_DIRECTORIES(${SDL_LIBRARY_DIR} ${CAIRO_LIBRARY_DIR} ${RSVG_LIBRARY_DIR} ${GLU_LIBRARY_DIR})
96 #INCLUDE_DIRECTORIES(${SDL_INCLUDE_DIR} ${CAIRO_INCLUDE_DIR} ${RSVG_INCLUDE_DIR} ${GLU_INCLUDE_DIR})
98 ADD_EXECUTABLE(elilanci elilanci.c geometry.c gr.c config.c map.c snd.c particle.c font.c)
99 IF ( "${PKGCONFIGFOUND}" STREQUAL "NOTFOUND")
100         SET_TARGET_PROPERTIES( elilanci PROPERTIES LINK_FLAGS "${CAIRO_LINK_FLAGS}      ${RSVG_LINK_FLAGS} ${FTGL_LINK_FLAGS}")
101         SET_TARGET_PROPERTIES( elilanci PROPERTIES COMPILE_FLAGS "${CAIRO_CFLAGS}       ${RSVG_CFLAGS} ${FTGL_CFLAGS}")
102 ENDIF ( "${PKGCONFIGFOUND}" STREQUAL "NOTFOUND")
104 ADD_SUBDIRECTORY (graphics)
105 ADD_SUBDIRECTORY (sounds)
106 CONFIGURE_FILE ( path.h.in path.h)
107 install(TARGETS elilanci
108         RUNTIME DESTINATION bin
111 CONFIGURE_FILE(
112   "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
113   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
114   IMMEDIATE @ONLY)
116 ADD_CUSTOM_TARGET(uninstall
117   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")