mirror of
https://github.com/triqs/dft_tools
synced 2024-12-31 16:45:49 +01:00
[cmake] Add PROJECT_NAME prefix to targets in doc dir to avoid naming conflicts
This commit is contained in:
parent
9b76ce9c4c
commit
6e4598ce07
@ -4,13 +4,13 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_BINARY_DIR
|
||||
# -----------------------------------------------------------------------------
|
||||
# Create an optional target that allows us to regenerate the C++ doc with c++2rst
|
||||
# -----------------------------------------------------------------------------
|
||||
add_custom_target(docs_cpp2rst)
|
||||
add_custom_target(${PROJECT_NAME}_docs_cpp2rst)
|
||||
include(${PROJECT_SOURCE_DIR}/share/cmake/extract_flags.cmake)
|
||||
extract_flags(app4triqs_c)
|
||||
separate_arguments(app4triqs_c_CXXFLAGS)
|
||||
macro(generate_docs header_file)
|
||||
add_custom_command(
|
||||
TARGET docs_cpp2rst
|
||||
TARGET ${PROJECT_NAME}_docs_cpp2rst
|
||||
COMMAND rm -rf ${CMAKE_CURRENT_SOURCE_DIR}/cpp2rst_generated
|
||||
COMMAND
|
||||
c++2rst
|
||||
@ -28,30 +28,32 @@ generate_docs(${PROJECT_SOURCE_DIR}/c++/app4triqs/app4triqs.hpp)
|
||||
# Build & Run the C++ doc examples and capture the output
|
||||
# --------------------------------------------------------
|
||||
|
||||
add_custom_target(docs_example_output)
|
||||
add_custom_target(${PROJECT_NAME}_docs_example_output)
|
||||
file(GLOB_RECURSE ExampleList RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
foreach(example ${ExampleList})
|
||||
get_filename_component(f ${example} NAME_WE)
|
||||
get_filename_component(d ${example} DIRECTORY)
|
||||
add_executable(doc_${f} EXCLUDE_FROM_ALL ${example})
|
||||
set_property(TARGET doc_${f} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${d})
|
||||
target_link_libraries(doc_${f} triqs)
|
||||
add_custom_command(TARGET doc_${f}
|
||||
COMMAND doc_${f} > ${CMAKE_CURRENT_SOURCE_DIR}/${d}/${f}.output 2>/dev/null
|
||||
add_executable(${PROJECT_NAME}_doc_${f} EXCLUDE_FROM_ALL ${example})
|
||||
set_property(TARGET ${PROJECT_NAME}_doc_${f} PROPERTY RUNTIME_OUTPUT_DIRECTORY ${d})
|
||||
target_link_libraries(${PROJECT_NAME}_doc_${f} triqs)
|
||||
add_custom_command(TARGET ${PROJECT_NAME}_doc_${f}
|
||||
COMMAND ${PROJECT_NAME}_doc_${f} > ${CMAKE_CURRENT_SOURCE_DIR}/${d}/${f}.output 2>/dev/null
|
||||
WORKING_DIRECTORY ${d}
|
||||
)
|
||||
add_dependencies(docs_example_output doc_${f})
|
||||
add_dependencies(${PROJECT_NAME}_docs_example_output ${PROJECT_NAME}_doc_${f})
|
||||
endforeach()
|
||||
|
||||
# ---------------------------------
|
||||
# Top Sphinx target
|
||||
# ---------------------------------
|
||||
find_package(Sphinx)
|
||||
if(NOT DEFINED SPHINXBUILD_EXECUTABLE)
|
||||
find_package(Sphinx)
|
||||
endif()
|
||||
|
||||
# Sphinx has internal caching, always run it
|
||||
add_custom_target(docs_sphinx ALL)
|
||||
add_custom_target(${PROJECT_NAME}_docs_sphinx ALL)
|
||||
add_custom_command(
|
||||
TARGET docs_sphinx
|
||||
TARGET ${PROJECT_NAME}_docs_sphinx
|
||||
COMMAND PYTHONPATH=${PROJECT_BINARY_DIR}/python:$ENV{PYTHONPATH} ${SPHINXBUILD_EXECUTABLE} -c . -j8 -b html ${CMAKE_CURRENT_SOURCE_DIR} html
|
||||
)
|
||||
|
||||
@ -60,11 +62,11 @@ if(NOT Sphinx_Only)
|
||||
# Autodoc usage requires the python modules to be built first
|
||||
get_property(CPP2PY_MODULES_LIST GLOBAL PROPERTY CPP2PY_MODULES_LIST)
|
||||
if(CPP2PY_MODULES_LIST)
|
||||
add_dependencies(docs_sphinx ${CPP2PY_MODULES_LIST})
|
||||
add_dependencies(${PROJECT_NAME}_docs_sphinx ${CPP2PY_MODULES_LIST})
|
||||
endif()
|
||||
|
||||
# Generation of C++ Api and Example Outputs
|
||||
add_dependencies(docs_sphinx docs_cpp2rst docs_example_output)
|
||||
add_dependencies(${PROJECT_NAME}_docs_sphinx ${PROJECT_NAME}_docs_cpp2rst ${PROJECT_NAME}_docs_example_output)
|
||||
endif()
|
||||
|
||||
# ---------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user