From 38e97670306685d5f518db1c0797f3d490301edc Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 23 Feb 2024 08:05:33 +0100 Subject: [PATCH 1/2] cmake: disable documentation and installation targets when adding PhysicsFS as a subproject --- CMakeLists.txt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59910dbc..a8940cab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,14 @@ cmake_minimum_required(VERSION 3.5) project(PhysicsFS VERSION ${PHYSFS_VERSION} LANGUAGES C ) +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + set(PHYSFS_SUBPROJECT OFF) + set(PHYSFS_ROOTPROJECT ON) +else() + set(PHYSFS_SUBPROJECT ON) + set(PHYSFS_ROOTPROJECT OFF) +endif() + include(GNUInstallDirs) # Increment this if/when we break backwards compatibility. @@ -232,7 +240,7 @@ if(PHYSFS_BUILD_TEST) list(APPEND PHYSFS_INSTALL_TARGETS test_physfs) endif() -option(PHYSFS_DISABLE_INSTALL "Disable installing PhysFS" OFF) +option(PHYSFS_DISABLE_INSTALL "Disable installing PhysFS" "${PHYSFS_SUBPROJECT}") if(NOT PHYSFS_DISABLE_INSTALL) install(TARGETS ${PHYSFS_INSTALL_TARGETS} EXPORT PhysFSExport @@ -262,7 +270,7 @@ if(NOT PHYSFS_DISABLE_INSTALL) endif() endif() -option(PHYSFS_BUILD_DOCS "Build doxygen based documentation" TRUE) +option(PHYSFS_BUILD_DOCS "Build doxygen based documentation" ${PHYSFS_ROOTPROJECT}) if(PHYSFS_BUILD_DOCS) find_package(Doxygen) if(DOXYGEN_FOUND) From 5772a006e9ccfd73d72991936f5a2f0946c6522f Mon Sep 17 00:00:00 2001 From: Anonymous Maarten Date: Fri, 23 Feb 2024 08:06:48 +0100 Subject: [PATCH 2/2] cmake: fix Doxygen documentation generation + install html & man pages --- CMakeLists.txt | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a8940cab..5d2d630d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -283,17 +283,31 @@ if(PHYSFS_BUILD_DOCS) 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}" "INPUT = \"${CMAKE_CURRENT_SOURCE_DIR}/src/physfs.h\"\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}" + add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/docs/html/index.html" + COMMAND ${DOXYGEN_EXECUTABLE} "${PHYSFS_OUTPUT_DOXYFILE}" COMMENT "Building documentation in 'docs' directory..." + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/physfs.h" "${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile" ) + add_custom_target(${PHYSFS_TARGETNAME_DOCS} ALL + DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/docs/html/index.html" + ) + + if(NOT PHYSFS_DISABLE_INSTALL) + install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/docs/html" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/physfs" + ) + install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/docs/man" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}" + ) + endif() + else() message(STATUS "Doxygen not found. You won't be able to build documentation.") endif()