diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a7e225e46..fe7212305e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,12 +71,29 @@ set(version_number_files doxygen/tfpsacrypto.doxyfile) foreach(file ${version_number_files}) configure_file(${file}.in - ${PROJECT_SOURCE_DIR}/${file}) + ${PROJECT_BINARY_DIR}/${file}) endforeach(file) ADD_CUSTOM_TARGET(${TF_PSA_CRYPTO_TARGET_PREFIX}tfpsacrypto-apidoc COMMAND doxygen tfpsacrypto.doxyfile - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doxygen) + WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/doxygen) + +# Create an in-tree symlink to the apidoc built in the binary folder. This is +# only performed on Unix platforms and for out-of-tree builds. The existence +# check is deferred to build time so that multiple out-of-tree build dirs each +# register the command, but only the first one to build actually creates the +# symlink. +if(UNIX AND NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + file(RELATIVE_PATH _apidoc_rel_path + ${CMAKE_CURRENT_SOURCE_DIR} + ${PROJECT_BINARY_DIR}/apidoc) + add_custom_command(TARGET ${TF_PSA_CRYPTO_TARGET_PREFIX}tfpsacrypto-apidoc POST_BUILD + COMMAND sh -c + "test -e '${CMAKE_CURRENT_SOURCE_DIR}/apidoc' || \ + '${CMAKE_COMMAND}' -E create_symlink \ + '${_apidoc_rel_path}' '${CMAKE_CURRENT_SOURCE_DIR}/apidoc'" + COMMENT "Creating in-tree symlink to apidoc documentation") +endif() option(ENABLE_PROGRAMS "Build TF-PSA-Crypto programs." ON) diff --git a/ChangeLog.d/doxygen-build-folder.txt b/ChangeLog.d/doxygen-build-folder.txt new file mode 100644 index 0000000000..5b03d8e60a --- /dev/null +++ b/ChangeLog.d/doxygen-build-folder.txt @@ -0,0 +1,5 @@ +Bugfix + * Doxygen documentation `apidoc` is now built into CMake's binary folder, + not in-tree. For backward compatibility on Unix platforms an in-tree + symlink named `apidoc` is created pointing to the folder in the build + directory. Fixes #381. diff --git a/README.md b/README.md index ada1e32126..576c378f7c 100644 --- a/README.md +++ b/README.md @@ -97,8 +97,8 @@ To generate a local copy of the library documentation in HTML format: 1. Run `cmake -B /path/to/build_dir /path/to/TF-PSA-Crypto/source` 1. Run `cmake --build /path/to/build_dir --target tfpsacrypto-apidoc` 1. Open one of the main generated HTML files: - * `apidoc/index.html` - * `apidoc/modules.html` or `apidoc/topics.html` + * `/path/to/build_dir/apidoc/index.html` + * `/path/to/build_dir/apidoc/modules.html` Compiling --------- diff --git a/doxygen/tfpsacrypto.doxyfile.in b/doxygen/tfpsacrypto.doxyfile.in index 9bee0d92ba..3c9605c5ad 100644 --- a/doxygen/tfpsacrypto.doxyfile.in +++ b/doxygen/tfpsacrypto.doxyfile.in @@ -6,9 +6,9 @@ EXTRACT_ALL = YES EXTRACT_PRIVATE = YES EXTRACT_STATIC = YES CASE_SENSE_NAMES = NO -INPUT = ../include input ../tests/include/alt-dummy +INPUT = "@PROJECT_SOURCE_DIR@/include" "input" "@PROJECT_SOURCE_DIR@/tests/include/alt-dummy" FILE_PATTERNS = *.h -EXCLUDE = ../include/mbedtls/private +EXCLUDE = "@PROJECT_SOURCE_DIR@/include/mbedtls/private" RECURSIVE = YES EXCLUDE_SYMLINKS = YES SOURCE_BROWSER = YES @@ -21,7 +21,7 @@ SEARCHENGINE = YES GENERATE_LATEX = NO MACRO_EXPANSION = YES EXPAND_ONLY_PREDEF = YES -INCLUDE_PATH = ../include ../drivers/builtin/include +INCLUDE_PATH = "@PROJECT_SOURCE_DIR@/include" "@PROJECT_SOURCE_DIR@/drivers/builtin/include" EXPAND_AS_DEFINED = MBEDTLS_PRIVATE CLASS_DIAGRAMS = NO HAVE_DOT = YES