1set(EXE_NAME curl)
2
3if(USE_MANUAL)
4  # Use the C locale to ensure that only ASCII characters appear in the
5  # embedded text. NROFF and MANOPT are set in the parent CMakeLists.txt
6  add_custom_command(
7    OUTPUT tool_hugehelp.c
8    COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_setup.h\"" > tool_hugehelp.c
9    COMMAND ${CMAKE_COMMAND} -E echo "#ifndef HAVE_LIBZ" >> tool_hugehelp.c
10    COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
11            "${CURL_BINARY_DIR}/docs/curl.1" |
12            "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" >> tool_hugehelp.c
13    COMMAND ${CMAKE_COMMAND} -E echo "#else" >> tool_hugehelp.c
14    COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
15            "${CURL_BINARY_DIR}/docs/curl.1" |
16            "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c >> tool_hugehelp.c
17    COMMAND ${CMAKE_COMMAND} -E echo "#endif /* HAVE_LIBZ */" >> tool_hugehelp.c
18    DEPENDS
19      generate-curl.1
20      "${CURL_BINARY_DIR}/docs/curl.1"
21      "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
22      "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
23    VERBATIM)
24else()
25  add_custom_command(
26    OUTPUT tool_hugehelp.c
27    COMMAND ${CMAKE_COMMAND} -E echo "/* built-in manual is disabled, blank function */" > tool_hugehelp.c
28    COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_hugehelp.h\"" >> tool_hugehelp.c
29    COMMAND ${CMAKE_COMMAND} -E echo "void hugehelp(void) {}" >> tool_hugehelp.c
30    DEPENDS
31      "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
32    VERBATIM)
33
34endif()
35
36transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
37include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
38
39if(MSVC)
40  list(APPEND CURL_FILES curl.rc)
41endif()
42
43# CURL_FILES comes from Makefile.inc
44add_executable(
45  ${EXE_NAME}
46  ${CURL_FILES}
47  )
48
49source_group("curlX source files" FILES ${CURLX_CFILES})
50source_group("curl source files" FILES ${CURL_CFILES})
51source_group("curl header files" FILES ${CURL_HFILES})
52
53include_directories(
54  ${CURL_SOURCE_DIR}/lib        # To be able to reach "curl_setup_once.h"
55  ${CURL_BINARY_DIR}/lib        # To be able to reach "curl_config.h"
56  ${CURL_BINARY_DIR}/include    # To be able to reach "curl/curl.h"
57  # This is needed as tool_hugehelp.c is generated in the binary dir
58  ${CURL_SOURCE_DIR}/src        # To be able to reach "tool_hugehelp.h"
59  )
60
61#Build curl executable
62target_link_libraries(${EXE_NAME} libcurl ${CURL_LIBS})
63
64################################################################################
65
66#SET_TARGET_PROPERTIES(${EXE_NAME} ARCHIVE_OUTPUT_DIRECTORY "blah blah blah")
67#SET_TARGET_PROPERTIES(${EXE_NAME} RUNTIME_OUTPUT_DIRECTORY "blah blah blah")
68#SET_TARGET_PROPERTIES(${EXE_NAME} LIBRARY_OUTPUT_DIRECTORY "blah blah blah")
69
70#INCLUDE(ModuleInstall OPTIONAL)
71
72install(TARGETS ${EXE_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
73export(TARGETS ${EXE_NAME}
74       APPEND FILE ${PROJECT_BINARY_DIR}/curl-target.cmake
75       NAMESPACE CURL::
76)
77