Imported Upstream version 7.40.0
[platform/upstream/curl.git] / src / CMakeLists.txt
1 set(EXE_NAME curl)
2
3 if(USE_MANUAL)
4   find_package(Perl REQUIRED)
5   # Use the C locale to ensure that only ASCII characters appear in the
6   # embedded text. NROFF and MANOPT are set in the parent CMakeLists.txt
7   add_custom_command(
8     OUTPUT tool_hugehelp.c
9     COMMAND echo "#include \"tool_setup.h\"" > tool_hugehelp.c
10     COMMAND echo "#ifndef HAVE_LIBZ" >> tool_hugehelp.c
11     COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
12             "${CURL_SOURCE_DIR}/docs/curl.1" |
13             "${PERL}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
14             "${CURL_SOURCE_DIR}/docs/MANUAL" >> tool_hugehelp.c
15     COMMAND echo "#else" >> tool_hugehelp.c
16     COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
17             "${CURL_SOURCE_DIR}/docs/curl.1" |
18             "${PERL}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c
19             "${CURL_SOURCE_DIR}/docs/MANUAL" >> tool_hugehelp.c
20     COMMAND echo "#endif /* HAVE_LIBZ */" >> tool_hugehelp.c
21     DEPENDS
22       "${CURL_SOURCE_DIR}/docs/MANUAL"
23       "${CURL_SOURCE_DIR}/docs/curl.1"
24       "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
25       "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
26     VERBATIM)
27 else()
28   add_custom_command(
29     OUTPUT tool_hugehelp.c
30     COMMAND echo "/* built-in manual is disabled, blank function */" > tool_hugehelp.c
31     COMMAND echo "#include \"tool_hugehelp.h\"" >> tool_hugehelp.c
32     COMMAND echo "void hugehelp(void) {}" >> tool_hugehelp.c
33     DEPENDS
34       "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
35     VERBATIM)
36 endif()
37
38 transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
39 include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
40
41 if(MSVC)
42   list(APPEND CURL_SOURCE curl.rc)
43 endif()
44
45 add_executable(
46   ${EXE_NAME}
47   ${curl_SOURCES}
48   )
49
50 source_group("cURLX source files" FILES ${CURLX_CFILES})
51 source_group("cURL source files" FILES ${CURL_CFILES})
52 source_group("cURL header files" FILES ${CURL_HFILES})
53
54 include_directories(
55   ${CURL_SOURCE_DIR}/lib        # To be able to reach "curl_setup_once.h"
56   ${CURL_BINARY_DIR}/lib        # To be able to reach "curl_config.h"
57   ${CURL_BINARY_DIR}/include    # To be able to reach "curl/curlbuild.h"
58   # This is needed as tool_hugehelp.c is generated in the binary dir
59   ${CURL_SOURCE_DIR}/src        # To be able to reach "tool_hugehelp.h"
60   )
61
62 #Build cURL executable
63 target_link_libraries( ${EXE_NAME} libcurl ${CURL_LIBS})
64
65 ################################################################################
66
67 #SET_TARGET_PROPERTIES(${EXE_NAME} ARCHIVE_OUTPUT_DIRECTORY "blah blah blah")
68 #SET_TARGET_PROPERTIES(${EXE_NAME} RUNTIME_OUTPUT_DIRECTORY "blah blah blah")
69 #SET_TARGET_PROPERTIES(${EXE_NAME} LIBRARY_OUTPUT_DIRECTORY "blah blah blah")
70
71 # Add the postfix to the executable since it is not added automatically as for modules and shared libraries
72 set_target_properties(${EXE_NAME} PROPERTIES
73   DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
74
75 #INCLUDE(ModuleInstall OPTIONAL)
76
77 install(TARGETS ${EXE_NAME} DESTINATION bin)