diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e08345..f755820 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,27 +353,32 @@ install(FILES src/SDL_sound.h install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SDL2_sound.pc DESTINATION "${PKGCONFIG_INSTALLDIR}") -find_package(Doxygen) -if(DOXYGEN_FOUND) - set(SDLSOUND_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile") - configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile" - "${SDLSOUND_OUTPUT_DOXYFILE}" - COPYONLY - ) - file(APPEND "${SDLSOUND_OUTPUT_DOXYFILE}" "\n\n# Below auto-generated by cmake...\n\n") - file(APPEND "${SDLSOUND_OUTPUT_DOXYFILE}" "PROJECT_NUMBER = \"${SDLSOUND_VERSION}\"\n") - file(APPEND "${SDLSOUND_OUTPUT_DOXYFILE}" "OUTPUT_DIRECTORY = \"${CMAKE_CURRENT_BINARY_DIR}/docs\"\n") - file(APPEND "${SDLSOUND_OUTPUT_DOXYFILE}" "\n# End auto-generated section.\n\n") - - add_custom_target( - SDL2_sound-docs - ${DOXYGEN_EXECUTABLE} "${SDLSOUND_OUTPUT_DOXYFILE}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - COMMENT "Building documentation..." - ) -else() - message(STATUS "Doxygen not found. You won't be able to build documentation.") +option(SDLSOUND_BUILD_DOCS "Build documentation" TRUE) +mark_as_advanced(SDLSOUND_BUILD_DOCS) + +if(SDLSOUND_BUILD_DOCS) + find_package(Doxygen) + if(DOXYGEN_FOUND) + set(SDLSOUND_OUTPUT_DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile") + configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile" + "${SDLSOUND_OUTPUT_DOXYFILE}" + COPYONLY + ) + file(APPEND "${SDLSOUND_OUTPUT_DOXYFILE}" "\n\n# Below auto-generated by cmake...\n\n") + file(APPEND "${SDLSOUND_OUTPUT_DOXYFILE}" "PROJECT_NUMBER = \"${SDLSOUND_VERSION}\"\n") + file(APPEND "${SDLSOUND_OUTPUT_DOXYFILE}" "OUTPUT_DIRECTORY = \"${CMAKE_CURRENT_BINARY_DIR}/docs\"\n") + file(APPEND "${SDLSOUND_OUTPUT_DOXYFILE}" "\n# End auto-generated section.\n\n") + + add_custom_target( + SDL2_sound-docs + ${DOXYGEN_EXECUTABLE} "${SDLSOUND_OUTPUT_DOXYFILE}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMENT "Building documentation..." + ) + else() + message(STATUS "Doxygen not found. You won't be able to build documentation.") + endif() endif() configure_file( @@ -412,6 +417,7 @@ message_bool_option("COREAUDIO support" SDLSOUND_DECODER_COREAUDIO) message_bool_option("Build static library" SDLSOUND_BUILD_STATIC) message_bool_option("Build shared library" SDLSOUND_BUILD_SHARED) message_bool_option("Build stdio test program" SDLSOUND_BUILD_TEST) +message_bool_option("Build documentation" SDLSOUND_BUILD_DOCS) # Make sure SDL2_sound::SDL2_sound always exists if(TARGET SDL2_sound::SDL2_sound-static AND NOT TARGET SDL2_sound::SDL2_sound)