From de492e9d54db1afeecddf57a5d10002dfd09c2d5 Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 30 Jul 2017 22:22:39 +1000 Subject: [PATCH] CMake: add install target --- CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++++++--- contrib/CMakeLists.txt | 4 ++++ plugins/CMakeLists.txt | 4 ++++ radiant/CMakeLists.txt | 5 +++++ 4 files changed, 50 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 065ddf10..6876c362 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,10 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") project(NetRadiant C CXX) option(BUILD_RADIANT "Build the gui" ON) +if (NOT CMAKE_INSTALL_PREFIX) + set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install") +endif () + #----------------------------------------------------------------------- # Version #----------------------------------------------------------------------- @@ -174,13 +178,14 @@ endif () add_subdirectory(tools) +file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/setup/data/tools/*") +file(GLOB DOCS_FILES "${PROJECT_SOURCE_DIR}/docs/*") + if (NOT (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)) # Copy data files from sources to the build directory message(STATUS "Copying data files") - file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/setup/data/tools/*") file(COPY ${DATA_FILES} DESTINATION "${PROJECT_BINARY_DIR}") - file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/docs/*") - file(COPY ${DATA_FILES} DESTINATION "${PROJECT_BINARY_DIR}/docs") + file(COPY ${DOCS_FILES} DESTINATION "${PROJECT_BINARY_DIR}/docs") endif () #----------------------------------------------------------------------- @@ -196,3 +201,32 @@ add_custom_target(game_packs if (DOWNLOAD_GAMEPACKS) add_custom_target(game_packs_all ALL DEPENDS game_packs) endif () + +#----------------------------------------------------------------------- +# Install +#----------------------------------------------------------------------- + +install( + FILES + "${PROJECT_BINARY_DIR}/RADIANT_MAJOR" + "${PROJECT_BINARY_DIR}/RADIANT_MINOR" + "${PROJECT_BINARY_DIR}/RADIANT_PATCH" + DESTINATION ${CMAKE_INSTALL_PREFIX} +) +file(GLOB GAME_FILES "${PROJECT_SOURCE_DIR}/games/*") +unset(_tmp) +foreach (it ${GAME_FILES}) + list(APPEND _tmp "${it}/games") + file(GLOB GAME_DIR "${it}/*.game") + list(APPEND _tmp "${GAME_DIR}") +endforeach () +set(GAME_FILES ${_tmp}) + +install( + DIRECTORY + ${PROJECT_SOURCE_DIR}/setup/data/tools/ + ${PROJECT_SOURCE_DIR}/docs + ${GAME_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX} +) + diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 98020146..8233ea1e 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -6,6 +6,10 @@ macro(radiant_plugin name) add_library(${name} MODULE ${ARGN}) add_dependencies(plugins ${name}) copy_dlls(${name}) + install( + TARGETS ${name} + LIBRARY DESTINATION plugins + ) endmacro() add_subdirectory(bobtoolz) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index bc9fcad3..a41ed780 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -6,6 +6,10 @@ macro(radiant_plugin name) add_library(${name} MODULE ${ARGN}) add_dependencies(modules ${name}) copy_dlls(${name}) + install( + TARGETS ${name} + LIBRARY DESTINATION modules + ) endmacro() add_subdirectory(archivepak) diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index 287cc951..89563063 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -130,3 +130,8 @@ if (X11_LIBRARIES) endif () copy_dlls(radiant) + +install( + TARGETS radiant + RUNTIME DESTINATION . +) -- 2.39.2