Make doxygen optional.

pull/1/head
Joshua Potter 2024-01-06 11:06:19 -07:00
parent a65bb5255e
commit bf7a1668b2
4 changed files with 45 additions and 37 deletions

View File

@ -1,24 +1,28 @@
find_package(Doxygen REQUIRED)
find_package(Doxygen)
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/include)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
if(DOXYGEN_FOUND)
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/include)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
add_custom_command(OUTPUT
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
add_custom_command(OUTPUT
${DOXYGEN_INDEX_FILE}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating Doxygen documentation"
VERBATIM
)
)
add_custom_target(docs DEPENDS ${DOXYGEN_INDEX_FILE})
add_custom_target(docs DEPENDS ${DOXYGEN_INDEX_FILE})
# Ensure worker is built before documentation.
add_dependencies(docs bootstrap)
# Ensure worker is built before documentation.
add_dependencies(docs bootstrap)
endif()

View File

@ -24,7 +24,7 @@
pname = "bootstrap";
src = ./.;
version = "0.1.3";
nativeBuildInputs = with pkgs; [ cmake ];
nativeBuildInputs = with pkgs; [ cmake doxygen ];
installPhase = ''
mkdir -p $out/bin
cp ./bootstrap $out/bin

View File

@ -56,7 +56,7 @@ mkdir -p "$BUILD"/build/{Debug,Release}
# REWRITES
# ============================================================
for file in flake.nix {,src/,test/}CMakeLists.txt
for file in flake.nix {,src/,docs/,test/}CMakeLists.txt
do
sed -i "s/<NAME>/$NAME/g" "$BUILD/$file"
done

View File

@ -1,24 +1,28 @@
find_package(Doxygen REQUIRED)
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/include)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
if(DOXYGEN_FOUND)
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
set(DOXYGEN_INPUT_DIR ${PROJECT_SOURCE_DIR}/include)
set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/doxygen)
set(DOXYGEN_INDEX_FILE ${DOXYGEN_OUTPUT_DIR}/xml/index.xml)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
add_custom_command(OUTPUT
file(MAKE_DIRECTORY ${DOXYGEN_OUTPUT_DIR})
add_custom_command(OUTPUT
${DOXYGEN_INDEX_FILE}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating Doxygen documentation"
VERBATIM
)
)
add_custom_target(docs DEPENDS ${DOXYGEN_INDEX_FILE})
add_custom_target(docs DEPENDS ${DOXYGEN_INDEX_FILE})
# Ensure worker is built before documentation.
add_dependencies(docs bootstrap)
# Ensure executable is built before documentation.
add_dependencies(docs "<NAME>")
endif()