Have scons and cmake link against same static libraries.
This commit is contained in:
parent
17c0fd97a8
commit
e45e824499
4 changed files with 66 additions and 136 deletions
|
@ -765,11 +765,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)
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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 ##
|
||||
|
@ -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}
|
||||
)
|
||||
|
||||
|
@ -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}
|
||||
|
@ -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.
|
||||
|
@ -284,7 +276,7 @@ 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"
|
||||
)
|
||||
|
@ -292,7 +284,7 @@ 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 ###############
|
||||
|
@ -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}"
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 ${BINDIR})
|
||||
install(TARGETS wesnothd DESTINATION ${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()
|
||||
GetSources("campaignd" campaignd_SRC)
|
||||
|
||||
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})
|
||||
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 ${BINDIR})
|
||||
install(TARGETS campaignd DESTINATION ${BINDIR})
|
||||
|
||||
endif(ENABLE_CAMPAIGN_SERVER)
|
||||
|
||||
|
@ -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
|
||||
)
|
||||
|
|
|
@ -65,11 +65,11 @@ libwesnoth_core_sources = GetSources("libwesnoth_core")
|
|||
if env["PLATFORM"] == "win32":
|
||||
libwesnoth_core_sources.append("log_windows.cpp")
|
||||
|
||||
libwesnoth_core = env.Library("wesnoth_core", libwesnoth_core_sources)
|
||||
libwesnoth_core = env.Library("wesnoth-core", libwesnoth_core_sources)
|
||||
|
||||
#---libwesnoth---
|
||||
libwesnoth_sources = GetSources("libwesnoth")
|
||||
libwesnoth = client_env.Library("wesnoth", libwesnoth_sources)
|
||||
#---libwesnoth_game---
|
||||
libwesnoth_game_sources = GetSources("libwesnoth")
|
||||
libwesnoth_game = client_env.Library("wesnoth-game", libwesnoth_game_sources)
|
||||
|
||||
#---libwesnoth_sdl---
|
||||
libwesnoth_sdl_sources = GetSources("libwesnoth_sdl")
|
||||
|
@ -77,23 +77,23 @@ libwesnoth_sdl_sources = GetSources("libwesnoth_sdl")
|
|||
if env["png"]:
|
||||
libwesnoth_sdl_sources.append("SDL_SavePNG/savepng.c")
|
||||
|
||||
libwesnoth_sdl = client_env.Library("wesnoth_sdl", libwesnoth_sdl_sources)
|
||||
libwesnoth_sdl = client_env.Library("wesnoth-sdl", libwesnoth_sdl_sources)
|
||||
|
||||
#---wesnoth---
|
||||
# Used by both 'wesnoth' and 'boost_unit_tests' targets
|
||||
|
||||
wesnoth_sources = GetSources("wesnoth")
|
||||
wesnoth_client_sources = GetSources("wesnoth")
|
||||
|
||||
if env["PLATFORM"] == "win32":
|
||||
wesnoth_sources.append("desktop/windows_tray_notification.cpp")
|
||||
wesnoth_client_sources.append("desktop/windows_tray_notification.cpp")
|
||||
|
||||
if env["PLATFORM"] == 'darwin':
|
||||
wesnoth_sources.append("desktop/apple_notification.mm")
|
||||
wesnoth_client_sources.append("desktop/apple_notification.mm")
|
||||
|
||||
if env["notifications"]:
|
||||
wesnoth_sources.append("desktop/dbus_notification.cpp")
|
||||
wesnoth_client_sources.append("desktop/dbus_notification.cpp")
|
||||
|
||||
libwesnoth_extras = client_env.Library("wesnoth_extras", wesnoth_sources)
|
||||
libwesnoth_client = client_env.Library("wesnoth-client", wesnoth_client_sources)
|
||||
|
||||
#---lua---
|
||||
lua_sources = GetSources("lua")
|
||||
|
@ -116,7 +116,7 @@ objs_lua = env_lua.Object(lua_sources)
|
|||
for obj in objs_lua:
|
||||
env_lua.Depends(obj, env_lua["wesnoth_lua_config"])
|
||||
|
||||
libwesnoth_extras.extend(env_lua.Library("lua", objs_lua))
|
||||
liblua = env_lua.Library("lua", objs_lua)
|
||||
|
||||
#
|
||||
# Target declarations
|
||||
|
@ -149,7 +149,7 @@ for env in [test_env, client_env, env]:
|
|||
#---wesnoth---
|
||||
# for wesnoth_res and wesnothd_res, see packaging/windows/SConscript
|
||||
# used to set the executable icon for wesnoth and wesnothd
|
||||
libwesnoth_objects = libwesnoth_extras + libwesnoth_core + libwesnoth + libwesnoth_sdl + libwesnoth_extras
|
||||
libwesnoth_objects = libwesnoth_client + liblua + libwesnoth_core + libwesnoth_game + libwesnoth_sdl + libwesnoth_client
|
||||
if env["PLATFORM"] == 'darwin':
|
||||
client_env.WesnothProgram("wesnoth", ["wesnoth.cpp"] + libwesnoth_objects + ["macosx/SDLMain.mm"], have_client_prereqs)
|
||||
elif env["PLATFORM"] == 'win32':
|
||||
|
|
Loading…
Add table
Reference in a new issue