Add (some) install functionaltiy and compile options to cmake build system.

This commit is contained in:
Moritz Göbelbecker 2008-05-04 17:27:28 +00:00
parent 694d043832
commit ae87049234
2 changed files with 101 additions and 7 deletions

View file

@ -7,12 +7,67 @@ FIND_PACKAGE( SDL_mixer 1.2 REQUIRED )
FIND_PACKAGE( SDL_net REQUIRED )
FIND_PACKAGE( SDL_ttf 2.0.8 REQUIRED )
# setting python to a "must have" for the moment, can later on be changed to be optional
FIND_PACKAGE( PythonInterp 2.4 REQUIRED )
FIND_PACKAGE( PythonLibs 2.4 REQUIRED )
FIND_PACKAGE( PythonInterp 2.4 )
FIND_PACKAGE( PythonLibs 2.4 )
FIND_PACKAGE( Boost 1.33 REQUIRED COMPONENTS boost_iostream boost_regex )
FIND_PACKAGE( ZLIB REQUIRED )
FIND_PACKAGE( PNG REQUIRED )
#Options
set(BINDIR "bin" CACHE STRING "Where to install binaries")
set(DATAROOTDIR "share" CACHE STRING "Sets the root of data directories to a non-default location")
set(DATADIR "${DATAROOTDIR}/wesnoth" CACHE STRING "Read-only architecture-independent game data")
set(LOCALEDIR "${DATADIR}/translations" CACHE STRING "sets the locale data directory to a non-default location")
set(PREFERENCES_DIR "" CACHE STRING "Use a non-default preferences directory (.wesnoth on unix)")
set(GUI "normal" CACHE STRING "Set for GUI reductions for resolutions down to 800x480 (eeePC, Nokia 8x0) or 320x240 (PDAs) (normal|small|tiny)")
if(NOT WIN32)
if(IS_ABSOLUTE DATADIR)
add_definitions(-DWESNOTH_PATH='\"${DATADIR}\"')
message("set -DWESNOTH_PATH='\"${DATADIR}\"'")
else(IS_ABSOLUTE DATADIR)
add_definitions(-DWESNOTH_PATH='\"${CMAKE_INSTALL_PREFIX}/${DATADIR}\"')
message("set -DWESNOTH_PATH='\"${CMAKE_INSTALL_PREFIX}/${DATADIR}\"'")
endif(IS_ABSOLUTE DATADIR)
endif(NOT WIN32)
add_definitions(-DLOCALEDIR=='\"${LOCALEDIR}\"')
message("set -DLOCALEDIR='\"${LOCALEDIR}\"'")
if(NOT IS_ABSOLUTE LOCALEDIR)
add_definitions(-DHAS_RELATIVE_LOCALEDIR)
message("set -DHAS_RELATIVE_LOCALEDIR")
endif(NOT IS_ABSOLUTE LOCALEDIR)
if(PREFERENCES_DIR)
add_definitions(-DPREFERENCES_DIR='\"${PREFERENCES_DIR}\"')
message("set -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")
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")
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")
option(ENABLE_PYTHON "Enable in-game python extensions" ON)
if(ENABLE_PYTHON AND PYTHON_LIBRARY)
add_definitions(-DHAVE_PYTHON)
message("set -DHAVE_PYTHON")
endif(ENABLE_PYTHON AND PYTHON_LIBRARY)
#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
# only one of the subdirs working so far...
@ -32,6 +87,7 @@ add_subdirectory(src)
#install(FILES copyright changelog players_changelog campaign_server.dsp editor.dev editor_gcc4.dev map_editor.dsp server.dev server.dsp unit_test.dev wesnothd.dev wesnoth.dev wesnothd_gcc4.dev wesnoth.dsp wesnoth.dsw wesnoth_gcc4.dev wesnoth.kdevelop DESTINATION )
#install(FILES DESTINATION /share/@DATADIR@)
install(DIRECTORY data fonts images sounds translations DESTINATION ${DATADIR})
#original Makefile.am contents follow:

View file

@ -46,7 +46,7 @@ SET(libwesnoth-core_STAT_SRC
# a 'lib' is automatically set in front when creating the library (as in the filename)
# internal reference is the name given here
add_library(wesnoth-core STATIC ${libwesnoth-core_STAT_SRC})
add_library(wesnoth-core STATIC EXCLUDE_FROM_ALL ${libwesnoth-core_STAT_SRC})
########### libwesnoth-game ###############
# rename libwesnoth.a to libwesnoth-game.a to have clearer targets
@ -104,10 +104,12 @@ SET(libwesnoth-game_STAT_SRC
# a 'lib' is automatically set in front when creating the library (as in the filename)
# internal reference is the name given here
add_library(wesnoth-game STATIC ${libwesnoth-game_STAT_SRC})
add_library(wesnoth-game STATIC EXCLUDE_FROM_ALL ${libwesnoth-game_STAT_SRC})
########### Wesnoth ###############
IF(ENABLE_GAME)
SET(wesnoth-main_SRC
about.cpp
actions.cpp
@ -205,8 +207,14 @@ SET(wesnoth_SRC
ADD_EXECUTABLE(wesnoth ${wesnoth_SRC})
TARGET_LINK_LIBRARIES(wesnoth wesnoth-core wesnoth-game ${the-external-libs})
INSTALL(TARGETS wesnoth DESTINATION ${BINDIR})
ENDIF(ENABLE_GAME)
########### Editor ###############
IF(ENABLE_EDITOR)
SET(wesnoth_editor_SRC
editor/editor.cpp
editor/editor_layout.cpp
@ -224,8 +232,14 @@ SET(wesnoth_editor_SRC
ADD_EXECUTABLE(wesnoth_editor ${wesnoth_editor_SRC})
TARGET_LINK_LIBRARIES(wesnoth_editor wesnoth-core wesnoth-game ${the-external-libs})
INSTALL(TARGETS wesnoth_editor DESTINATION ${BINDIR})
ENDIF(ENABLE_EDITOR)
########### Wesnothd Server ###############
IF(ENABLE_SERVER)
SET(wesnothd_SRC
server/game.cpp
server/input_stream.cpp
@ -242,8 +256,14 @@ SET(wesnothd_SRC
ADD_EXECUTABLE(wesnothd ${wesnothd_SRC})
TARGET_LINK_LIBRARIES(wesnothd wesnoth-core ${the-external-libs})
INSTALL(TARGETS wesnothd DESTINATION ${BINDIR})
ENDIF(ENABLE_SERVER)
########### Campaign Server ###############
IF(ENABLE_CAMPAIGN_SERVER)
SET(campaignd_SRC
campaign_server/campaign_server.cpp
network.cpp
@ -255,8 +275,14 @@ SET(campaignd_SRC
ADD_EXECUTABLE(campaignd ${campaignd_SRC})
TARGET_LINK_LIBRARIES(campaignd wesnoth-core ${the-external-libs})
INSTALL(TARGETS campaignd DESTINATION ${BINDIR})
ENDIF(ENABLE_CAMPAIGN_SERVER)
########### Castle building helpers ###############
IF(ENABLE_TOOLS)
SET(exploder_SRC
tools/exploder.cpp
tools/exploder_utils.cpp
@ -270,6 +296,8 @@ SET(exploder_SRC
ADD_EXECUTABLE(exploder ${exploder_SRC})
TARGET_LINK_LIBRARIES(exploder wesnoth-core ${the-external-libs} png12)
INSTALL(TARGETS exploder DESTINATION ${BINDIR})
SET(cutter_SRC
tools/cutter.cpp
tools/exploder_utils.cpp
@ -282,16 +310,26 @@ SET(cutter_SRC
ADD_EXECUTABLE(cutter ${cutter_SRC})
TARGET_LINK_LIBRARIES(cutter wesnoth-core ${the-external-libs} png12)
INSTALL(TARGETS cutter DESTINATION ${BINDIR})
ENDIF(ENABLE_TOOLS)
########### Unit tests ###############
SET(exploder_SRC
IF(ENABLE_TESTS)
ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK)
SET(test_SRC
tests/main.cpp
tests/test_util.cpp
${wesnoth-main_SRC}
)
ADD_EXECUTABLE(test ${wesnoth_SRC})
TARGET_LINK_LIBRARIES(test wesnoth-core wesnoth-game ${the-external-libs})
ADD_EXECUTABLE(test ${test_SRC})
TARGET_LINK_LIBRARIES(test wesnoth-core wesnoth-game ${the-external-libs} boost_unit_test_framework)
ENDIF(ENABLE_TESTS)
########### install files ###############