mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Introduce object target for shared sources
This commit is contained in:
parent
37095f3e49
commit
a18355e7e8
3 changed files with 86 additions and 56 deletions
|
@ -379,87 +379,90 @@ add_custom_target(GenerateVersion
|
||||||
add_subdirectory(threading)
|
add_subdirectory(threading)
|
||||||
add_subdirectory(content)
|
add_subdirectory(content)
|
||||||
add_subdirectory(database)
|
add_subdirectory(database)
|
||||||
add_subdirectory(gui)
|
|
||||||
add_subdirectory(mapgen)
|
add_subdirectory(mapgen)
|
||||||
add_subdirectory(network)
|
add_subdirectory(network)
|
||||||
add_subdirectory(script)
|
add_subdirectory(script)
|
||||||
add_subdirectory(unittest)
|
|
||||||
add_subdirectory(benchmark)
|
|
||||||
add_subdirectory(util)
|
add_subdirectory(util)
|
||||||
add_subdirectory(irrlicht_changes)
|
|
||||||
add_subdirectory(server)
|
add_subdirectory(server)
|
||||||
|
|
||||||
set(common_SRCS
|
# Source files that are identical between server & client builds.
|
||||||
${database_SRCS}
|
# This means they don't use or include anything that depends on the
|
||||||
${mapgen_SRCS}
|
# CHECK_CLIENT_BUILD() macro. If you wrongly add something here there will be
|
||||||
${server_SRCS}
|
# a compiler error and you need to instead add it to client_SRCS or common_SRCS.
|
||||||
${content_SRCS}
|
set(independent_SRCS
|
||||||
chat.cpp
|
chat.cpp
|
||||||
clientdynamicinfo.cpp
|
|
||||||
collision.cpp
|
|
||||||
content_mapnode.cpp
|
|
||||||
content_nodemeta.cpp
|
|
||||||
convert_json.cpp
|
convert_json.cpp
|
||||||
craftdef.cpp
|
|
||||||
debug.cpp
|
|
||||||
defaultsettings.cpp
|
|
||||||
emerge.cpp
|
|
||||||
environment.cpp
|
|
||||||
face_position_cache.cpp
|
face_position_cache.cpp
|
||||||
filesys.cpp
|
|
||||||
gettext.cpp
|
|
||||||
gettext_plural_form.cpp
|
gettext_plural_form.cpp
|
||||||
httpfetch.cpp
|
httpfetch.cpp
|
||||||
hud.cpp
|
hud.cpp
|
||||||
inventory.cpp
|
|
||||||
inventorymanager.cpp
|
|
||||||
itemdef.cpp
|
|
||||||
itemstackmetadata.cpp
|
itemstackmetadata.cpp
|
||||||
light.cpp
|
|
||||||
lighting.cpp
|
lighting.cpp
|
||||||
log.cpp
|
log.cpp
|
||||||
main.cpp
|
|
||||||
map.cpp
|
|
||||||
map_settings_manager.cpp
|
|
||||||
mapblock.cpp
|
|
||||||
mapnode.cpp
|
|
||||||
mapsector.cpp
|
|
||||||
metadata.cpp
|
metadata.cpp
|
||||||
modchannels.cpp
|
modchannels.cpp
|
||||||
nameidmapping.cpp
|
nameidmapping.cpp
|
||||||
nodedef.cpp
|
|
||||||
nodemetadata.cpp
|
|
||||||
nodetimer.cpp
|
nodetimer.cpp
|
||||||
noise.cpp
|
noise.cpp
|
||||||
objdef.cpp
|
objdef.cpp
|
||||||
object_properties.cpp
|
object_properties.cpp
|
||||||
particles.cpp
|
particles.cpp
|
||||||
pathfinder.cpp
|
|
||||||
player.cpp
|
|
||||||
porting.cpp
|
|
||||||
profiler.cpp
|
profiler.cpp
|
||||||
raycast.cpp
|
|
||||||
reflowscan.cpp
|
|
||||||
remoteplayer.cpp
|
|
||||||
rollback_interface.cpp
|
|
||||||
serialization.cpp
|
serialization.cpp
|
||||||
server.cpp
|
|
||||||
serverenvironment.cpp
|
|
||||||
servermap.cpp
|
|
||||||
settings.cpp
|
|
||||||
staticobject.cpp
|
staticobject.cpp
|
||||||
terminal_chat_console.cpp
|
terminal_chat_console.cpp
|
||||||
texture_override.cpp
|
texture_override.cpp
|
||||||
tileanimation.cpp
|
tileanimation.cpp
|
||||||
|
${threading_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
# /!\ Consider carefully before adding files here /!\
|
||||||
|
set(common_SRCS
|
||||||
|
clientdynamicinfo.cpp
|
||||||
|
collision.cpp
|
||||||
|
content_mapnode.cpp
|
||||||
|
content_nodemeta.cpp
|
||||||
|
craftdef.cpp
|
||||||
|
debug.cpp
|
||||||
|
defaultsettings.cpp
|
||||||
|
emerge.cpp
|
||||||
|
environment.cpp
|
||||||
|
filesys.cpp
|
||||||
|
gettext.cpp
|
||||||
|
inventory.cpp
|
||||||
|
inventorymanager.cpp
|
||||||
|
itemdef.cpp
|
||||||
|
light.cpp
|
||||||
|
main.cpp
|
||||||
|
map_settings_manager.cpp
|
||||||
|
map.cpp
|
||||||
|
mapblock.cpp
|
||||||
|
mapnode.cpp
|
||||||
|
mapsector.cpp
|
||||||
|
nodedef.cpp
|
||||||
|
nodemetadata.cpp
|
||||||
|
pathfinder.cpp
|
||||||
|
player.cpp
|
||||||
|
porting.cpp
|
||||||
|
raycast.cpp
|
||||||
|
reflowscan.cpp
|
||||||
|
remoteplayer.cpp
|
||||||
|
rollback_interface.cpp
|
||||||
|
server.cpp
|
||||||
|
serverenvironment.cpp
|
||||||
|
servermap.cpp
|
||||||
|
settings.cpp
|
||||||
tool.cpp
|
tool.cpp
|
||||||
translation.cpp
|
translation.cpp
|
||||||
version.cpp
|
version.cpp
|
||||||
voxel.cpp
|
voxel.cpp
|
||||||
voxelalgorithms.cpp
|
voxelalgorithms.cpp
|
||||||
hud.cpp
|
|
||||||
${common_network_SRCS}
|
${common_network_SRCS}
|
||||||
${JTHREAD_SRCS}
|
|
||||||
${common_SCRIPT_SRCS}
|
${common_SCRIPT_SRCS}
|
||||||
|
${common_server_SRCS}
|
||||||
|
${content_SRCS}
|
||||||
|
${database_SRCS}
|
||||||
|
${mapgen_SRCS}
|
||||||
${UTIL_SRCS}
|
${UTIL_SRCS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -468,10 +471,12 @@ if(ANDROID)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_UNITTESTS)
|
if(BUILD_UNITTESTS)
|
||||||
|
add_subdirectory(unittest)
|
||||||
set(common_SRCS ${common_SRCS} ${UNITTEST_SRCS})
|
set(common_SRCS ${common_SRCS} ${UNITTEST_SRCS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_BENCHMARKS)
|
if(BUILD_BENCHMARKS)
|
||||||
|
add_subdirectory(benchmark)
|
||||||
set(common_SRCS ${common_SRCS} ${BENCHMARK_SRCS})
|
set(common_SRCS ${common_SRCS} ${BENCHMARK_SRCS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -503,6 +508,8 @@ endif()
|
||||||
# Client sources
|
# Client sources
|
||||||
if (BUILD_CLIENT)
|
if (BUILD_CLIENT)
|
||||||
add_subdirectory(client)
|
add_subdirectory(client)
|
||||||
|
add_subdirectory(gui)
|
||||||
|
add_subdirectory(irrlicht_changes)
|
||||||
endif(BUILD_CLIENT)
|
endif(BUILD_CLIENT)
|
||||||
|
|
||||||
set(client_SRCS
|
set(client_SRCS
|
||||||
|
@ -522,13 +529,11 @@ if(BUILD_BENCHMARKS)
|
||||||
set(client_SRCS ${client_SRCS} ${BENCHMARK_CLIENT_SRCS})
|
set(client_SRCS ${client_SRCS} ${BENCHMARK_CLIENT_SRCS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(SORT client_SRCS)
|
|
||||||
|
|
||||||
# Server sources
|
# Server sources
|
||||||
|
# (nothing here because a client always comes with a server)
|
||||||
set(server_SRCS
|
set(server_SRCS
|
||||||
${common_SRCS}
|
${common_SRCS}
|
||||||
)
|
)
|
||||||
list(SORT server_SRCS)
|
|
||||||
|
|
||||||
# Avoid source_group on broken CMake version.
|
# Avoid source_group on broken CMake version.
|
||||||
# see issue #7074 #7075
|
# see issue #7074 #7075
|
||||||
|
@ -577,13 +582,32 @@ if(NOT CMAKE_CROSSCOMPILING)
|
||||||
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
|
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# shared object target
|
||||||
|
add_library(EngineCommon OBJECT
|
||||||
|
${independent_SRCS}
|
||||||
|
)
|
||||||
|
add_dependencies(EngineCommon GenerateVersion)
|
||||||
|
get_target_property(
|
||||||
|
IRRLICHT_INCLUDES IrrlichtMt::IrrlichtMt INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
target_include_directories(EngineCommon PRIVATE ${IRRLICHT_INCLUDES})
|
||||||
|
if(PRECOMPILE_HEADERS)
|
||||||
|
target_precompile_headers(EngineCommon PRIVATE ${PRECOMPILED_HEADERS_LIST})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(BUILD_CLIENT)
|
if(BUILD_CLIENT)
|
||||||
|
# client target
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
add_library(${PROJECT_NAME} SHARED ${client_SRCS})
|
add_library(${PROJECT_NAME} SHARED)
|
||||||
else()
|
else()
|
||||||
add_executable(${PROJECT_NAME} ${client_SRCS} ${extra_windows_SRCS})
|
add_executable(${PROJECT_NAME})
|
||||||
endif()
|
endif()
|
||||||
add_dependencies(${PROJECT_NAME} GenerateVersion)
|
list(SORT client_SRCS)
|
||||||
|
target_sources(${PROJECT_NAME} PRIVATE
|
||||||
|
$<TARGET_OBJECTS:EngineCommon>
|
||||||
|
${client_SRCS}
|
||||||
|
${extra_windows_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
${PROJECT_NAME}
|
${PROJECT_NAME}
|
||||||
${ZLIB_LIBRARIES}
|
${ZLIB_LIBRARIES}
|
||||||
|
@ -661,12 +685,18 @@ endif(BUILD_CLIENT)
|
||||||
|
|
||||||
|
|
||||||
if(BUILD_SERVER)
|
if(BUILD_SERVER)
|
||||||
add_executable(${PROJECT_NAME}server ${server_SRCS} ${extra_windows_SRCS})
|
# server target
|
||||||
add_dependencies(${PROJECT_NAME}server GenerateVersion)
|
add_executable(${PROJECT_NAME}server)
|
||||||
|
list(SORT server_SRCS)
|
||||||
|
target_sources(${PROJECT_NAME}server PRIVATE
|
||||||
|
$<TARGET_OBJECTS:EngineCommon>
|
||||||
|
${server_SRCS}
|
||||||
|
${extra_windows_SRCS}
|
||||||
|
)
|
||||||
|
|
||||||
|
# don't link the irrlicht library
|
||||||
get_target_property(
|
get_target_property(
|
||||||
IRRLICHT_INCLUDES IrrlichtMt::IrrlichtMt INTERFACE_INCLUDE_DIRECTORIES)
|
IRRLICHT_INCLUDES IrrlichtMt::IrrlichtMt INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
# Doesn't work without PRIVATE/PUBLIC/INTERFACE mode specified.
|
|
||||||
target_include_directories(${PROJECT_NAME}server PRIVATE ${IRRLICHT_INCLUDES})
|
target_include_directories(${PROJECT_NAME}server PRIVATE ${IRRLICHT_INCLUDES})
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
${PROJECT_NAME}server
|
${PROJECT_NAME}server
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
set(server_SRCS
|
set(common_server_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/activeobjectmgr.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/activeobjectmgr.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/ban.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/ban.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/clientiface.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/clientiface.cpp
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
set(JTHREAD_SRCS
|
set(threading_SRCS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/event.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/event.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/thread.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/thread.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/semaphore.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/semaphore.cpp
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue