Skip to content

Commit 995e4a5

Browse files
committed
CMake: Give the server target a permanent name independent of exec name
The name used to be the same as the server executable name but such approach leads to massive rebuild on the exec name changed. (A use-case: production and testing builds with different executables)
1 parent f4b7618 commit 995e4a5

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

CMakeLists.txt

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -724,15 +724,18 @@ set(LIBS_SERVER
724724
)
725725

726726
# Target
727-
set(TARGET_SERVER ${SERVER_EXECUTABLE})
728-
add_executable(${TARGET_SERVER}
727+
add_executable(Server
729728
${DEPS}
730729
${SERVER_SRC}
731730
${SERVER_ICON}
732731
$<TARGET_OBJECTS:engine-shared>
733732
$<TARGET_OBJECTS:game-shared>
734733
)
735734

735+
set_property(TARGET Server
736+
PROPERTY OUTPUT_NAME ${SERVER_EXECUTABLE}
737+
)
738+
736739
if(GEOLOCATION)
737740
add_library(GeoLite2PP STATIC
738741
${CMAKE_CURRENT_SOURCE_DIR}/src/infclassr/GeoLite2PP/GeoLite2PP.cpp
@@ -746,31 +749,31 @@ if(GEOLOCATION)
746749
)
747750
add_library(GeoLite2PP::GeoLite2PP ALIAS GeoLite2PP)
748751

749-
target_sources(${TARGET_SERVER} PRIVATE
752+
target_sources(Server PRIVATE
750753
"src/infclassr/geolocation.cpp"
751754
"src/infclassr/geolocation.h"
752755
)
753756

754-
target_compile_definitions(${TARGET_SERVER} PRIVATE CONF_GEOLOCATION)
755-
target_link_libraries(${TARGET_SERVER}
757+
target_compile_definitions(Server PRIVATE CONF_GEOLOCATION)
758+
target_link_libraries(Server
756759
GeoLite2PP::GeoLite2PP
757760
MaxMindDB::MaxMindDB
758761
)
759762
endif()
760763

761-
target_link_libraries(${TARGET_SERVER} ${LIBS_SERVER})
762-
list(APPEND TARGETS_OWN ${TARGET_SERVER})
763-
list(APPEND TARGETS_LINK ${TARGET_SERVER})
764+
target_link_libraries(Server ${LIBS_SERVER})
765+
list(APPEND TARGETS_OWN Server)
766+
list(APPEND TARGETS_LINK Server)
764767

765-
target_link_libraries(${TARGET_SERVER} md5)
766-
target_link_libraries(${TARGET_SERVER} engine-shared)
767-
target_link_libraries(${TARGET_SERVER} game-shared)
768-
target_link_libraries(${TARGET_SERVER} ICU::i18n)
769-
target_link_libraries(${TARGET_SERVER} ICU::uc)
768+
target_link_libraries(Server md5)
769+
target_link_libraries(Server engine-shared)
770+
target_link_libraries(Server game-shared)
771+
target_link_libraries(Server ICU::i18n)
772+
target_link_libraries(Server ICU::uc)
770773

771774
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
772775
set(SERVER_LAUNCHER_SRC src/osxlaunch/server.mm)
773-
set(TARGET_SERVER_LAUNCHER ${TARGET_SERVER}-Launcher)
776+
set(TARGET_SERVER_LAUNCHER Server-Launcher)
774777
add_executable(${TARGET_SERVER_LAUNCHER} ${SERVER_LAUNCHER_SRC})
775778
target_link_libraries(${TARGET_SERVER_LAUNCHER} ${COCOA})
776779
list(APPEND TARGETS_OWN ${TARGET_SERVER_LAUNCHER})

0 commit comments

Comments
 (0)