CMake: Make dll bundling optional
[xonotic/netradiant.git] / CMakeLists.txt
index b95fd6280666f98ccadccc6278402bc3da0cffde..928461deec0b3468815218cf8a50a72e00b1ad88 100644 (file)
@@ -115,8 +115,15 @@ endif ()
 include_directories("${PROJECT_SOURCE_DIR}/include")
 include_directories("${PROJECT_SOURCE_DIR}/libs")
 
+if (WIN32 AND NOT CMAKE_CROSSCOMPILING)
+    set(BUNDLE_LIBRARIES_DEFAULT ON)
+else ()
+    set(BUNDLE_LIBRARIES_DEFAULT OFF)
+endif ()
+option(BUNDLE_LIBRARIES "Bundle libraries" ${BUNDLE_LIBRARIES_DEFAULT})
+
 macro(copy_dlls target)
-    if (WIN32)
+    if (BUNDLE_LIBRARIES)
         add_custom_command(TARGET ${target} POST_BUILD
                 COMMAND bash
                 ARGS -c "ldd '$<TARGET_FILE:${target}>' | grep -v /c/Windows | awk '{ print $1 }' | while read dll; do cp \"$(which $dll)\" '${PROJECT_BINARY_DIR}'; done"
@@ -194,13 +201,11 @@ 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(COPY ${DATA_FILES} DESTINATION "${PROJECT_BINARY_DIR}")
-    file(COPY ${DOCS_FILES} DESTINATION "${PROJECT_BINARY_DIR}/docs")
 endif ()
 
 #-----------------------------------------------------------------------
@@ -228,9 +233,32 @@ install(
         "${PROJECT_BINARY_DIR}/RADIANT_PATCH"
         DESTINATION ${CMAKE_INSTALL_PREFIX}
 )
-file(GLOB GAME_FILES "${PROJECT_SOURCE_DIR}/games/*")
+
+install(
+        DIRECTORY
+        ${PROJECT_SOURCE_DIR}/setup/data/tools/
+        ${PROJECT_SOURCE_DIR}/docs
+        DESTINATION ${CMAKE_INSTALL_PREFIX}
+)
+
+set(GAME_FILES
+        DarkPlacesPack
+        NexuizPack
+        OpenArenaPack
+        OsirionPack
+        Q3Pack
+        Quake2Pack
+        QuakePack
+        QuetooPack
+        TremulousPack
+        UFOAIPack
+        UnvanquishedPack
+        WarsowPack
+        XonoticPack
+        )
 unset(_tmp)
 foreach (it ${GAME_FILES})
+    set(it "${PROJECT_BINARY_DIR}/games/${it}")
     list(APPEND _tmp "${it}/games")
     file(GLOB GAME_DIR "${it}/*.game")
     list(APPEND _tmp "${GAME_DIR}")
@@ -239,9 +267,7 @@ set(GAME_FILES ${_tmp})
 
 install(
         DIRECTORY
-        ${PROJECT_SOURCE_DIR}/setup/data/tools/
-        ${PROJECT_SOURCE_DIR}/docs
         ${GAME_FILES}
         DESTINATION ${CMAKE_INSTALL_PREFIX}
+        OPTIONAL
 )
-