From 52ba9d8ebedbcb9b61337a1e7bf9a71c6f5b120d Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Thu, 8 Aug 2019 03:51:22 +0000 Subject: [PATCH] Add sphinx as doc target. --- CMakeLists.txt | 13 +++++++++++-- CMakePack.txt | 17 ++++++++--------- cmake/FindSphinx.cmake | 13 +++++++++++++ docs/CMakeLists.txt | 14 +++++++++++++- 4 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 cmake/FindSphinx.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index b130ad9..40f2ba6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ cmake_policy(SET CMP0048 NEW) project(wrmath VERSION 0.0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) # Don't warn on unused functions, because this is a library and not all # functions might be used. @@ -33,16 +34,17 @@ include_directories(include) file(GLOB_RECURSE ${PROJECT_NAME}_HEADERS include/**.h) file(GLOB_RECURSE ${PROJECT_NAME}_SOURCES src/*.cc) -message("${${PROJECT_NAME}_SOURCES} -> libwrmath") ## BUILD add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SOURCES}) + add_executable(euler2quat tools/euler2quat.cc) target_link_libraries(euler2quat ${PROJECT_NAME}) set_target_properties(euler2quat PROPERTIES FOLDER bin RUNTIME_OUTPUT_DIRECTORY bin) + add_executable(quaternion tools/quaternion.cc) target_link_libraries(quaternion ${PROJECT_NAME}) set_target_properties(quaternion PROPERTIES @@ -51,16 +53,23 @@ set_target_properties(quaternion PROPERTIES ## INSTALL +install(TARGETS ${PROJECT_NAME} DESTINATION lib) +install(TARGETS euler2quat DESTINATION bin) +install(TARGETS quaternion DESTINATION bin) install(DIRECTORY include/${PROJECT_NAME} DESTINATION include/ FILES_MATCHING PATTERN "*.h") +install(DIRECTORY docs/sphinx/_build/html/ + DESTINATION share/doc/${PROJECT_NAME} + FILES_MATCHING PATTERN "*.html") + ## TEST # From Modern CMake: # https://cliutils.gitlab.io/modern-cmake/chapters/testing/googletest.html -add_subdirectory("${PROJECT_SOURCE_DIR}/extern/googletest" "extern/googletest") +add_subdirectory("${PROJECT_SOURCE_DIR}/extern/googletest" "extern/googletest" EXCLUDE_FROM_ALL) include_directories("${gtest_SOURCE_DIR}/include") mark_as_advanced( BUILD_GMOCK BUILD_GTEST BUILD_SHARED_LIBS diff --git a/CMakePack.txt b/CMakePack.txt index 21d63d8..2736598 100644 --- a/CMakePack.txt +++ b/CMakePack.txt @@ -1,18 +1,17 @@ # build a CPack driven installer package include(InstallRequiredSystemLibraries) set(CPACK_RESOURCE_FILE_LICENSE - "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") + "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt") set(CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}") # Debian settings - set(CPACK_DEBIAN_PACKAGE_MAINTAINER "K. Isom") - set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Shimmering Clarity C++ library") - set(CPACK_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION}) - set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc++1 (>= 3.7.0-1)") -# set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA - set(CPACK_DEBIAN_PACKAGE_SECTION devel) +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "K. Isom") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The Shimmering Clarity C++ library") +set(CPACK_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION}) +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc++1 (>= 3.7.0-1)") +set(CPACK_DEBIAN_PACKAGE_SECTION devel) # actually do the thing - set(CPACK_GENERATOR DEB) - include (CPack) +set(CPACK_GENERATOR DEB) +include (CPack) diff --git a/cmake/FindSphinx.cmake b/cmake/FindSphinx.cmake new file mode 100644 index 0000000..3068215 --- /dev/null +++ b/cmake/FindSphinx.cmake @@ -0,0 +1,13 @@ +# Via https://devblogs.microsoft.com/cppblog/clear-functional-c-documentation-with-sphinx-breathe-doxygen-cmake/ + +# Look for an executable called sphinx-build +find_program(SPHINX_EXECUTABLE + NAMES sphinx-build + DOC "Path to sphinx-build executable") + +include(FindPackageHandleStandardArgs) + +# Handle standard arguments to find_package like REQUIRED and QUIET +find_package_handle_standard_args(Sphinx + "Failed to find sphinx-build executable" + SPHINX_EXECUTABLE) diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt index 8e06e53..f8c31cd 100644 --- a/docs/CMakeLists.txt +++ b/docs/CMakeLists.txt @@ -14,4 +14,16 @@ add_custom_command(OUTPUT ${DOXYGEN_INDEX_FILE} MAIN_DEPENDENCY Doxyfile COMMENT "Generating docs") -add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE}) \ No newline at end of file +add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE}) + +find_package(Sphinx REQUIRED) + +set(SPHINX_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/sphinx) +set(SPHINX_BUILD ${CMAKE_CURRENT_BINARY_DIR}/docs) + +add_custom_target(Sphinx ALL + COMMAND + ${SPHINX_EXECUTABLE} -b html + ${SPHINX_SOURCE} ${SPHINX_BUILD} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating documentation with Sphinx")