cmake: use option() in CMakeConfig.txt
authorMichael Wallner <mike@php.net>
Thu, 27 Feb 2020 08:12:38 +0000 (09:12 +0100)
committerMichael Wallner <mike@php.net>
Thu, 27 Feb 2020 08:12:38 +0000 (09:12 +0100)
CMake/_Include.cmake
CMakeConfig.txt
docs/CMakeLists.txt

index 9f6891c2a35145492ed15ccc3694813bfe801631..0f25ab4875a6eb363f298ade9b2c5646a51ae3ea 100644 (file)
@@ -48,13 +48,13 @@ if(ENABLE_SASL)
 endif()
 
 ## hashes
-if(ENABLE_FNV64_HASH)
+if(ENABLE_HASH_FNV64)
     set(HAVE_FNV64_HASH 1)
 endif()
-if(ENABLE_MURMUR_HASH)
+if(ENABLE_HASH_MURMUR)
     set(HAVE_MURMUR_HASH 1)
 endif()
-if(ENABLE_HSIEH_HASH)
+if(ENABLE_HASH_HSIEH)
     set(HAVE_HSIEH_HASH 1)
 endif()
 
index 209f4770976161e7de1f380682c58d16b65d1fd6..707ff4bbedd470bab7af83b227645a54552fba7a 100644 (file)
@@ -3,61 +3,52 @@ set(CMAKE_BUILD_TYPE Release
 set(CMAKE_INSTALL_PREFIX /usr/local
     CACHE PATH "install prefix")
 
-# make test
-
-set(BUILD_TESTING ON
-    CACHE STRING "whether to enable build of the test suite")
+option(BUILD_TESTING        "whether to enable build of the test suite"
+        OFF)
+option(BUILD_DOCSONLY       "build *only* documentation"
+        OFF)
+option(BUILD_DOCS           "build documentation"
+        OFF)
+option(BUILD_DOCS_HTML      "build HTML docs"
+        ${BUILD_DOCS})
+option(BUILD_DOCS_MAN       "build manpages"
+        ${BUILD_DOCS})
+option(BUILD_DOCS_MANGZ     "gzip manpages"
+        ${BUILD_DOCS_MAN})
+
+option(ENABLE_DTRACE        "enable dtrace support"
+        OFF)
+option(ENABLE_HASH_FNV64    "enable fnv64 hash support"
+        ON)
+option(ENABLE_HASH_MURMUR   "enable murmur hash support"
+        ON)
+option(ENABLE_HASH_HSIEH    "enable hsieh hash support"
+        OFF)
+option(ENABLE_MEMASLAP      "enable memaslap client"
+        ON)
+option(ENABLE_SASL          "enable SASL support"
+        OFF)
 
 set(ENABLE_SANITIZERS ""
     CACHE STRING "sanitizers to enable (e.g. address undefined ...)")
 
-set(MEMCACHED_BINARY "/usr/bin/memcached"
-    CACHE FILEPATH "memcached binary")
-
-# sasl
-
-set(ENABLE_SASL OFF
-    CACHE BOOL "enable SASL support")
-
-# hashes
-
-set(ENABLE_FNV64_HASH ON
-    CACHE BOOL "enable fnv64 hash support")
-set(ENABLE_MURMUR_HASH ON
-    CACHE BOOL "enable murmur hash support")
-set(ENABLE_HSIEH_HASH OFF
-    CACHE BOOL "enable hsieh hash support")
-
-# memaslap, needs libevent and stdatomic
-set(ENABLE_MEMASLAP ON
-    CACHE BOOL "enable memaslap client")
-
-# dtrace
-
-set(ENABLE_DTRACE OFF
-    CACHE BOOL "enable dtrace support")
-
-# docs / sphinx
-
-set(BUILD_DOCS ON
-    CACHE BOOL "build documentation")
-
-set(BUILD_DOCSONLY OFF
-    CACHE BOOL "build *only* documentation")
-
-set(GZIP_MAN ON
-    CACHE BOOL "gzip manpages")
+if(BUILD_TESTING)
+    set(MEMCACHED_BINARY "/usr/bin/memcached"
+        CACHE FILEPATH "memcached binary")
+endif()
 
-set(SPHINX_OPTIONS ""
-    CACHE STRING "additional sphinx-build command line options")
-set(SPHINX_THEME "sphinx_rtd_theme"
-    CACHE STRING "sphinx HTML theme")
-set(SPHINX_THEME_OPTIONS "'collapse_navigation':False, 'navigation_depth':2, 'titles_only':False, 'includehidden':False"
-    CACHE STRING "sphinx HTML theme options")
-set(SPHINX_EXTENSIONS ""
-    CACHE STRING "comma separated list of quoted sphinx extensions")
-set(SPHINX_CONF_APPEND ""
-    CACHE STRING "append verbatim code to sphinx' conf.py")
+if(BUILD_DOCS)
+    set(SPHINX_OPTIONS ""
+        CACHE STRING "additional sphinx-build command line options")
+    set(SPHINX_THEME "sphinx_rtd_theme"
+        CACHE STRING "sphinx HTML theme")
+    set(SPHINX_THEME_OPTIONS "'collapse_navigation':False, 'navigation_depth':2, 'titles_only':False, 'includehidden':False"
+        CACHE STRING "sphinx HTML theme options")
+    set(SPHINX_EXTENSIONS ""
+        CACHE STRING "comma separated list of quoted sphinx extensions")
+    set(SPHINX_CONF_APPEND ""
+        CACHE STRING "append verbatim code to sphinx' conf.py")
+endif()
 
 # legacy
 
index e7ce95c9c607b82720ea23eed5f63b9b49845788..784fadb71b09332e77f53bdeb87eb336a33f42b0 100644 (file)
@@ -34,50 +34,56 @@ else()
             "${SPHINX_BUILD_DIR}/conf.py"
             @ONLY)
 
-    add_custom_target(html
-            ${SPHINX_EXECUTABLE}
-            -q -b html
-            -c "${SPHINX_BUILD_DIR}"
-            -d "${SPHINX_CACHE_DIR}"
-            ${SPHINX_OPTIONS}
-            "${SPHINX_SOURCE_DIR}"
-            "${SPHINX_HTML_DIR}"
-            BYPRODUCTS ${SPHINX_HTML_DIR}
-            )
-    add_custom_target(man ALL
-            ${SPHINX_EXECUTABLE}
-            -q -b man
-            -c "${SPHINX_BUILD_DIR}"
-            -d "${SPHINX_CACHE_DIR}"
-            ${SPHINX_OPTIONS}
-            "${SPHINX_SOURCE_DIR}"
-            "${SPHINX_MAN_DIR}"
-            BYPRODUCTS ${SPHINX_MAN_DIR}
-            )
-
-    set(MAN_EXT "")
-    if(GZIP_MAN)
-        find_program(PIGZ pigz)
-        if(PIGZ)
-            set(GZIP ${PIGZ})
-        else()
-            find_package(UnixCommands)
-        endif()
-        if(GZIP)
-            set(MAN_EXT ".gz")
-            add_custom_target(man_gz ALL
-                    ${GZIP} -kf ${SPHINX_MAN_DIR}/*.{1,3}
-                    DEPENDS man
-                    )
+    if(BUILD_DOCS_HTML)
+        add_custom_target(html
+                ${SPHINX_EXECUTABLE}
+                -q -b html
+                -c "${SPHINX_BUILD_DIR}"
+                -d "${SPHINX_CACHE_DIR}"
+                ${SPHINX_OPTIONS}
+                "${SPHINX_SOURCE_DIR}"
+                "${SPHINX_HTML_DIR}"
+                BYPRODUCTS ${SPHINX_HTML_DIR}
+                )
+    endif()
+
+    if(BUILD_DOCS_MAN)
+        add_custom_target(man ALL
+                ${SPHINX_EXECUTABLE}
+                -q -b man
+                -c "${SPHINX_BUILD_DIR}"
+                -d "${SPHINX_CACHE_DIR}"
+                ${SPHINX_OPTIONS}
+                "${SPHINX_SOURCE_DIR}"
+                "${SPHINX_MAN_DIR}"
+                BYPRODUCTS ${SPHINX_MAN_DIR}
+                )
+
+        set(MAN_EXT "")
+        if(BUILD_DOCS_MANGZ)
+            find_program(PIGZ pigz)
+            if(PIGZ)
+                set(GZIP ${PIGZ})
+            else()
+                find_package(UnixCommands)
+            endif()
+            if(GZIP)
+                set(MAN_EXT ".gz")
+                add_custom_target(man_gz ALL
+                        ${GZIP} -kf ${SPHINX_MAN_DIR}/*.{1,3}
+                        DEPENDS man
+                        )
+            endif()
         endif()
+
+        install(DIRECTORY ${SPHINX_MAN_DIR}/
+                DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
+                FILES_MATCHING PATTERN *.1${MAN_EXT}
+                )
+        install(DIRECTORY ${SPHINX_MAN_DIR}/
+                DESTINATION ${CMAKE_INSTALL_MANDIR}/man3
+                FILES_MATCHING PATTERN *.3${MAN_EXT}
+                )
     endif()
 
-    install(DIRECTORY ${SPHINX_MAN_DIR}/
-            DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
-            FILES_MATCHING PATTERN *.1${MAN_EXT}
-            )
-    install(DIRECTORY ${SPHINX_MAN_DIR}/
-            DESTINATION ${CMAKE_INSTALL_MANDIR}/man3
-            FILES_MATCHING PATTERN *.3${MAN_EXT}
-            )
 endif()