2008-05-05 20:43:39 +00:00
# most stuff should be implemented so far, mgoe should know the details (he has done all the work...)
# what is not working so far:
2008-05-15 04:31:36 +00:00
# * The fribidi check doesn't distinguish between version 1 and version 2
# Wesnoth only works with version 1 currently, so if version 2 is installed,
2008-05-15 14:56:38 +00:00
# it should be treated the same as if it wasn't present. (This should be fixed, please test)
2008-05-18 13:53:40 +00:00
# The fribidi test for fribidi_utf8_to_unicode succeeds when it shouldn't.
# I looked through the header files for that string and didn't find it,
# so I don't know why the test is succeeding.
2008-05-05 20:43:39 +00:00
# * some other smaller stuff
# * nice INSTALL howto
2008-05-01 20:12:38 +00:00
2008-05-07 08:13:25 +00:00
# set minimum version and make sure that things work with cmake 2.6, too
2008-05-15 16:40:36 +00:00
cmake_minimum_required ( VERSION 2.4.6 )
2008-05-07 08:13:25 +00:00
if ( COMMAND cmake_policy )
cmake_policy ( SET CMP0003 NEW )
cmake_policy ( SET CMP0005 OLD )
endif ( COMMAND cmake_policy )
2008-05-09 10:53:45 +00:00
set ( CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
2008-05-05 21:06:14 +00:00
# use our own version of FindBoost.cmake and other Find* scripts
2008-05-04 20:32:01 +00:00
set ( CMAKE_MODULE_PATH ${ CMAKE_SOURCE_DIR } /cmake )
2008-05-04 20:11:11 +00:00
2008-05-01 20:12:38 +00:00
# find all deps needed
2008-05-15 14:56:38 +00:00
find_package ( SDL 1.2.7 REQUIRED )
find_package ( Boost 1.33 REQUIRED COMPONENTS iostreams regex )
find_package ( Gettext )
find_package ( FriBiDi )
find_package ( PythonInterp 2.4 )
find_package ( PythonCustom )
2008-05-05 22:22:28 +00:00
2008-05-13 09:11:18 +00:00
#
# Options
#
2008-05-04 17:27:28 +00:00
2008-05-13 09:11:18 +00:00
#Path options
2008-05-04 17:27:28 +00:00
set ( BINDIR "bin" CACHE STRING "Where to install binaries" )
2008-05-12 23:00:16 +00:00
set ( MANDIR "man" CACHE STRING "Where to install manpages" )
2008-05-08 19:19:15 +00:00
set ( DATAROOTDIR "${CMAKE_INSTALL_PREFIX}/share" CACHE STRING "Sets the root of data directories to a non-default location" )
2008-05-12 23:00:16 +00:00
set ( DOCDIR "${DATAROOTDIR}/doc/wesnoth" CACHE STRING "Sets the doc directory to a non-default location." )
2008-05-08 19:35:40 +00:00
set ( DATADIRNAME "wesnoth" CACHE STRING "change the name of the directory for the read-only architecture-independent game data" )
2008-05-08 20:32:54 +00:00
set ( LOCALEDIR "translations" CACHE STRING "change the name of the locale data directory to a non-default name" )
2008-05-04 17:27:28 +00:00
set ( PREFERENCES_DIR "" CACHE STRING "Use a non-default preferences directory (.wesnoth on unix)" )
2008-05-13 09:11:18 +00:00
2008-05-15 14:56:38 +00:00
#Game options
2008-05-13 09:11:18 +00:00
option ( ENABLE_PYTHON "Enable in-game python extensions" ON )
2008-05-14 12:15:17 +00:00
option ( ENABLE_FRIBIDI "Enable FriBIDi support" ON )
2008-05-15 14:56:38 +00:00
option ( ENABLE_DUMMY_LOCALES "Create dummy locales" )
2008-05-04 17:27:28 +00:00
set ( GUI "normal" CACHE STRING "Set for GUI reductions for resolutions down to 800x480 (eeePC, Nokia 8x0) or 320x240 (PDAs) (normal|small|tiny)" )
2008-05-13 09:11:18 +00:00
#server options
set ( SERVER_UID "" CACHE STRING "User id of the user who runs wesnothd" )
set ( SERVER_GID "" CACHE STRING "Group id of the user who runs wesnothd" )
set ( FIFO_DIR "/var/run/wesnothd" CACHE STRING "Directory for the wesnothd fifo socket file" )
#build options
2008-05-05 21:06:14 +00:00
option ( ENABLE_GAME "Enable compilation of the game" ON )
option ( ENABLE_CAMPAIGN_SERVER "Enable compilation of campaign server" )
option ( ENABLE_SERVER "Enable compilation of server" ON )
option ( ENABLE_EDITOR "Enable compilation of map editor" )
option ( ENABLE_TOOLS "Enable building and installation of tools for artists and WML maintainers" )
option ( ENABLE_TESTS "Build unit tests" )
2008-05-15 14:56:38 +00:00
option ( ENABLE_NLS "Enable building of tranlations" ON )
set ( BINARY_SUFFIX "" CACHE STRING "Suffix behind all binaries" )
set ( BINARY_PREFIX "" CACHE STRING "Prefix in front of all binaries" )
2008-05-05 21:06:14 +00:00
2008-05-13 09:11:18 +00:00
#
# Handle options (set paths/definitions/etc...)
#
2008-05-05 21:06:14 +00:00
2008-05-15 14:56:38 +00:00
# Set our own default debug flags at first run
2008-05-12 23:00:16 +00:00
if ( NOT CONFIGURED )
set ( CMAKE_CXX_FLAGS_DEBUG "-O0 -DDEBUG -ggdb3 -W -Wall -ansi" CACHE STRING "Flags used by the compiler during debug builds." FORCE )
endif ( NOT CONFIGURED )
2008-05-15 14:56:38 +00:00
#Add build-type: DEBUGSTRICT
2008-05-15 13:02:11 +00:00
set ( CMAKE_CXX_FLAGS_DEBUGSTRICT "-O0 -DDEBUG -ggdb3 -W -Wall -ansi -Werror -Wno-unused -Wno-sign-compare" CACHE STRING "Flags used by the compiler during strict debug builds." )
set ( CMAKE_EXE_LINKER_FLAGS_DEBUGSTRICT "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "Flags used for linking binaries during strict debug builds." )
2008-05-15 14:56:38 +00:00
mark_as_advanced ( CMAKE_CXX_FLAGS_DEBUGSTRICT CMAKE_EXE_LINKER_FLAGS_DEBUGSTRICT )
2008-05-15 13:02:11 +00:00
2008-05-08 19:19:15 +00:00
# compose datadir path of datarootdir and datadirname
set ( DATADIR ${ DATAROOTDIR } / ${ DATADIRNAME } )
2008-05-08 19:35:40 +00:00
2008-05-04 17:27:28 +00:00
if ( NOT WIN32 )
2008-05-08 19:19:15 +00:00
add_definitions ( -DWESNOTH_PATH='\ "${DATADIR}\" ' )
2008-05-04 17:27:28 +00:00
endif ( NOT WIN32 )
2008-05-08 20:19:07 +00:00
add_definitions ( -DHAS_RELATIVE_LOCALEDIR )
2008-05-09 01:49:21 +00:00
add_definitions ( -DLOCALEDIR='\ "${LOCALEDIR}\" ' )
2008-05-08 20:32:54 +00:00
set ( LOCALE_INSTALL ${ DATADIR } / ${ LOCALEDIR } )
2008-05-04 17:27:28 +00:00
2008-05-13 09:11:18 +00:00
add_definitions ( -DFIFODIR='\ "${FIFO_DIR}\" ' )
2008-05-04 17:27:28 +00:00
if ( PREFERENCES_DIR )
add_definitions ( -DPREFERENCES_DIR='\ "${PREFERENCES_DIR}\" ' )
endif ( PREFERENCES_DIR )
if ( GUI STREQUAL "tiny" )
add_definitions ( -DUSE_TINY_GUI )
elseif ( GUI STREQUAL "small" )
add_definitions ( -DUSE_SMALL_GUI )
endif ( GUI STREQUAL "tiny" )
2008-05-15 14:56:38 +00:00
if ( ENABLE_PYTHON AND PYTHON_LIBRARIES )
2008-05-04 17:27:28 +00:00
add_definitions ( -DHAVE_PYTHON )
2008-05-15 14:56:38 +00:00
elseif ( ENABLE_PYTHON AND NOT PYTHON_LIBRARIES )
message ( "Could not find Python. Disabling Python support." )
endif ( )
2008-05-04 17:27:28 +00:00
2008-05-14 12:15:17 +00:00
if ( ENABLE_FRIBIDI AND FRIBIDI_LIBRARIES )
add_definitions ( -DHAVE_FRIBIDI )
2008-05-15 14:56:38 +00:00
elseif ( ENABLE_FRIBIDI AND NOT FRIBIDI_LIBRARIES )
message ( "Could not find FriBiDi. Disabling FriBiDi support." )
endif ( )
2008-05-12 23:00:16 +00:00
2008-05-15 13:02:11 +00:00
#
# Libraries that are only required by some targets
#
if ( ENABLE_TOOLS OR ENABLE_GAME OR ENABLE_EDITOR OR ENABLE_TESTS )
2008-05-15 14:56:38 +00:00
find_package ( SDL_image 1.2 REQUIRED )
2008-05-15 13:02:11 +00:00
endif ( )
if ( ENABLE_GAME OR ENABLE_EDITOR OR ENABLE_TESTS )
2008-05-15 14:56:38 +00:00
find_package ( SDL_mixer 1.2 REQUIRED )
find_package ( SDL_ttf 2.0.8 REQUIRED )
2008-05-15 13:02:11 +00:00
endif ( )
if ( ENABLE_GAME OR ENABLE_SERVER OR ENABLE_CAMPAIGN_SERVER OR ENABLE_TESTS )
2008-05-15 14:56:38 +00:00
find_package ( SDL_net REQUIRED )
2008-05-15 13:02:11 +00:00
endif ( )
if ( ENABLE_TOOLS )
2008-05-15 14:56:38 +00:00
find_package ( ZLIB REQUIRED )
find_package ( PNG REQUIRED )
2008-05-15 13:02:11 +00:00
endif ( )
2008-05-15 14:56:38 +00:00
# get languages
file ( READ po/LINGUAS LINGUAS )
string ( REPLACE "\n" "" LINGUAS ${ LINGUAS } )
separate_arguments ( LINGUAS )
#
# Include subdirectories
#
add_subdirectory ( doc )
if ( GETTEXT_FOUND AND ENABLE_NLS )
add_subdirectory ( po )
endif ( GETTEXT_FOUND AND ENABLE_NLS )
add_subdirectory ( src )
2008-05-15 13:02:11 +00:00
2008-05-14 13:00:50 +00:00
#
2008-05-09 10:53:45 +00:00
#create dummy-locales
2008-05-14 13:00:50 +00:00
#
2008-05-09 10:53:45 +00:00
if ( ENABLE_DUMMY_LOCALES )
add_definitions ( -DUSE_DUMMYLOCALES )
set ( DUMMY_LOCALE_C_DIR ${ CMAKE_SOURCE_DIR } /locales/C )
add_custom_command ( OUTPUT ${ DUMMY_LOCALE_C_DIR }
C O M M A N D m k d i r - p $ { D U M M Y _ L O C A L E _ C _ D I R }
& & e c h o | l o c a l e d e f - - f o r c e $ { D U M M Y _ L O C A L E _ C _ D I R } 2 > / d e v / n u l l | | t r u e )
file ( GLOB_RECURSE LANGS RELATIVE ${ CMAKE_SOURCE_DIR } /data/languages data/languages/*.cfg )
set ( DUMMY_LOCALES )
foreach ( LANGFILE ${ LANGS } )
string ( REGEX REPLACE "(.*)\\.cfg" "\\1" LANG ${ LANGFILE } )
if ( NOT LANG STREQUAL "C" )
set ( DUMMY_LOCALE_DIR ${ CMAKE_SOURCE_DIR } /locales/ ${ LANG } )
add_custom_command ( OUTPUT ${ DUMMY_LOCALE_DIR }
C O M M A N D l n - s
A R G S $ { D U M M Y _ L O C A L E _ C _ D I R } $ { D U M M Y _ L O C A L E _ D I R }
D E P E N D S $ { D U M M Y _ L O C A L E _ C _ D I R } )
set ( DUMMY_LOCALES ${ DUMMY_LOCALES } ${ DUMMY_LOCALE_DIR } )
2008-05-15 14:56:38 +00:00
endif ( )
2008-05-09 10:53:45 +00:00
2008-05-15 14:56:38 +00:00
endforeach ( )
add_custom_target ( dummy-locales ALL DEPENDS ${ DUMMY_LOCALES } )
2008-05-09 10:53:45 +00:00
2008-05-12 23:00:16 +00:00
# this is a workaround for a bug in 2.4-7
file ( MAKE_DIRECTORY locales )
2008-05-09 10:53:45 +00:00
install ( DIRECTORY locales DESTINATION ${ DATADIR } )
2008-05-15 14:56:38 +00:00
endif ( )
2008-05-01 20:12:38 +00:00
2008-05-14 13:00:50 +00:00
#
# shrink images for tinygui
#
2008-05-09 01:49:21 +00:00
if ( GUI STREQUAL "tiny" )
FIND_PACKAGE ( ImageMagick REQUIRED )
2008-05-05 21:06:14 +00:00
2008-05-09 01:49:21 +00:00
if ( ${ CMAKE_SOURCE_DIR } STREQUAL ${ CMAKE_BINARY_DIR } )
set ( IMAGE_BUILD_DIR ${ CMAKE_SOURCE_DIR } /tiny_images )
2008-05-12 23:00:16 +00:00
else ( )
2008-05-09 01:49:21 +00:00
set ( IMAGE_BUILD_DIR ${ CMAKE_BINARY_DIR } )
2008-05-15 14:56:38 +00:00
endif ( )
2008-05-09 01:49:21 +00:00
set ( IMAGE_FILES data/*.jpg data/*.png images/*.jpg images/*.png )
add_custom_target ( shrink-images ALL
C O M M A N D $ { C M A K E _ C O M M A N D }
A R G S - D I M A G E _ F I L E S = " $ { I M A G E _ F I L E S } " - D I M A G E _ B U I L D _ D I R = " $ { I M A G E _ B U I L D _ D I R } " - D I M A G E M A G I C K _ I D E N T I F Y _ E X E C U T A B L E = " $ { I M A G E M A G I C K _ I D E N T I F Y _ E X E C U T A B L E } " - D I M A G E M A G I C K _ C O N V E R T _ E X E C U T A B L E = " $ { I M A G E M A G I C K _ C O N V E R T _ E X E C U T A B L E } " - P " $ { C M A K E _ S O U R C E _ D I R } / c m a k e / S h r i n k I m a g e s . c m a k e "
2008-05-09 11:00:19 +00:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ S O U R C E _ D I R }
C O M M E N T " C r e a t i n g r e s i z e d i m a g e s f o r t i n y g u i . " )
2008-05-09 01:49:21 +00:00
2008-05-15 14:56:38 +00:00
#
# Install files (exclude images from data-dir, we install them from our build dir)
#
2008-05-05 22:22:28 +00:00
2008-05-12 23:00:16 +00:00
# this is a workaround for a bug in 2.4-7
file ( MAKE_DIRECTORY ${ IMAGE_BUILD_DIR } /data ${ IMAGE_BUILD_DIR } /images )
2008-05-09 01:49:21 +00:00
install ( DIRECTORY ${ IMAGE_BUILD_DIR } /data ${ IMAGE_BUILD_DIR } /images DESTINATION ${ DATADIR } )
install ( DIRECTORY data fonts sounds DESTINATION ${ DATADIR }
P A T T E R N " * . p n g " E X C L U D E
P A T T E R N " * . j p g " E X C L U D E
P A T T E R N " . s v n " E X C L U D E )
2008-05-09 10:53:45 +00:00
else ( )
2008-05-05 22:22:28 +00:00
2008-05-15 14:56:38 +00:00
#
# Install files
#
2008-05-09 01:49:21 +00:00
install ( DIRECTORY data fonts images sounds DESTINATION ${ DATADIR } PATTERN ".svn" EXCLUDE )
2008-05-01 20:12:38 +00:00
2008-05-15 14:56:38 +00:00
endif ( )
2008-05-09 01:49:21 +00:00
2008-05-13 09:11:18 +00:00
if ( ENABLE_SERVER AND FIFO_DIR )
2008-05-13 18:28:39 +00:00
install ( CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory \$ENV{DESTDIR}/${FIFO_DIR})" )
2008-05-13 09:11:18 +00:00
if ( SERVER_UID AND SERVER_GID )
2008-05-13 18:28:39 +00:00
install ( CODE "execute_process(COMMAND chown ${SERVER_UID}:${SERVER_GID} \$ENV{DESTDIR}/${FIFO_DIR})" )
2008-05-15 14:56:38 +00:00
endif ( )
endif ( )
2008-05-14 13:00:50 +00:00
2008-05-09 01:49:21 +00:00
#
2008-05-14 13:00:50 +00:00
# uninstall
2008-05-09 01:49:21 +00:00
#
2008-05-01 20:12:38 +00:00
2008-05-14 13:00:50 +00:00
configure_file (
" $ { C M A K E _ S O U R C E _ D I R } / c m a k e / u n i n s t a l l . c m a k e . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n i n s t a l l . c m a k e "
I M M E D I A T E @ O N L Y )
add_custom_target ( uninstall
" $ { C M A K E _ C O M M A N D } " - P " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / u n i n s t a l l . c m a k e " )
#
# Packaging stuff
#
2008-05-09 01:49:21 +00:00
2008-05-15 14:56:38 +00:00
include ( CPack )
set ( CPACK_GENERATOR "TGZ" )
set ( CPACK_SOURCE_GENERATOR "TGZ" )
2008-05-09 22:07:30 +00:00
set ( CONFIGURED ON CACHE INTERNAL "" )