-SET(EXE_NAME curl)
-
-# First try to locate 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 hugehelp.c PATHS . NO_DEFAULT_PATH)
-IF (NOT HUGEHELP_C_FILE)
- MESSAGE(STATUS "Warning: hugehelp.c file was not generated before. Generating an 'empty' file...")
- FILE(WRITE hugehelp.c "/* built-in manual is disabled, blank function */\n#include \"hugehelp.h\"\nvoid hugehelp(void) {}")
-ENDIF()
-
-SET(CURLX_SOURCE
- ${CURL_SOURCE_DIR}/lib/strtoofft.c
- ${CURL_SOURCE_DIR}/lib/strdup.c
- ${CURL_SOURCE_DIR}/lib/rawstr.c
-)
-
-SET(CURL_SOURCE
- main.c hugehelp.c urlglob.c writeout.c writeenv.c
- getpass.c homedir.c curlutil.c
-)
-
-SET(CURL_HEADERS
- hugehelp.h setup.h config-win32.h config-mac.h
- config-riscos.h urlglob.h version.h
- writeout.h writeenv.h getpass.h homedir.h curlutil.h
-)
-
-IF(MSVC)
- LIST(APPEND CURL_SOURCE curl.rc)
-ENDIF()
-
-ADD_EXECUTABLE(
- ${EXE_NAME}
- ${CURL_HEADERS}
- ${CURL_SOURCE} ${CURLX_SOURCE}
-)
-
-SOURCE_GROUP("cURLX source files" FILES ${CURLX_SOURCE})
-SOURCE_GROUP("cURL source files" FILES ${CURL_SOURCE})
-SOURCE_GROUP("cURL header files" FILES ${CURL_HEADERS})
-
-INCLUDE_DIRECTORIES(
- ${CURL_SOURCE_DIR}/lib # To be able to reach "setup_once.h"
- ${CURL_BINARY_DIR}/lib # To be able to reach "config.h"
- ${CURL_BINARY_DIR}/include # To be able to reach "curl/curlbuild.h"
-)
-
-
-# Setup dependencies
-
-IF(CURL_ZLIB AND ZLIB_FOUND)
- TARGET_LINK_LIBRARIES(${EXE_NAME} ${ZLIB_LIBRARIES})
- #ADD_DEFINITIONS( -DHAVE_ZLIB_H -DHAVE_ZLIB -DHAVE_LIBZ )
-ENDIF()
-# IF(CURL_SSL AND CURL_CONFIG_HAS_BEEN_RUN_BEFORE)
- # TARGET_LINK_LIBRARIES(${EXE_NAME} ${OPENSSL_LIBRARIES})
- # ADD_DEFINITIONS( -DUSE_SSLEAY )
-# ENDIF()
-TARGET_LINK_LIBRARIES( ${EXE_NAME} libcurl )
-
+set(EXE_NAME curl)
+
+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")
+include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
+
+if(MSVC)
+ list(APPEND CURL_SOURCE curl.rc)
+endif()
+
+add_executable(
+ ${EXE_NAME}
+ ${curl_SOURCES}
+ )
+
+source_group("cURLX source files" FILES ${CURLX_CFILES})
+source_group("cURL source files" FILES ${CURL_CFILES})
+source_group("cURL header files" FILES ${CURL_HFILES})
+
+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
+target_link_libraries( ${EXE_NAME} libcurl ${CURL_LIBS})
################################################################################
#SET_TARGET_PROPERTIES(${EXE_NAME} LIBRARY_OUTPUT_DIRECTORY "blah blah blah")
# Add the postfix to the executable since it is not added automatically as for modules and shared libraries
-SET_TARGET_PROPERTIES(${EXE_NAME} PROPERTIES DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
-
-IF(MSVC)
- IF(NOT BUILD_RELEASE_DEBUG_DIRS)
- # Ugly workaround to remove the "/debug" or "/release" in each output
- SET_TARGET_PROPERTIES(${EXE_NAME} PROPERTIES PREFIX "../")
- ENDIF()
-ENDIF()
+set_target_properties(${EXE_NAME} PROPERTIES
+ DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
#INCLUDE(ModuleInstall OPTIONAL)
+
+install(TARGETS ${EXE_NAME} DESTINATION bin)