Browse Source

Add option to turn off the build of the documentation if Doxygen was found

Arthur Brianville (Ybalrid) 6 years ago
parent
commit
23690f316d
1 changed files with 27 additions and 21 deletions
  1. 27 21
      CMakeLists.txt

+ 27 - 21
CMakeLists.txt

@@ -229,28 +229,33 @@ install(EXPORT PhysFSExport
 )
 )
 
 
 
 
-find_package(Doxygen)
-if(DOXYGEN_FOUND)
-    set(PHYSFS_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
-    configure_file(
-        "${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile"
-        "${PHYSFS_OUTPUT_DOXYFILE}"
-        COPYONLY
-    )
-    file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n\n# Below auto-generated by cmake...\n\n")
-    file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "PROJECT_NUMBER = \"${PHYSFS_VERSION}\"\n")
-    file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "OUTPUT_DIRECTORY = \"${CMAKE_CURRENT_BINARY_DIR}/docs\"\n")
-    file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n# End auto-generated section.\n\n")
+option(PHYSFS_BUILD_DOCS "Build doxygen based documentation" TRUE)
+if(PHYSFS_BUILD_DOCS)
+    find_package(Doxygen)
+    if(DOXYGEN_FOUND)
+        set(PHYSFS_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
+        configure_file(
+            "${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile"
+            "${PHYSFS_OUTPUT_DOXYFILE}"
+            COPYONLY
+        )
+        file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n\n# Below auto-generated by cmake...\n\n")
+        file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "PROJECT_NUMBER = \"${PHYSFS_VERSION}\"\n")
+        file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "OUTPUT_DIRECTORY = \"${CMAKE_CURRENT_BINARY_DIR}/docs\"\n")
+        file(APPEND "${PHYSFS_OUTPUT_DOXYFILE}" "\n# End auto-generated section.\n\n")
+
+        set(PHYSFS_TARGETNAME_DOCS "docs" CACHE STRING "Name of 'docs' build target")
+
+        add_custom_target(
+            ${PHYSFS_TARGETNAME_DOCS}
+            ${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}"
+            WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+            COMMENT "Building documentation in 'docs' directory..."
+        )
 
 
-    set(PHYSFS_TARGETNAME_DOCS "docs" CACHE STRING "Name of 'docs' build target")
-    add_custom_target(
-        ${PHYSFS_TARGETNAME_DOCS}
-        ${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}"
-        WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
-        COMMENT "Building documentation in 'docs' directory..."
-    )
-else()
-    message(STATUS "Doxygen not found. You won't be able to build documentation.")
+    else()
+        message(STATUS "Doxygen not found. You won't be able to build documentation.")
+    endif()
 endif()
 endif()
 
 
 if(UNIX)
 if(UNIX)
@@ -307,6 +312,7 @@ message_bool_option("ISO9660 support" PHYSFS_ARCHIVE_ISO9660)
 message_bool_option("Build static library" PHYSFS_BUILD_STATIC)
 message_bool_option("Build static library" PHYSFS_BUILD_STATIC)
 message_bool_option("Build shared library" PHYSFS_BUILD_SHARED)
 message_bool_option("Build shared library" PHYSFS_BUILD_SHARED)
 message_bool_option("Build stdio test program" PHYSFS_BUILD_TEST)
 message_bool_option("Build stdio test program" PHYSFS_BUILD_TEST)
+message_bool_option("Build Doxygen documentation" PHYSFS_BUILD_DOCS)
 if(PHYSFS_BUILD_TEST)
 if(PHYSFS_BUILD_TEST)
     message_bool_option("  Use readline in test program" HAVE_SYSTEM_READLINE)
     message_bool_option("  Use readline in test program" HAVE_SYSTEM_READLINE)
 endif()
 endif()