summaryrefslogtreecommitdiff
path: root/CMake
diff options
context:
space:
mode:
authorSergei Nikulov <sergey.nikulov@gmail.com>2017-09-26 10:42:12 +0300
committerJay Satiro <raysatiro@yahoo.com>2017-10-02 01:32:36 -0400
commit440dbcb06e8dedba1551e32046a9415adb82eb0b (patch)
treec29d9b86deb816e80ace3654482edafd9513d51f /CMake
parent753a5da906f2ce21d82c4e6210697b9110c151a9 (diff)
downloadcurl-440dbcb06e8dedba1551e32046a9415adb82eb0b.tar.gz
cmake: disable tests and man generation if perl/nroff not found
Fixes https://github.com/curl/curl/issues/1500 Reported-by: Jay Satiro Fixes https://github.com/curl/curl/pull/1662 Assisted-by: Tom Seddon Assisted-by: dpull@users.noreply.github.com Assisted-by: elelel@users.noreply.github.com Closes https://github.com/curl/curl/pull/1924
Diffstat (limited to 'CMake')
-rw-r--r--CMake/Macros.cmake29
1 files changed, 29 insertions, 0 deletions
diff --git a/CMake/Macros.cmake b/CMake/Macros.cmake
index dab005f73..82aadca9d 100644
--- a/CMake/Macros.cmake
+++ b/CMake/Macros.cmake
@@ -93,3 +93,32 @@ macro(CURL_INTERNAL_TEST_RUN CURL_TEST)
endif(${CURL_TEST}_COMPILE AND NOT ${CURL_TEST})
endif()
endmacro(CURL_INTERNAL_TEST_RUN)
+
+macro(CURL_NROFF_CHECK)
+ find_program(NROFF NAMES gnroff nroff)
+ if(NROFF)
+ # Need a way to write to stdin, this will do
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt" "test")
+ # Tests for a valid nroff option to generate a manpage
+ foreach(_MANOPT "-man" "-mandoc")
+ execute_process(COMMAND "${NROFF}" ${_MANOPT}
+ OUTPUT_VARIABLE NROFF_MANOPT_OUTPUT
+ INPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt"
+ ERROR_QUIET)
+ # Save the option if it was valid
+ if(NROFF_MANOPT_OUTPUT)
+ message("Found *nroff option: -- ${_MANOPT}")
+ set(NROFF_MANOPT ${_MANOPT})
+ set(NROFF_USEFUL ON)
+ break()
+ endif()
+ endforeach()
+ # No need for the temporary file
+ file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt")
+ if(NOT NROFF_USEFUL)
+ message(WARNING "Found no *nroff option to get plaintext from man pages")
+ endif()
+ else()
+ message(WARNING "Found no *nroff program")
+ endif()
+endmacro(CURL_NROFF_CHECK)