Skip to content

Commit

Permalink
Merge branch 'static-libs'
Browse files Browse the repository at this point in the history
Manual merge of pull request #2208.
  • Loading branch information
jyrkive committed Nov 20, 2017
2 parents 3400891 + 870f896 commit 321c350
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 152 deletions.
10 changes: 2 additions & 8 deletions CMakeLists.txt
Expand Up @@ -28,7 +28,6 @@ include(GNUInstallDirs)
#Path options
set(DATADIRNAME "wesnoth" CACHE STRING "change the name of the directory for the read-only architecture-independent game data")
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}" CACHE STRING "change the dir where binaries are placed right at compile time")
set(LOCALEDIR "translations" CACHE STRING "change the name of the locale data directory to a non-default name")
set(PREFERENCES_DIR "" CACHE STRING "Use a non-default preferences directory (.wesnoth on unix)")
set(DEFAULT_PREFS_FILE "" CACHE STRING "Set system wide preferences file")

Expand Down Expand Up @@ -484,8 +483,6 @@ if(X11_FOUND)
add_definitions(-D_X11)
endif(X11_FOUND)

add_definitions(-DLOCALEDIR="${LOCALEDIR}")

# -NDEBUG is automatically added to all release build types, so manually remove
# this define from the related variables
MESSAGE ("removing NDEBUG flag from CMAKE_CXX_FLAGS_RELWITHDEBINFO")
Expand Down Expand Up @@ -761,11 +758,8 @@ if(ENABLE_GAME)
endif(ENABLE_HISTORY AND HISTORY_FOUND)
endif(ENABLE_GAME)

if(ENABLE_GAME OR ENABLE_SERVER OR ENABLE_TOOLS OR ENABLE_TESTS)
find_package(Boost 1.50 REQUIRED COMPONENTS filesystem)

find_package(Boost 1.50 REQUIRED COMPONENTS locale)
endif(ENABLE_GAME OR ENABLE_SERVER OR ENABLE_TOOLS OR ENABLE_TESTS)
find_package(Boost 1.50 REQUIRED COMPONENTS filesystem)
find_package(Boost 1.50 REQUIRED COMPONENTS locale)

if(ENABLE_POT_UPDATE_TARGET)
find_package(TranslationTools REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion SConstruct
Expand Up @@ -105,7 +105,7 @@ opts.AddVariables(
BoolVariable('ccache', "Use ccache", False),
('ctool', 'Set c compiler command if not using standard compiler.'),
('cxxtool', 'Set c++ compiler command if not using standard compiler.'),
EnumVariable('cxx_std', 'Target c++ std version', '11', ['11', '14', '1y']),
EnumVariable('cxx_std', 'Target c++ std version', '11', ['11', '1y', '14']),
BoolVariable('openmp', 'Enable openmp use.', False),
('sanitize', 'Enable clang and GCC sanitizer functionality. A comma separated list of sanitize suboptions must be passed as value.', ''),
BoolVariable("fast", "Make scons faster at cost of less precise dependency tracking.", False),
Expand Down
20 changes: 10 additions & 10 deletions po/CMakeLists.txt
Expand Up @@ -229,32 +229,32 @@ if(ENABLE_NLS)
foreach(DOMAIN ${DOMAINS})

add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES
COMMAND ${CMAKE_COMMAND} -E make_directory
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES
${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES
COMMENT "mo-update [${LINGUA}]: Creating locale directory."
)

add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
COMMAND ${GETTEXT_MSGFMT_EXECUTABLE}
${GETTEXT_MSGFMT_PARAMETER}
-o ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo ${LINGUA}.po
-o ${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo ${LINGUA}.po
DEPENDS
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES
${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES
${PROJECT_SOURCE_DIR}/po/${DOMAIN}/${LINGUA}.po
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/po/${DOMAIN}
COMMENT "mo-update [${DOMAIN}-${LINGUA}]: Creating mo file."
)

install(FILES ${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
DESTINATION ${LOCALE_INSTALL}/${LINGUA}/LC_MESSAGES)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/${LINGUA}/LC_MESSAGES)

set(mo-update-SRC ${mo-update-SRC}
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
)
set(mo-update-LINGUA-SRC ${mo-update-LINGUA-SRC}
${CMAKE_SOURCE_DIR}/${LOCALEDIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}/LC_MESSAGES/${DOMAIN}.mo
)

endforeach(DOMAIN ${DOMAINS})
Expand All @@ -276,7 +276,7 @@ if(ENABLE_NLS)
)

set_directory_properties(properties
ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_SOURCE_DIR}/${LOCALEDIR}
ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}
)

endif(ENABLE_NLS)
Expand Down
175 changes: 54 additions & 121 deletions src/CMakeLists.txt
Expand Up @@ -3,8 +3,8 @@ set(CXX_FLAGS_PROJECT "${CXX_FLAGS_PROJECT} -include boost-patched/bind/arg.hpp"

# store the specified sources list in the specified variable
function(GetSources source_list store_in_var)
file(STRINGS "../source_lists/${source_list}" sources)
set(${store_in_var} ${sources} PARENT_SCOPE)
file(STRINGS "../source_lists/${source_list}" sources)
set(${store_in_var} ${sources} PARENT_SCOPE)
endfunction()

## some includes ##
Expand Down Expand Up @@ -84,10 +84,6 @@ endif(MSVC)
set(common-external-libs
${common-external-libs}
${Boost_FILESYSTEM_LIBRARY}
)

set(common-external-libs
${common-external-libs}
${Boost_LOCALE_LIBRARY}
)

Expand Down Expand Up @@ -135,10 +131,6 @@ set(server-external-libs
${Boost_SYSTEM_LIBRARIES}
)

set(game-external-libs
${game-external-libs}
)

set(tools-external-libs
${common-external-libs}
${sdl_image-lib}
Expand Down Expand Up @@ -264,18 +256,18 @@ if(ENABLE_DISPLAY_REVISION)
endif()


########### libwesnoth-lua ###############
########### lua ###############

GetSources("lua" libwesnoth-lua_STAT_SRC)
GetSources("lua" lua_STAT_SRC)

# We explicitly want lua compiled as C++ version, so this line is required:
set_source_files_properties(${libwesnoth-lua_STAT_SRC} PROPERTIES LANGUAGE CXX)
set_source_files_properties(${lua_STAT_SRC} PROPERTIES LANGUAGE CXX)

# Inject a header into the Lua sources for Wesnoth-specific changes
# makedepend won't see it so we have to specifically add it as a dependancy.
file(GLOB wesnoth_lua_config wesnoth_lua_config.h)
set_source_files_properties(${libwesnoth-lua_STAT_SRC} PROPERTIES COMPILE_FLAGS "-include ${wesnoth_lua_config}")
set_source_files_properties(${libwesnoth-lua_STAT_SRC} PROPERTIES OBJECT_DEPENDS ${wesnoth_lua_config})
set_source_files_properties(${lua_STAT_SRC} PROPERTIES COMPILE_FLAGS "-include ${wesnoth_lua_config}")
set_source_files_properties(${lua_STAT_SRC} PROPERTIES OBJECT_DEPENDS ${wesnoth_lua_config})

if(UNIX AND NOT CMAKE_COMPILER_IS_GNUCXX)
# Assume the compiler is the clang compiler.
Expand All @@ -284,15 +276,15 @@ if(UNIX AND NOT CMAKE_COMPILER_IS_GNUCXX)
#
# Also silence some Clang specific warnings due to extra parenthesis in if statements when comparing instead
set_property(SOURCE
SOURCE ${libwesnoth-lua_STAT_SRC}
SOURCE ${lua_STAT_SRC}
APPEND_STRING PROPERTY COMPILE_FLAGS
" -x c++ -Wno-parentheses-equality -Wno-conditional-uninitialized"
)
endif(UNIX AND NOT CMAKE_COMPILER_IS_GNUCXX)

# 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-lua ${LIBRARY_TYPE} EXCLUDE_FROM_ALL ${libwesnoth-lua_STAT_SRC})
add_library(lua ${LIBRARY_TYPE} EXCLUDE_FROM_ALL ${lua_STAT_SRC})


########### Old style cast flags ###############
Expand All @@ -308,7 +300,7 @@ if(HAS_COMPILER_FLAG_WUSELESS_CAST)
set(CXX_FLAG_NO_USELESS_CAST "-Wno-useless-cast")
endif()

set_target_properties(wesnoth-lua
set_target_properties(lua
PROPERTIES
COMPILE_FLAGS
"${CXX_FLAG_NO_OLD_STYLE_CAST} ${CXX_FLAG_NO_USELESS_CAST}"
Expand Down Expand Up @@ -340,16 +332,14 @@ target_link_libraries(wesnoth-sdl

########### Wesnoth main source files ###############

# Depending on whether the game or the game and the tests are build the main
# sources are compiled in the game library or not. If only one target is needed
# the putting in the game library solution is slower. If both targets are build
# the library is faster (especially if the user doesn't use ccache (or
# something similar)).
# create libwesnoth-client.a if building the client or the boost unit tests

GetSources("wesnoth" wesnoth-main_SRC)
if(ENABLE_GAME OR ENABLE_TESTS)
GetSources("wesnoth" wesnoth-main_SRC)
add_library(wesnoth-client ${LIBRARY_TYPE} EXCLUDE_FROM_ALL ${wesnoth-main_SRC})
endif(ENABLE_GAME OR ENABLE_TESTS)

########### libwesnoth-game ###############
# rename libwesnoth.a to libwesnoth-game.a to have clearer targets

GetSources("libwesnoth" libwesnoth-game_STAT_SRC)

Expand All @@ -369,7 +359,6 @@ if(APPLE)
)
endif(APPLE)


# For libdbus (essentially just for linux), this file needs to be linked, as its header is included #ifdef HAVE_LIBDBUS
if(LIBDBUS_FOUND)
set(libwesnoth-game_STAT_SRC
Expand All @@ -378,56 +367,22 @@ if(LIBDBUS_FOUND)
)
endif(LIBDBUS_FOUND)

if(ENABLE_GAME AND ENABLE_TESTS)
set(libwesnoth-game_STAT_SRC
${libwesnoth-game_STAT_SRC}
${wesnoth-main_SRC}
)
endif(ENABLE_GAME AND ENABLE_TESTS)

# 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 ${LIBRARY_TYPE} EXCLUDE_FROM_ALL ${libwesnoth-game_STAT_SRC})

if(ENABLE_GAME AND ENABLE_TESTS)
target_link_libraries(wesnoth-game
wesnoth-core
wesnoth-lua
)
endif(ENABLE_GAME AND ENABLE_TESTS)

########### Wesnoth ###############

if(ENABLE_GAME)
if(ENABLE_TESTS)
set(wesnoth_SRC
wesnoth.cpp
)
set(wesnoth_LIB
wesnoth-core
wesnoth-lua
wesnoth-game
wesnoth-sdl
)
else(ENABLE_TESTS)
set(wesnoth_SRC
wesnoth.cpp
${wesnoth-main_SRC}
)
set(wesnoth_LIB
wesnoth-core
wesnoth-lua
wesnoth-game
wesnoth-sdl
)
endif(ENABLE_TESTS)

add_executable(wesnoth WIN32
${wesnoth_SRC}
)
add_executable(wesnoth WIN32 wesnoth.cpp)

target_link_libraries(wesnoth
${wesnoth_LIB}
wesnoth-client
lua
wesnoth-core
wesnoth-game
wesnoth-sdl
wesnoth-client
${game-external-libs}
)
set_target_properties(wesnoth
Expand All @@ -441,41 +396,35 @@ endif(ENABLE_GAME)

if(ENABLE_SERVER)

GetSources("wesnothd" wesnothd_SRC)
GetSources("wesnothd" wesnothd_SRC)

add_executable(wesnothd WIN32
${wesnothd_SRC}
)
add_executable(wesnothd WIN32 ${wesnothd_SRC})

target_link_libraries(wesnothd wesnoth-core ${server-external-libs} ${Boost_RANDOM_LIBRARY})
set_target_properties(wesnothd PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}wesnothd${BINARY_SUFFIX})
target_link_libraries(wesnothd wesnoth-core ${server-external-libs} ${Boost_RANDOM_LIBRARY})

set_target_properties(wesnothd PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}wesnothd${BINARY_SUFFIX})

install(TARGETS wesnothd DESTINATION ${CMAKE_INSTALL_BINDIR})
install(TARGETS wesnothd DESTINATION ${CMAKE_INSTALL_BINDIR})

endif(ENABLE_SERVER)

########### Campaign Server ###############

if(ENABLE_CAMPAIGN_SERVER)

GetSources("campaignd" campaignd_SRC)

check_library_exists(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME_RT)
if(HAVE_CLOCK_GETTIME_RT)
set(LIBRT rt)
endif()

add_executable(campaignd ${campaignd_SRC})
target_link_libraries(campaignd
wesnoth-core
${server-external-libs}
${CRYPTO_LIBRARY}
${Boost_RANDOM_LIBRARY}
${LIBRT}
)
set_target_properties(campaignd PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}campaignd${BINARY_SUFFIX})

install(TARGETS campaignd DESTINATION ${CMAKE_INSTALL_BINDIR})

GetSources("campaignd" campaignd_SRC)

add_executable(campaignd ${campaignd_SRC})

target_link_libraries(campaignd
wesnoth-core
${server-external-libs}
${CRYPTO_LIBRARY}
${Boost_RANDOM_LIBRARY}
)
set_target_properties(campaignd PROPERTIES OUTPUT_NAME ${BINARY_PREFIX}campaignd${BINARY_SUFFIX})

install(TARGETS campaignd DESTINATION ${CMAKE_INSTALL_BINDIR})

endif(ENABLE_CAMPAIGN_SERVER)

Expand All @@ -484,41 +433,25 @@ endif(ENABLE_CAMPAIGN_SERVER)
if(ENABLE_TESTS)

add_definitions(-DBOOST_TEST_DYN_LINK)

GetSources("boost_unit_tests" test_SRC)

if(ENABLE_GAME)
set(test_LIB
wesnoth-core
wesnoth-game
wesnoth-sdl
wesnoth-lua
)
else(ENABLE_GAME)
set(test_SRC
${test_SRC}
${wesnoth-main_SRC}
)
set(test_LIB
wesnoth-core
wesnoth-game
wesnoth-lua
wesnoth-sdl
)
endif(ENABLE_GAME)

GetSources("boost_unit_tests" test_SRC)

set_source_files_properties(
tests/test_util.cpp
PROPERTIES
COMPILE_FLAGS
"${CXX_FLAG_NO_USELESS_CAST}"
COMPILE_FLAGS
"${CXX_FLAG_NO_USELESS_CAST}"
)

add_executable(boost_unit_tests
${test_SRC}
)
add_executable(boost_unit_tests ${test_SRC})

target_link_libraries(boost_unit_tests
${test_LIB}
wesnoth-client
lua
wesnoth-core
wesnoth-game
wesnoth-sdl
wesnoth-client
${game-external-libs}
boost_unit_test_framework
)
Expand Down

0 comments on commit 321c350

Please sign in to comment.