Modularize dependencies in cmake build.
Only require libs that are needed for enabled targets.
This commit is contained in:
parent
79f14f3851
commit
130f897a72
2 changed files with 79 additions and 28 deletions
|
@ -1,7 +1,5 @@
|
|||
# most stuff should be implemented so far, mgoe should know the details (he has done all the work...)
|
||||
# what is not working so far:
|
||||
# * "uninstall" target (this is at least partially done)
|
||||
# * Strict compilation (-Werror -Wno-unused -Wno-sign-compare)
|
||||
# * 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,
|
||||
# it should be treated the same as if it wasn't present.
|
||||
|
@ -25,17 +23,10 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
|||
|
||||
# find all deps needed
|
||||
FIND_PACKAGE( SDL 1.2.7 REQUIRED )
|
||||
FIND_PACKAGE( SDL_image 1.2 REQUIRED )
|
||||
FIND_PACKAGE( SDL_mixer 1.2 REQUIRED )
|
||||
FIND_PACKAGE( SDL_net REQUIRED )
|
||||
FIND_PACKAGE( SDL_ttf 2.0.8 REQUIRED )
|
||||
FIND_PACKAGE( Boost 1.33 REQUIRED COMPONENTS iostreams regex )
|
||||
FIND_PACKAGE( ZLIB REQUIRED )
|
||||
FIND_PACKAGE( PNG REQUIRED )
|
||||
FIND_PACKAGE( Gettext )
|
||||
FIND_PACKAGE( FriBiDi )
|
||||
|
||||
|
||||
#Really find python
|
||||
FIND_PACKAGE( PythonInterp 2.4 )
|
||||
if(PYTHON_EXECUTABLE AND NOT PYTHON_LIBRARY)
|
||||
|
@ -112,6 +103,11 @@ 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)
|
||||
|
||||
#Build-type: DEBUGSTRICT
|
||||
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.")
|
||||
MARK_AS_ADVANCED(CMAKE_CXX_FLAGS_DEBUGSTRICT CMAKE_EXE_LINKER_FLAGS_DEBUGSTRICT)
|
||||
|
||||
# compose datadir path of datarootdir and datadirname
|
||||
set(DATADIR ${DATAROOTDIR}/${DATADIRNAME})
|
||||
|
||||
|
@ -143,6 +139,26 @@ if(ENABLE_FRIBIDI AND FRIBIDI_LIBRARIES)
|
|||
add_definitions(-DHAVE_FRIBIDI)
|
||||
endif(ENABLE_FRIBIDI AND FRIBIDI_LIBRARIES)
|
||||
|
||||
#
|
||||
# Libraries that are only required by some targets
|
||||
#
|
||||
|
||||
if(ENABLE_TOOLS OR ENABLE_GAME OR ENABLE_EDITOR OR ENABLE_TESTS)
|
||||
FIND_PACKAGE( SDL_image 1.2 REQUIRED )
|
||||
endif()
|
||||
if(ENABLE_GAME OR ENABLE_EDITOR OR ENABLE_TESTS)
|
||||
FIND_PACKAGE( SDL_mixer 1.2 REQUIRED )
|
||||
FIND_PACKAGE( SDL_ttf 2.0.8 REQUIRED )
|
||||
endif()
|
||||
if(ENABLE_GAME OR ENABLE_SERVER OR ENABLE_CAMPAIGN_SERVER OR ENABLE_TESTS)
|
||||
FIND_PACKAGE( SDL_net REQUIRED )
|
||||
endif()
|
||||
if(ENABLE_TOOLS)
|
||||
FIND_PACKAGE( ZLIB REQUIRED )
|
||||
FIND_PACKAGE( PNG REQUIRED )
|
||||
endif()
|
||||
|
||||
|
||||
#
|
||||
#create dummy-locales
|
||||
#
|
||||
|
|
|
@ -1,34 +1,69 @@
|
|||
## some includes ##
|
||||
include_directories( ${Boost_INCLUDE_DIR} )
|
||||
include_directories( ${SDLIMAGE_INCLUDE_DIR} )
|
||||
include_directories( ${SDLMIXER_INCLUDE_DIR} )
|
||||
include_directories( ${SDLNET_INCLUDE_DIR} )
|
||||
include_directories( ${SDLTTF_INCLUDE_DIR} )
|
||||
include_directories( ${SDL_INCLUDE_DIR} )
|
||||
include_directories( ${ZLIB_INCLUDE_DIR} )
|
||||
|
||||
#optional dependencies
|
||||
if(SDLIMAGE_INCLUDE_DIR)
|
||||
include_directories( ${SDLIMAGE_INCLUDE_DIR} )
|
||||
endif()
|
||||
if(SDLMIXER_INCLUDE_DIR)
|
||||
include_directories( ${SDLMIXER_INCLUDE_DIR} )
|
||||
endif()
|
||||
if(SDLNET_INCLUDE_DIR)
|
||||
include_directories( ${SDLNET_INCLUDE_DIR} )
|
||||
endif()
|
||||
if(SDLTTF_INCLUDE_DIR)
|
||||
include_directories( ${SDLTTF_INCLUDE_DIR} )
|
||||
endif()
|
||||
if(ZLIB_INCLUDE_DIR)
|
||||
include_directories( ${ZLIB_INCLUDE_DIR} )
|
||||
endif()
|
||||
|
||||
# needed to get include paths in the subfolders correct
|
||||
include_directories( ${CMAKE_SOURCE_DIR}/src/ )
|
||||
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
||||
|
||||
set( the-external-libs
|
||||
${SDLIMAGE_LIBRARY}
|
||||
${SDLMIXER_LIBRARY}
|
||||
${SDLNET_LIBRARY}
|
||||
${SDLTTF_LIBRARY}
|
||||
set( common-external-libs
|
||||
${SDL_LIBRARY}
|
||||
${Boost_IOSTREAMS_LIBRARY}
|
||||
${Boost_REGEX_LIBRARY}
|
||||
)
|
||||
|
||||
set( game-external-libs
|
||||
${common-external-libs}
|
||||
${SDLIMAGE_LIBRARY}
|
||||
${SDLMIXER_LIBRARY}
|
||||
${SDLNET_LIBRARY}
|
||||
${SDLTTF_LIBRARY}
|
||||
)
|
||||
|
||||
set( server-external-libs
|
||||
${common-external-libs}
|
||||
${SDLNET_LIBRARY}
|
||||
)
|
||||
|
||||
set( editor-external-libs
|
||||
${common-external-libs}
|
||||
${SDLIMAGE_LIBRARY}
|
||||
${SDLMIXER_LIBRARY}
|
||||
${SDLTTF_LIBRARY}
|
||||
)
|
||||
|
||||
set( tools-external-libs
|
||||
${common-external-libs}
|
||||
${SDLIMAGE_LIBRARY}
|
||||
)
|
||||
|
||||
if(ENABLE_PYTHON AND PYTHON_LIBRARY)
|
||||
include_directories( ${PYTHON_INCLUDE_PATH} )
|
||||
set(the-external-libs ${the-external-libs} ${PYTHON_LIBRARIES})
|
||||
set(game-external-libs ${game-external-libs} ${PYTHON_LIBRARIES})
|
||||
endif(ENABLE_PYTHON AND PYTHON_LIBRARY)
|
||||
|
||||
if(ENABLE_FRIBIDI AND FRIBIDI_LIBRARIES)
|
||||
include_directories( ${FRIBIDI_INCLUDE_PATH} )
|
||||
set(the-external-libs ${the-external-libs} ${FRIBIDI_LIBRARIES})
|
||||
set(game-external-libs ${game-external-libs} ${FRIBIDI_LIBRARIES})
|
||||
set(editor-external-libs ${editor-external-libs} ${FRIBIDI_LIBRARIES})
|
||||
endif(ENABLE_FRIBIDI AND FRIBIDI_LIBRARIES)
|
||||
|
||||
#
|
||||
|
@ -249,7 +284,7 @@ SET(wesnoth_SRC
|
|||
)
|
||||
|
||||
ADD_EXECUTABLE(${BINARY_PREFIX}wesnoth${BINARY_SUFFIX} ${wesnoth_SRC})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}wesnoth${BINARY_SUFFIX} wesnoth-core wesnoth-game ${the-external-libs})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}wesnoth${BINARY_SUFFIX} wesnoth-core wesnoth-game ${game-external-libs})
|
||||
|
||||
INSTALL(TARGETS ${BINARY_PREFIX}wesnoth${BINARY_SUFFIX} DESTINATION ${BINDIR})
|
||||
|
||||
|
@ -274,7 +309,7 @@ SET(wesnoth_editor_SRC
|
|||
)
|
||||
|
||||
ADD_EXECUTABLE(${BINARY_PREFIX}wesnoth_editor${BINARY_SUFFIX} ${wesnoth_editor_SRC})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}wesnoth_editor${BINARY_SUFFIX} wesnoth-core wesnoth-game ${the-external-libs})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}wesnoth_editor${BINARY_SUFFIX} wesnoth-core wesnoth-game ${editor-external-libs})
|
||||
|
||||
INSTALL(TARGETS ${BINARY_PREFIX}wesnoth_editor${BINARY_SUFFIX} DESTINATION ${BINDIR})
|
||||
|
||||
|
@ -298,7 +333,7 @@ SET(wesnothd_SRC
|
|||
)
|
||||
|
||||
ADD_EXECUTABLE(${BINARY_PREFIX}wesnothd${BINARY_SUFFIX} ${wesnothd_SRC})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}wesnothd${BINARY_SUFFIX} wesnoth-core ${the-external-libs})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}wesnothd${BINARY_SUFFIX} wesnoth-core ${server-external-libs})
|
||||
|
||||
INSTALL(TARGETS ${BINARY_PREFIX}wesnothd${BINARY_SUFFIX} DESTINATION ${BINDIR})
|
||||
|
||||
|
@ -317,7 +352,7 @@ SET(campaignd_SRC
|
|||
)
|
||||
|
||||
ADD_EXECUTABLE(${BINARY_PREFIX}campaignd${BINARY_SUFFIX} ${campaignd_SRC})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}campaignd${BINARY_SUFFIX} wesnoth-core ${the-external-libs})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}campaignd${BINARY_SUFFIX} wesnoth-core ${server-external-libs})
|
||||
|
||||
INSTALL(TARGETS ${BINARY_PREFIX}campaignd${BINARY_SUFFIX} DESTINATION ${BINDIR})
|
||||
|
||||
|
@ -338,7 +373,7 @@ SET(exploder_SRC
|
|||
)
|
||||
|
||||
ADD_EXECUTABLE(${BINARY_PREFIX}exploder${BINARY_SUFFIX} ${exploder_SRC})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}exploder${BINARY_SUFFIX} wesnoth-core ${the-external-libs} png12)
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}exploder${BINARY_SUFFIX} wesnoth-core png12 ${tools-external-libs})
|
||||
|
||||
INSTALL(TARGETS ${BINARY_PREFIX}exploder${BINARY_SUFFIX} DESTINATION ${BINDIR})
|
||||
|
||||
|
@ -352,7 +387,7 @@ SET(cutter_SRC
|
|||
)
|
||||
|
||||
ADD_EXECUTABLE(${BINARY_PREFIX}cutter${BINARY_SUFFIX} ${cutter_SRC})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}cutter${BINARY_SUFFIX} wesnoth-core ${the-external-libs} png12)
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}cutter${BINARY_SUFFIX} wesnoth-core png12 ${tools-external-libs})
|
||||
|
||||
INSTALL(TARGETS ${BINARY_PREFIX}cutter${BINARY_SUFFIX} DESTINATION ${BINDIR})
|
||||
|
||||
|
@ -371,7 +406,7 @@ SET(test_SRC
|
|||
)
|
||||
|
||||
ADD_EXECUTABLE(${BINARY_PREFIX}test${BINARY_SUFFIX} ${test_SRC})
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}test${BINARY_SUFFIX} wesnoth-core wesnoth-game ${the-external-libs} boost_unit_test_framework)
|
||||
TARGET_LINK_LIBRARIES(${BINARY_PREFIX}test${BINARY_SUFFIX} wesnoth-core wesnoth-game ${game-external-libs} boost_unit_test_framework)
|
||||
|
||||
ENDIF(ENABLE_TESTS)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue