CMake: switch minizip casing
[xonotic/netradiant.git] / CMakeLists.txt
index 6876c36..928461d 100644 (file)
@@ -4,8 +4,8 @@ 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")
+if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+    set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/install" CACHE PATH "..." FORCE)
 endif ()
 
 #-----------------------------------------------------------------------
@@ -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"
@@ -152,10 +159,6 @@ endif ()
 # Radiant
 #-----------------------------------------------------------------------
 
-if (BUILD_RADIANT)
-    add_subdirectory(radiant build)
-endif ()
-
 if (CMAKE_EXECUTABLE_SUFFIX)
     string(REGEX REPLACE "^[.]" "" RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
 else ()
@@ -166,7 +169,26 @@ else ()
     )
 endif ()
 
+macro(radiant_tool name)
+    add_executable(${name} ${ARGN})
+    install(
+            TARGETS ${name}
+            RUNTIME DESTINATION .
+    )
+    if (NOT (CMAKE_EXECUTABLE_SUFFIX STREQUAL ".${RADIANT_EXECUTABLE}"))
+        add_custom_command(TARGET ${name} POST_BUILD
+                COMMAND ln -f -s "$<TARGET_FILE_NAME:${name}>" "${PROJECT_BINARY_DIR}/${name}.${RADIANT_EXECUTABLE}"
+                VERBATIM
+                )
+        install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
+            ${name}${CMAKE_EXECUTABLE_SUFFIX} \
+            ${CMAKE_INSTALL_PREFIX}/${name}.${RADIANT_EXECUTABLE} \
+        )")
+    endif ()
+endmacro()
+
 if (BUILD_RADIANT)
+    add_subdirectory(radiant build)
     set_target_properties(radiant PROPERTIES
             COMPILE_DEFINITIONS RADIANT_EXECUTABLE="${RADIANT_EXECUTABLE}"
             )
@@ -179,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 ()
 
 #-----------------------------------------------------------------------
@@ -213,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}")
@@ -224,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
 )
-