From 995e4a59b5c4e4390ca5cc2964799571b7ec6f9b Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Mon, 12 Jul 2021 03:05:47 +0300 Subject: [PATCH] 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) --- CMakeLists.txt | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d495922e..787eca9ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -724,8 +724,7 @@ set(LIBS_SERVER ) # Target -set(TARGET_SERVER ${SERVER_EXECUTABLE}) -add_executable(${TARGET_SERVER} +add_executable(Server ${DEPS} ${SERVER_SRC} ${SERVER_ICON} @@ -733,6 +732,10 @@ add_executable(${TARGET_SERVER} $ ) +set_property(TARGET Server + PROPERTY OUTPUT_NAME ${SERVER_EXECUTABLE} +) + if(GEOLOCATION) add_library(GeoLite2PP STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/infclassr/GeoLite2PP/GeoLite2PP.cpp @@ -746,31 +749,31 @@ if(GEOLOCATION) ) add_library(GeoLite2PP::GeoLite2PP ALIAS GeoLite2PP) - target_sources(${TARGET_SERVER} PRIVATE + target_sources(Server PRIVATE "src/infclassr/geolocation.cpp" "src/infclassr/geolocation.h" ) - target_compile_definitions(${TARGET_SERVER} PRIVATE CONF_GEOLOCATION) - target_link_libraries(${TARGET_SERVER} + target_compile_definitions(Server PRIVATE CONF_GEOLOCATION) + target_link_libraries(Server GeoLite2PP::GeoLite2PP MaxMindDB::MaxMindDB ) endif() -target_link_libraries(${TARGET_SERVER} ${LIBS_SERVER}) -list(APPEND TARGETS_OWN ${TARGET_SERVER}) -list(APPEND TARGETS_LINK ${TARGET_SERVER}) +target_link_libraries(Server ${LIBS_SERVER}) +list(APPEND TARGETS_OWN Server) +list(APPEND TARGETS_LINK Server) -target_link_libraries(${TARGET_SERVER} md5) -target_link_libraries(${TARGET_SERVER} engine-shared) -target_link_libraries(${TARGET_SERVER} game-shared) -target_link_libraries(${TARGET_SERVER} ICU::i18n) -target_link_libraries(${TARGET_SERVER} ICU::uc) +target_link_libraries(Server md5) +target_link_libraries(Server engine-shared) +target_link_libraries(Server game-shared) +target_link_libraries(Server ICU::i18n) +target_link_libraries(Server ICU::uc) if(TARGET_OS AND TARGET_OS STREQUAL "mac") set(SERVER_LAUNCHER_SRC src/osxlaunch/server.mm) - set(TARGET_SERVER_LAUNCHER ${TARGET_SERVER}-Launcher) + set(TARGET_SERVER_LAUNCHER Server-Launcher) add_executable(${TARGET_SERVER_LAUNCHER} ${SERVER_LAUNCHER_SRC}) target_link_libraries(${TARGET_SERVER_LAUNCHER} ${COCOA}) list(APPEND TARGETS_OWN ${TARGET_SERVER_LAUNCHER})