Last active
October 20, 2022 15:38
-
-
Save BCadet/a50634a42499562eec4013108e9bd815 to your computer and use it in GitHub Desktop.
CMake snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# function to create a TARGET_NAME Doxygen target with Doxygen parameters defined in PARAM_FILE and the sources located in SOURCE_DIR | |
function(create_documentation TARGET_NAME PARAM_FILE SOURCE_DIR) | |
find_package(Doxygen REQUIRED dot) | |
include(${PARAM_FILE}) | |
doxygen_add_docs(${TARGET_NAME}-doc | |
${SOURCE_DIR} | |
) | |
if(DOXYGEN_GENERATE_LATEX AND DOXYGEN_USE_PDFLATEX) | |
add_custom_command( | |
TARGET ${TARGET_NAME}-doc | |
POST_BUILD | |
COMMAND pdflatex refman > /dev/null | |
COMMENT " Generate PDF documentation for ${TARGET_NAME}-doc" | |
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/documentation/${TARGET_NAME}/latex/ | |
) | |
endif() | |
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ------------------------------------------------------------------------# | |
# Reqflow function | |
function(reqflow_create_requirements_traceability TARGET_NAME CONF_FILE) | |
find_program(REQFLOW | |
NAMES reqflow | |
) | |
if(NOT REQFLOW) | |
message( FATAL_ERROR | |
" | |
You have called reqflow_create_requirements_traceability but reqflow is not present on your system. | |
You can install it from here: https://goeb.github.io/reqflow/ | |
" ) | |
endif() | |
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/${TARGET_NAME}) | |
add_custom_target(${TARGET_NAME}) | |
# add reqflow target with dependence to conception file parsed | |
# the command seems ugly but it's due to the fact that reqflow return a non 0 value if all requirements have not been covered | |
# this force cmake to stop. Instead, i print the output log to the console to let the user see the requirements not covered | |
add_custom_command( | |
TARGET ${TARGET_NAME} | |
COMMAND reqflow trac -c ${CONF_FILE} -x html -o Requirements_Traceability_${TARGET_NAME}.html 2>reqflow.log || cat reqflow.log | |
COMMENT "[SPEC] Create Requirements Traceability file for ${TARGET_NAME}" | |
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${TARGET_NAME} | |
USES_TERMINAL | |
DEPENDS ${CONF_FILE} | |
) | |
endfunction() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment