Use CMake Doxygen module. #1
|
@ -7,9 +7,6 @@
|
||||||
# The directory containing all build outputs.
|
# The directory containing all build outputs.
|
||||||
/build/
|
/build/
|
||||||
|
|
||||||
# The directory generated by `Doxygen`.
|
|
||||||
/docs/
|
|
||||||
|
|
||||||
# A symlink produced by default when running `nix build`.
|
# A symlink produced by default when running `nix build`.
|
||||||
result
|
result
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,12 @@ cmake_minimum_required(VERSION 3.19)
|
||||||
project(bootstrap VERSION 0.1.3 LANGUAGES C)
|
project(bootstrap VERSION 0.1.3 LANGUAGES C)
|
||||||
|
|
||||||
add_executable(bootstrap main.c)
|
add_executable(bootstrap main.c)
|
||||||
|
|
||||||
add_subdirectory(src)
|
|
||||||
target_link_libraries(bootstrap PUBLIC m)
|
target_link_libraries(bootstrap PUBLIC m)
|
||||||
target_include_directories(bootstrap PUBLIC include)
|
target_include_directories(bootstrap PUBLIC include)
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
add_subdirectory(docs)
|
||||||
|
|
||||||
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
|
||||||
set_target_properties(
|
set_target_properties(
|
||||||
bootstrap PROPERTIES
|
bootstrap PROPERTIES
|
||||||
|
|
|
@ -251,10 +251,12 @@ $ make test
|
||||||
|
|
||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
We use [doxygen](https://www.doxygen.nl/index.html) for documentation
|
Documentation is generated using [Doxygen](https://www.doxygen.nl/index.html)
|
||||||
generation. Run the following command to generate documentation locally:
|
(version 1.9.7) through CMake. (Re)generate documentation by navigating to
|
||||||
|
the desired build configuration directory and running:
|
||||||
```bash
|
```bash
|
||||||
$ doxygen
|
$ cmake --build .
|
||||||
|
$ make docs
|
||||||
```
|
```
|
||||||
|
|
||||||
### Formatting
|
### Formatting
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
find_package(Doxygen)
|
||||||
|
|
||||||
|
if(DOXYGEN_FOUND)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
# Ensure worker is built before documentation.
|
||||||
|
add_dependencies(docs bootstrap)
|
||||||
|
|
||||||
|
endif()
|
|
@ -0,0 +1,2 @@
|
||||||
|
INPUT = "@DOXYGEN_INPUT_DIR@"
|
||||||
|
GENERATE_LATEX = NO
|
|
@ -24,7 +24,7 @@
|
||||||
pname = "bootstrap";
|
pname = "bootstrap";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
version = "0.1.3";
|
version = "0.1.3";
|
||||||
nativeBuildInputs = with pkgs; [ cmake ];
|
nativeBuildInputs = with pkgs; [ cmake doxygen ];
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp ./bootstrap $out/bin
|
cp ./bootstrap $out/bin
|
||||||
|
|
|
@ -56,7 +56,7 @@ mkdir -p "$BUILD"/build/{Debug,Release}
|
||||||
# REWRITES
|
# REWRITES
|
||||||
# ============================================================
|
# ============================================================
|
||||||
|
|
||||||
for file in flake.nix {,src/,test/}CMakeLists.txt
|
for file in flake.nix {,src/,docs/,test/}CMakeLists.txt
|
||||||
do
|
do
|
||||||
sed -i "s/<NAME>/$NAME/g" "$BUILD/$file"
|
sed -i "s/<NAME>/$NAME/g" "$BUILD/$file"
|
||||||
done
|
done
|
||||||
|
|
|
@ -7,9 +7,6 @@
|
||||||
# The directory containing all build outputs.
|
# The directory containing all build outputs.
|
||||||
/build/
|
/build/
|
||||||
|
|
||||||
# The directory generated by `Doxygen`.
|
|
||||||
/docs/
|
|
||||||
|
|
||||||
# A symlink produced by default when running `nix build`.
|
# A symlink produced by default when running `nix build`.
|
||||||
/result
|
/result
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,9 @@ add_executable("<NAME>" main.c)
|
||||||
# for linking the other project source files to our executable.
|
# for linking the other project source files to our executable.
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
|
# Use the Doxygen module to generate documentation through CMake.
|
||||||
|
add_subdirectory(docs)
|
||||||
|
|
||||||
# An example on linking additional libraries. In this case, links `math`.
|
# An example on linking additional libraries. In this case, links `math`.
|
||||||
target_link_libraries("<NAME>" PUBLIC m)
|
target_link_libraries("<NAME>" PUBLIC m)
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -41,10 +41,11 @@ exists and points to this generated database.
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Documentation is generated using [Doxygen](https://www.doxygen.nl/index.html)
|
Documentation is generated using [Doxygen](https://www.doxygen.nl/index.html)
|
||||||
(version 1.9.7). (Re)generate documentation by editing the `Doxyfile` and
|
(version 1.9.7) through CMake. (Re)generate documentation by navigating to
|
||||||
running:
|
the desired build configuration directory and running:
|
||||||
```bash
|
```bash
|
||||||
$ doxygen
|
$ cmake --build .
|
||||||
|
$ make docs
|
||||||
```
|
```
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
find_package(Doxygen REQUIRED)
|
||||||
|
|
||||||
|
if(DOXYGEN_FOUND)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY)
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
# Ensure executable is built before documentation.
|
||||||
|
add_dependencies(docs "<NAME>")
|
||||||
|
|
||||||
|
endif()
|
|
@ -0,0 +1 @@
|
||||||
|
INPUT = "@DOXYGEN_INPUT_DIR@"
|
|
@ -30,7 +30,11 @@
|
||||||
pname = "<NAME>";
|
pname = "<NAME>";
|
||||||
src = ./.;
|
src = ./.;
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
nativeBuildInputs = with pkgs; [ cmake ];
|
nativeBuildInputs = with pkgs; [
|
||||||
|
cmake
|
||||||
|
# Include if interested in building documentation.
|
||||||
|
# doxygen
|
||||||
|
];
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
cmake -DCMAKE_BUILD_TYPE=Release .
|
cmake -DCMAKE_BUILD_TYPE=Release .
|
||||||
cmake --build .
|
cmake --build .
|
||||||
|
|
Loading…
Reference in New Issue