diff options
Diffstat (limited to 'src/boost/libs/hof/cmake')
-rw-r--r-- | src/boost/libs/hof/cmake/BCMTest.cmake | 92 | ||||
-rw-r--r-- | src/boost/libs/hof/cmake/SphinxDoc.cmake | 61 |
2 files changed, 153 insertions, 0 deletions
diff --git a/src/boost/libs/hof/cmake/BCMTest.cmake b/src/boost/libs/hof/cmake/BCMTest.cmake new file mode 100644 index 00000000..a7215f9c --- /dev/null +++ b/src/boost/libs/hof/cmake/BCMTest.cmake @@ -0,0 +1,92 @@ +option(BUILD_TESTING off) + +include(CMakeParseArguments) +enable_testing() + +if(NOT TARGET check) + add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR}) +endif() + +if(NOT TARGET tests) + add_custom_target(tests COMMENT "Build all tests.") + add_dependencies(check tests) +endif() + +function(bcm_mark_as_test) + foreach(TEST_TARGET ${ARGN}) + if (NOT BUILD_TESTING) + set_target_properties(${TEST_TARGET} + PROPERTIES EXCLUDE_FROM_ALL TRUE + ) + endif() + add_dependencies(tests ${TEST_TARGET}) + endforeach() +endfunction(bcm_mark_as_test) + +function(bcm_add_test) + set(options COMPILE_ONLY WILL_FAIL) + set(oneValueArgs NAME) + set(multiValueArgs SOURCES CONTENT) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + # TODO: Check if name exists + + set(SOURCES ${PARSE_SOURCES}) + if(PARSE_CONTENT) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generated-${PARSE_NAME}.cpp "${PARSE_CONTENT}") + set(SOURCES ${CMAKE_CURRENT_BINARY_DIR}/generated-${PARSE_NAME}.cpp) + endif() + + if(PARSE_COMPILE_ONLY) + if(PARSE_WILL_FAIL) + add_library(_${PARSE_NAME}_TEST_FAIL STATIC EXCLUDE_FROM_ALL ${SOURCES}) + add_custom_target(${PARSE_NAME} + COMMAND ${CMAKE_COMMAND} --build . --target _${PARSE_NAME}_TEST_FAIL --config $<CONFIGURATION> + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + add_test(NAME ${PARSE_NAME} + COMMAND ${CMAKE_COMMAND} --build . --target _${PARSE_NAME}_TEST_FAIL --config $<CONFIGURATION> + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + set_tests_properties(${PARSE_NAME} PROPERTIES WILL_FAIL TRUE) + else() + add_library(${PARSE_NAME} STATIC ${SOURCES}) + bcm_mark_as_test(${PARSE_NAME}) + endif() + else() + add_executable (${PARSE_NAME} ${SOURCES}) + bcm_mark_as_test(${PARSE_NAME}) + if(WIN32) + add_test(NAME ${PARSE_NAME} WORKING_DIRECTORY ${LIBRARY_OUTPUT_PATH} COMMAND ${PARSE_NAME}${CMAKE_EXECUTABLE_SUFFIX}) + else() + add_test(NAME ${PARSE_NAME} COMMAND ${PARSE_NAME}) + endif() + if(WILL_FAIL) + set_tests_properties(${PARSE_NAME} PROPERTIES WILL_FAIL TRUE) + endif() + endif() +endfunction(bcm_add_test) + +function(bcm_test_header) + set(options STATIC) + set(oneValueArgs NAME HEADER) + set(multiValueArgs) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(PARSE_STATIC) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/header-main-include-${PARSE_NAME}.cpp + "#include <${PARSE_HEADER}>\nint main() {}\n" + ) + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/header-static-include-${PARSE_NAME}.cpp + "#include <${PARSE_HEADER}>\n" + ) + bcm_add_test(NAME header-static-include-${PARSE_NAME} SOURCES + ${CMAKE_CURRENT_BINARY_DIR}/header-main-include-${PARSE_NAME}.cpp + ${CMAKE_CURRENT_BINARY_DIR}/header-static-include-${PARSE_NAME}.cpp + ) + else() + bcm_add_test(NAME header-include-${PARSE_NAME} CONTENT + "#include <${PARSE_HEADER}>\nint main() {}\n" + ) + endif() +endfunction(bcm_test_header) diff --git a/src/boost/libs/hof/cmake/SphinxDoc.cmake b/src/boost/libs/hof/cmake/SphinxDoc.cmake new file mode 100644 index 00000000..6cedf77b --- /dev/null +++ b/src/boost/libs/hof/cmake/SphinxDoc.cmake @@ -0,0 +1,61 @@ +include(CMakeParseArguments) +include(ProcessorCount) + +find_program(SPHINX_EXECUTABLE NAMES sphinx-build + HINTS + $ENV{SPHINX_DIR} + PATH_SUFFIXES bin + DOC "Sphinx documentation generator" +) + +mark_as_advanced(SPHINX_EXECUTABLE) + +function(clean_doc_output DIR) + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${DIR}) +endfunction() + +set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/sphinx/_build") + +# Sphinx cache with pickled ReST documents +set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/sphinx/_doctrees") + +# HTML output directory +set(SPHINX_DEFAULT_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/sphinx/html") +function(add_sphinx_doc SRC_DIR) + set(options) + set(oneValueArgs HTML_DIR) + set(multiValueArgs VARS TEMPLATE_VARS) + + cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + ProcessorCount(N) + + set(ADDITIONAL_ARGS) + foreach(VAR ${PARSE_VARS}) + list(APPEND ADDITIONAL_ARGS "-D ${VAR}") + endforeach() + foreach(VAR ${PARSE_TEMPLATE_VARS}) + list(APPEND ADDITIONAL_ARGS "-A ${VAR}") + endforeach() + + if(PARSE_HTML_DIR) + set(SPHINX_HTML_DIR ${PARSE_HTML_DIR} CACHE PATH "Path to html output") + else() + set(SPHINX_HTML_DIR ${SPHINX_DEFAULT_HTML_DIR} CACHE PATH "Path to html output") + endif() + + clean_doc_output(${SPHINX_HTML_DIR}) + clean_doc_output(${SPHINX_CACHE_DIR}) + clean_doc_output(${BINARY_BUILD_DIR}) + + add_custom_target(doc + ${SPHINX_EXECUTABLE} + -j ${N} + -n + -b html + -d "${SPHINX_CACHE_DIR}" + ${ADDITIONAL_ARGS} + "${SRC_DIR}" + "${SPHINX_HTML_DIR}" + COMMENT "Building HTML documentation with Sphinx") +endfunction() + |