]> git.rm.cloudns.org Git - xonotic/netradiant.git/commitdiff
cmake: allow to configure for radiant/tools/gamepacks separately
authorThomas Debesse <dev@illwieckz.net>
Wed, 14 Nov 2018 21:13:18 +0000 (22:13 +0100)
committerThomas Debesse <dev@illwieckz.net>
Sat, 18 May 2019 20:47:42 +0000 (22:47 +0200)
people can switch on/off

- BUILD_RADIANT
- BUILD_TOOLS
- DOWNLOAD_GAMEPACKS

CMakeLists.txt

index ebfef96b0da4567c6751a1159dd6d1158e73593b..c18cf13e8b0483722cecd014da1ad512c15d0d39 100644 (file)
@@ -3,10 +3,17 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
 project(NetRadiant C CXX)
 
 option(BUILD_RADIANT "Build the GUI" ON)
+option(BUILD_TOOLS "Build the tools" ON)
 option(BUILD_CRUNCH "Build Crunch image support" OFF)
+option(DOWNLOAD_GAMEPACKS "Download game packs" ON)
 option(USE_WERROR "Build with -Werror -pedantic-errors" OFF)
 option(FHS_INSTALL "Install according to Filesystem Hierarchy Standard" OFF)
 
+set(BUILD_BINARIES OFF CACHE INTERNAL "...")
+if (BUILD_RADIANT OR BUILD_TOOLS)
+    set(BUILD_BINARIES ON)
+endif ()
+
 #-----------------------------------------------------------------------
 # Paths
 #-----------------------------------------------------------------------
@@ -61,21 +68,23 @@ message(STATUS "Building ${PROJECT_NAME} ${RADIANT_VERSION_STRING} ${RADIANT_ABO
 # Language standard
 #-----------------------------------------------------------------------
 
-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_CXX_EXTENSIONS OFF)
-
-if (CMAKE_VERSION VERSION_LESS "3.1")
-    if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
-        include(CheckCXXCompilerFlag)
-        check_cxx_compiler_flag(--std=c++${CMAKE_CXX_STANDARD} STD_CXX)
-        if (STD_CXX)
-            set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++${CMAKE_CXX_STANDARD}")
+if (BUILD_BINARIES)
+    set(CMAKE_CXX_STANDARD 11)
+    set(CMAKE_CXX_STANDARD_REQUIRED ON)
+    set(CMAKE_CXX_EXTENSIONS OFF)
+
+    if (CMAKE_VERSION VERSION_LESS "3.1")
+        if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR CMAKE_COMPILER_IS_GNUCXX)
+            include(CheckCXXCompilerFlag)
+            check_cxx_compiler_flag(--std=c++${CMAKE_CXX_STANDARD} STD_CXX)
+            if (STD_CXX)
+                set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++${CMAKE_CXX_STANDARD}")
+            else ()
+                message(SEND_ERROR "Requires C++${CMAKE_CXX_STANDARD} or better")
+            endif ()
         else ()
-            message(SEND_ERROR "Requires C++${CMAKE_CXX_STANDARD} or better")
+            message(WARNING "Unrecognized compiler: ${CMAKE_CXX_COMPILER_ID}, make sure it supports C++${CMAKE_CXX_STANDARD}")
         endif ()
-    else ()
-        message(WARNING "Unrecognized compiler: ${CMAKE_CXX_COMPILER_ID}, make sure it supports C++${CMAKE_CXX_STANDARD}")
     endif ()
 endif ()
 
@@ -83,100 +92,106 @@ endif ()
 # Flags
 #-----------------------------------------------------------------------
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
+if (BUILD_BINARIES)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
 
-macro(addflags_c args)
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${args}")
-endmacro()
+    macro(addflags_c args)
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${args}")
+    endmacro()
 
-macro(addflags_cxx args)
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${args}")
+    macro(addflags_cxx args)
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${args}")
+    endmacro()
 
-endmacro()
-macro(addflags args)
-    addflags_c("${args}")
-    addflags_cxx("${args}")
-endmacro()
+    macro(addflags args)
+        addflags_c("${args}")
+        addflags_cxx("${args}")
+    endmacro()
 
-addflags("-fno-strict-aliasing")
-if (NOT WIN32)
-    addflags("-fvisibility=hidden")
-endif ()
+    addflags("-fno-strict-aliasing")
+    if (NOT WIN32)
+        addflags("-fvisibility=hidden")
+    endif ()
 
-if (USE_WERROR)
-    addflags("-Werror")
-    addflags("-pedantic-errors")
-endif ()
+    if (USE_WERROR)
+        addflags("-Werror")
+        addflags("-pedantic-errors")
+    endif ()
 
-addflags("-Wall")
-addflags("-Wextra")
-addflags("-pedantic")
+    addflags("-Wall")
+    addflags("-Wextra")
+    addflags("-pedantic")
 
-addflags_c("-Wno-deprecated-declarations") # vfs.c: g_strdown
+    addflags_c("-Wno-deprecated-declarations") # vfs.c: g_strdown
 
-addflags("-Wno-unused-function")
-addflags("-Wno-unused-variable")
-addflags("-Wno-unused-parameter")
+    addflags("-Wno-unused-function")
+    addflags("-Wno-unused-variable")
+    addflags("-Wno-unused-parameter")
 
-set(CMAKE_POSITION_INDEPENDENT_CODE 1)
+    set(CMAKE_POSITION_INDEPENDENT_CODE 1)
+endif ()
 
 if (BUILD_RADIANT)
-set(GTK_TARGET 2 CACHE STRING "GTK target")
-add_definitions(-DGTK_TARGET=${GTK_TARGET})
+    set(GTK_TARGET 2 CACHE STRING "GTK target")
+    add_definitions(-DGTK_TARGET=${GTK_TARGET})
 endif()
 
 #-----------------------------------------------------------------------
 # Defs
 #-----------------------------------------------------------------------
 
-add_definitions(-DRADIANT_VERSION="${NetRadiant_VERSION}")
-add_definitions(-DRADIANT_MAJOR_VERSION="${NetRadiant_VERSION_MAJOR}")
-add_definitions(-DRADIANT_MINOR_VERSION="${NetRadiant_VERSION_MINOR}")
-add_definitions(-DRADIANT_PATCH_VERSION="${NetRadiant_VERSION_PATCH}")
+if (BUILD_BINARIES)
+    add_definitions(-DRADIANT_VERSION="${NetRadiant_VERSION}")
+    add_definitions(-DRADIANT_MAJOR_VERSION="${NetRadiant_VERSION_MAJOR}")
+    add_definitions(-DRADIANT_MINOR_VERSION="${NetRadiant_VERSION_MINOR}")
+    add_definitions(-DRADIANT_PATCH_VERSION="${NetRadiant_VERSION_PATCH}")
 
-add_definitions(-DRADIANT_ABOUTMSG="${NetRadiant_ABOUT}")
+    add_definitions(-DRADIANT_ABOUTMSG="${NetRadiant_ABOUT}")
 
-if (NOT CMAKE_BUILD_TYPE MATCHES Release)
-    add_definitions(-D_DEBUG=1)
+    if (NOT CMAKE_BUILD_TYPE MATCHES Release)
+        add_definitions(-D_DEBUG=1)
+    endif ()
 endif ()
 
 if (BUILD_RADIANT)
-macro(disable_deprecated name gtk2only)
-    add_definitions(-D${name}_DISABLE_SINGLE_INCLUDES)
-    if ((${gtk2only} EQUAL 0) OR (GTK_TARGET EQUAL 2))
-        add_definitions(-D${name}_DISABLE_DEPRECATED)
-    endif ()
-endmacro()
-
-disable_deprecated(ATK 0)
-disable_deprecated(G 0)
-disable_deprecated(GDK 0)
-disable_deprecated(GDK_PIXBUF 0)
-disable_deprecated(GTK 1)
-disable_deprecated(PANGO 0)
-endif()
+    macro(disable_deprecated name gtk2only)
+        add_definitions(-D${name}_DISABLE_SINGLE_INCLUDES)
+        if ((${gtk2only} EQUAL 0) OR (GTK_TARGET EQUAL 2))
+            add_definitions(-D${name}_DISABLE_DEPRECATED)
+        endif ()
+    endmacro()
+
+    disable_deprecated(ATK 0)
+    disable_deprecated(G 0)
+    disable_deprecated(GDK 0)
+    disable_deprecated(GDK_PIXBUF 0)
+    disable_deprecated(GTK 1)
+    disable_deprecated(PANGO 0)
+endif ()
 
-if (APPLE)
-    if (BUILD_RADIANT)
-    option(XWINDOWS "Build against X11" ON)
-    endif()
+if (BUILD_BINARIES)
+    if (APPLE)
+        if (BUILD_RADIANT)
+        option(XWINDOWS "Build against X11" ON)
+        endif()
 
-    add_definitions(
-            -DPOSIX=1
-    )
-elseif (WIN32)
-    add_definitions(
-            -DWIN32=1
-            -D_WIN32=1
-    )
-else ()
-    if (BUILD_RADIANT)
-    set(XWINDOWS ON)
-    endif()
+        add_definitions(
+                -DPOSIX=1
+        )
+    elseif (WIN32)
+        add_definitions(
+                -DWIN32=1
+                -D_WIN32=1
+        )
+    else ()
+        if (BUILD_RADIANT)
+        set(XWINDOWS ON)
+        endif()
 
-    add_definitions(
-            -DPOSIX=1
-    )
+        add_definitions(
+                -DPOSIX=1
+        )
+    endif ()
 endif ()
 
 if (BUILD_RADIANT AND XWINDOWS)
@@ -185,36 +200,40 @@ if (BUILD_RADIANT AND XWINDOWS)
     add_definitions(-DXWINDOWS=1)
 endif ()
 
-include_directories("${PROJECT_SOURCE_DIR}/include")
-include_directories("${PROJECT_SOURCE_DIR}/libs")
+if (BUILD_BINARIES)
+    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 ()
+    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})
+    option(BUNDLE_LIBRARIES "Bundle libraries" ${BUNDLE_LIBRARIES_DEFAULT})
 
-macro(copy_dlls target)
-    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"
-                VERBATIM
-                )
-    endif ()
-endmacro()
+    macro(copy_dlls target)
+        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"
+                    VERBATIM
+                    )
+        endif ()
+    endmacro()
+endif ()
 
 #-----------------------------------------------------------------------
 # Libraries
 #-----------------------------------------------------------------------
 
-add_subdirectory(libs)
+if (BUILD_BINARIES)
+    add_subdirectory(libs)
+endif ()
 
 if (BUILD_RADIANT)
-add_subdirectory(include)
-endif()
+    add_subdirectory(include)
+endif ()
 
 #-----------------------------------------------------------------------
 # Plugins
@@ -236,45 +255,47 @@ endif ()
 # Radiant
 #-----------------------------------------------------------------------
 
-if (CMAKE_EXECUTABLE_SUFFIX)
-    string(REGEX REPLACE "^[.]" "" RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
-endif ()
+if (BUILD_BINARIES)
+    if (CMAKE_EXECUTABLE_SUFFIX)
+        string(REGEX REPLACE "^[.]" "" RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
+    endif ()
 
-macro(radiant_tool name)
-    add_executable(${name} ${ARGN})
-    install(
-            TARGETS ${name}
-            RUNTIME DESTINATION ${RADIANT_BIN_SUBDIR}/.
-    )
-endmacro()
+    macro(radiant_tool name)
+        add_executable(${name} ${ARGN})
+        install(
+                TARGETS ${name}
+                RUNTIME DESTINATION ${RADIANT_BIN_SUBDIR}/.
+        )
+    endmacro()
 
-if (BUILD_RADIANT)
-    add_subdirectory(radiant _radiant)
-    set_target_properties(${RADIANT_BASENAME} PROPERTIES
-            COMPILE_DEFINITIONS RADIANT_EXECUTABLE="${RADIANT_EXECUTABLE}"
-            )
+    if (BUILD_RADIANT)
+        add_subdirectory(radiant _radiant)
+        set_target_properties(${RADIANT_BASENAME} PROPERTIES
+                COMPILE_DEFINITIONS RADIANT_EXECUTABLE="${RADIANT_EXECUTABLE}"
+                )
+    endif ()
 endif ()
 
 #-----------------------------------------------------------------------
 # Tools
 #-----------------------------------------------------------------------
 
-add_subdirectory(tools)
+if (BUILD_TOOLS)
+    add_subdirectory(tools)
 
-file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/setup/data/tools/*")
+    file(GLOB DATA_FILES "${PROJECT_SOURCE_DIR}/setup/data/tools/*")
 
-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}")
+    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}")
+    endif ()
 endif ()
 
 #-----------------------------------------------------------------------
 # Game packs
 #-----------------------------------------------------------------------
 
-option(DOWNLOAD_GAMEPACKS "Download game packs" ON)
-
 set(GAMEPACKS_LICENSE_LIST free CACHE STRING "Download game packs by license")
 set(GAMEPACKS_NAME_LIST none CACHE STRING "Download game packs by name")
 
@@ -289,11 +310,13 @@ endif()
 # Install
 #-----------------------------------------------------------------------
 
-install(DIRECTORY
-        setup/data/tools/
-        docs
-        DESTINATION ${RADIANT_DATA_SUBDIR}/.
-)
+if (BUILD_BINARIES)
+    install(DIRECTORY
+            setup/data/tools/
+            docs
+            DESTINATION ${RADIANT_DATA_SUBDIR}/.
+    )
+endif ()
 
 if (DOWNLOAD_GAMEPACKS)
     install(CODE
@@ -301,7 +324,7 @@ if (DOWNLOAD_GAMEPACKS)
         )
 endif()
 
-if(NOT WIN32 AND NOT APPLE AND FHS_INSTALL)
+if(BUILD_BINARIES AND FHS_INSTALL AND NOT WIN32 AND NOT APPLE)
     install(FILES
             ${PROJECT_SOURCE_DIR}/icons/netradiant.png
             DESTINATION ${CMAKE_INSTALL_PREFIX}/share/pixmaps