From ce236dad226cf25d474f700a72d73e6dceb0799f Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Wed, 8 Mar 2023 00:57:43 +0300 Subject: [PATCH] CMake: Fix installation for optional targets --- CMakeLists.txt | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 55ad4726f..c39784c1a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2988,11 +2988,15 @@ else() set(TARGET_TOOLS) endif() -set(CPACK_TARGETS - game-client - game-server - ${TARGET_TOOLS} -) +set(CPACK_TARGETS) +if(TARGET game-client) + list(APPEND CPACK_TARGETS game-client) +endif() +if(TARGET game-server) + list(APPEND CPACK_TARGETS game-server) +endif() +list(APPEND CPACK_TARGETS ${TARGET_TOOLS}) + if(STEAMAPI_KIND STREQUAL SHARED) list(APPEND CPACK_TARGETS ${TARGET_STEAMAPI}) endif() @@ -3019,11 +3023,15 @@ endif() if(NOT DEV) include(GNUInstallDirs) install(DIRECTORY data DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ddnet COMPONENT data) - install(TARGETS game-client DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) + if(TARGET game-client) + install(TARGETS game-client DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT client) + endif() if(STEAMAPI_KIND STREQUAL SHARED) install(TARGETS ${TARGET_STEAMAPI} DESTINATION ${CMAKE_INSTALL_LIBDIR}/ddnet COMPONENT client) endif() - install(TARGETS game-server DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) + if(TARGET game-server) + install(TARGETS game-server DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT server) + endif() if(ANTIBOT) install(TARGETS ${TARGET_ANTIBOT} DESTINATION ${CMAKE_INSTALL_LIBDIR}/ddnet COMPONENT server) endif()