Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: move physfs.h to include folder + doxygen fix #76

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 28 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -275,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()
Expand Down