curl-library
cmake: build tool_hugehelp (ENABLE_MANUAL)
From: Peter Wu <peter_at_lekensteyn.nl>
Date: Sun, 12 Oct 2014 11:27:07 +0200
Date: Sun, 12 Oct 2014 11:27:07 +0200
Rather than always outputting an empty manual page for the '-M' option,
generate a full manual page as done by autotools. For simplicity in
CMake, always generate the gzipped page as it will not be used anyway
when zlib is not available.
Signed-off-by: Peter Wu <peter_at_lekensteyn.nl>
--- Hi, This supersedes the previous patch which would only recreate the tool_hugehelp.c when re-running cmake. Another advantage of this patch is that a tool_hugehelp.c gets created with 'make'. I am aware that a feature freeze is in effect, how does it work with this kind of patches? Should I keep patches in a queue or is that handled by you? Kind regards, Peter --- CMakeLists.txt | 30 ++++++++++++++++++++++++++++++ docs/INSTALL.cmake | 1 - src/CMakeLists.txt | 41 +++++++++++++++++++++++++++++++++++------ 3 files changed, 65 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f8e503..13bd39e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,6 +174,36 @@ mark_as_advanced(DISABLED_THREADSAFE) option(ENABLE_IPV6 "Define if you want to enable IPv6 support" OFF) mark_as_advanced(ENABLE_IPV6) +option(ENABLE_MANUAL "to provide the built-in manual" ON) +unset(USE_MANUAL CACHE) # TODO: cache NROFF/NROFF_MANOPT/USE_MANUAL vars? +if(ENABLE_MANUAL) + 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(USE_MANUAL 1) + break() + endif() + endforeach() + # No need for the temporary file + file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/nroff-input.txt") + if(NOT USE_MANUAL) + message(WARNING "Found no *nroff option to get plaintext from man pages") + endif() + else() + message(WARNING "Found no *nroff program") + endif() +endif() # We need ansi c-flags, especially on HP set(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") diff --git a/docs/INSTALL.cmake b/docs/INSTALL.cmake index f5d32d8..dd8c936 100644 --- a/docs/INSTALL.cmake +++ b/docs/INSTALL.cmake @@ -24,7 +24,6 @@ Current flaws in the curl CMake build Missing features in the cmake build: - Builds libcurl without large file support - - It doesn't build src/tool_hugehelp.c which creates the --manual output - Can't select which SSL library to build with, only OpenSSL - Doesn't build with SCP and SFTP support (libssh2) - Doesn't allow different resolver backends (no c-ares build support) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fceaf10..9c1fd54 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,38 @@ set(EXE_NAME curl) -# First try to locate tool_hugehelp.c to see if it has already been created -# TODO Find the file WITHOUT adding a cache entry!!! Or else the user can delete the file after the script was first run, and the script won't notice it has gone. -find_file(HUGEHELP_C_FILE tool_hugehelp.c PATHS . NO_DEFAULT_PATH) -if (NOT HUGEHELP_C_FILE) - message(STATUS "Warning: tool_hugehelp.c file was not generated before. Generating an 'empty' file...") - file(WRITE tool_hugehelp.c "/* built-in manual is disabled, blank function */\n#include \"tool_hugehelp.h\"\nvoid hugehelp(void) {}\n\n") +if(USE_MANUAL) + find_package(Perl REQUIRED) + # Use the C locale to ensure that only ASCII characters appear in the + # embedded text. NROFF and MANOPT are set in the parent CMakeLists.txt + add_custom_command( + OUTPUT tool_hugehelp.c + COMMAND echo "#include \"tool_setup.h\"" > tool_hugehelp.c + COMMAND echo "#ifndef HAVE_LIBZ" >> tool_hugehelp.c + COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT} + "${CURL_SOURCE_DIR}/docs/curl.1" | + "${PERL}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" + "${CURL_SOURCE_DIR}/docs/MANUAL" >> tool_hugehelp.c + COMMAND echo "#else" >> tool_hugehelp.c + COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT} + "${CURL_SOURCE_DIR}/docs/curl.1" | + "${PERL}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c + "${CURL_SOURCE_DIR}/docs/MANUAL" >> tool_hugehelp.c + COMMAND echo "#endif /* HAVE_LIBZ */" >> tool_hugehelp.c + DEPENDS + "${CURL_SOURCE_DIR}/docs/MANUAL" + "${CURL_SOURCE_DIR}/docs/curl.1" + "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" + "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h" + VERBATIM) +else() + add_custom_command( + OUTPUT tool_hugehelp.c + COMMAND echo "/* built-in manual is disabled, blank function */" > tool_hugehelp.c + COMMAND echo "#include \"tool_hugehelp.h\"" >> tool_hugehelp.c + COMMAND echo "void hugehelp(void) {}" >> tool_hugehelp.c + DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h" + VERBATIM) endif() transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake") @@ -28,6 +55,8 @@ include_directories( ${CURL_SOURCE_DIR}/lib # To be able to reach "curl_setup_once.h" ${CURL_BINARY_DIR}/lib # To be able to reach "curl_config.h" ${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h" + # This is needed as tool_hugehelp.c is generated in the binary dir + ${CURL_SOURCE_DIR}/src # To be able to reach "tool_hugehelp.h" ) #Build cURL executable -- 2.1.1 ------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.htmlReceived on 2014-10-12