From b123022530997df901abbfc7f8dab2846e7d1d7a Mon Sep 17 00:00:00 2001
From: William Breathitt Gray <vilhelm.gray@gmail.com>
Date: Sat, 6 Jun 2020 13:39:46 -0400
Subject: [PATCH] Add CMake install targets

Fixes: https://github.com/coelckers/prboom-plus/issues/70
---
 prboom2/CMakeLists.txt      | 2 +-
 prboom2/data/CMakeLists.txt | 2 ++
 prboom2/src/CMakeLists.txt  | 3 +++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/prboom2/CMakeLists.txt b/prboom2/CMakeLists.txt
index 4aba6b94..932182b6 100644
--- a/prboom2/CMakeLists.txt
+++ b/prboom2/CMakeLists.txt
@@ -150,7 +150,7 @@ check_symbol_exists(SDL_JoystickGetAxis "SDL.h" HAVE_SDL_JOYSTICKGETAXIS)
 set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_PREV})
 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES_PREV})
 
-set(DOOMWADDIR "${CMAKE_INSTALL_PREFIX}/share/games/doom" CACHE PATH "Path to install prboom.wad and look for other WAD files")
+set(DOOMWADDIR "${CMAKE_INSTALL_PREFIX}/share/games/doom" CACHE PATH "Path to look for WAD files")
 
 option(SIMPLECHECKS "Enable checks which only impose significant overhead if a posible error is detected" ON)
 option(ZONEIDCHECK "Enable id checks on zone blocks, to detect corrupted and illegally freed blocks" ON)
diff --git a/prboom2/data/CMakeLists.txt b/prboom2/data/CMakeLists.txt
index b855e9e5..33e1d873 100644
--- a/prboom2/data/CMakeLists.txt
+++ b/prboom2/data/CMakeLists.txt
@@ -362,3 +362,5 @@ add_custom_command(
     DEPENDS rdatawad ${WAD_SRC}
 )
 add_custom_target(prboomwad DEPENDS ${WAD_DATA_PATH})
+set(WAD_INSTALL_PATH ${DOOMWADDIR} CACHE PATH "Path to install prboom.wad")
+install(FILES ${WAD_DATA_PATH} DESTINATION ${WAD_INSTALL_PATH} COMPONENT "PrBoom-Plus internal WAD")
diff --git a/prboom2/src/CMakeLists.txt b/prboom2/src/CMakeLists.txt
index b5a0f6bd..89505603 100644
--- a/prboom2/src/CMakeLists.txt
+++ b/prboom2/src/CMakeLists.txt
@@ -340,6 +340,8 @@ function(AddGameExecutable TARGET SOURCES)
             COMMAND ${CMAKE_COMMAND} -E copy_if_different ${WAD_DATA_PATH} $<TARGET_FILE_DIR:prboom-plus>
         )
     endif()
+
+    install(TARGETS ${TARGET} COMPONENT "Game executable")
 endfunction()
 
 AddGameExecutable(prboom-plus "${PRBOOM_PLUS_SOURCES}")
@@ -426,6 +428,7 @@ if(BUILD_SERVER AND SDL2_NET_FOUND)
         RUNTIME_OUTPUT_DIRECTORY ${PRBOOM_OUTPUT_PATH}
     )
     ApplySDL2NetOptions(prboom-plus-game-server)
+    install(TARGETS prboom-plus-game-server COMPONENT "Game server executable")
 endif()
 
 
-- 
2.26.2

