• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#***************************************************************************
2#                                  _   _ ____  _
3#  Project                     ___| | | |  _ \| |
4#                             / __| | | | |_) | |
5#                            | (__| |_| |  _ <| |___
6#                             \___|\___/|_| \_\_____|
7#
8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
13#
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21# SPDX-License-Identifier: curl
22#
23###########################################################################
24set(EXE_NAME curl)
25
26if(USE_MANUAL)
27  # Use the C locale to ensure that only ASCII characters appear in the
28  # embedded text. NROFF and MANOPT are set in the parent CMakeLists.txt
29  add_custom_command(
30    OUTPUT tool_hugehelp.c
31    COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_setup.h\"" > tool_hugehelp.c
32    COMMAND ${CMAKE_COMMAND} -E echo "#ifndef HAVE_LIBZ" >> tool_hugehelp.c
33    COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
34            "${CURL_BINARY_DIR}/docs/curl.1" |
35            "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" >> tool_hugehelp.c
36    COMMAND ${CMAKE_COMMAND} -E echo "#else" >> tool_hugehelp.c
37    COMMAND env LC_ALL=C "${NROFF}" ${NROFF_MANOPT}
38            "${CURL_BINARY_DIR}/docs/curl.1" |
39            "${PERL_EXECUTABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl" -c >> tool_hugehelp.c
40    COMMAND ${CMAKE_COMMAND} -E echo "#endif /* HAVE_LIBZ */" >> tool_hugehelp.c
41    DEPENDS
42      generate-curl.1
43      "${CURL_BINARY_DIR}/docs/curl.1"
44      "${CMAKE_CURRENT_SOURCE_DIR}/mkhelp.pl"
45      "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
46    VERBATIM)
47else()
48  add_custom_command(
49    OUTPUT tool_hugehelp.c
50    COMMAND ${CMAKE_COMMAND} -E echo "#include \"tool_hugehelp.h\"" > tool_hugehelp.c
51    DEPENDS
52      "${CMAKE_CURRENT_SOURCE_DIR}/tool_hugehelp.h"
53    VERBATIM)
54
55endif()
56
57transform_makefile_inc("Makefile.inc" "${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake")
58include(${CMAKE_CURRENT_BINARY_DIR}/Makefile.inc.cmake)
59
60if(WIN32)
61  list(APPEND CURL_FILES curl.rc)
62endif()
63
64# CURL_FILES comes from Makefile.inc
65add_executable(
66  ${EXE_NAME}
67  ${CURL_FILES}
68  )
69
70add_executable(
71  ${PROJECT_NAME}::${EXE_NAME}
72  ALIAS ${EXE_NAME}
73  )
74
75if(CURL_HAS_LTO)
76  set_target_properties(${EXE_NAME} PROPERTIES
77    INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE
78    INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE)
79endif()
80
81if(ENABLE_UNICODE AND MINGW)
82  target_link_libraries(${EXE_NAME} -municode)
83endif()
84
85source_group("curlX source files" FILES ${CURLX_CFILES})
86source_group("curl source files" FILES ${CURL_CFILES})
87source_group("curl header files" FILES ${CURL_HFILES})
88
89include_directories(
90  ${CURL_SOURCE_DIR}/lib        # To be able to reach "curl_setup_once.h"
91  ${CURL_BINARY_DIR}/lib        # To be able to reach "curl_config.h"
92  ${CURL_BINARY_DIR}/include    # To be able to reach "curl/curl.h"
93  # This is needed as tool_hugehelp.c is generated in the binary dir
94  ${CURL_SOURCE_DIR}/src        # To be able to reach "tool_hugehelp.h"
95  )
96
97#Build curl executable
98target_link_libraries(${EXE_NAME} libcurl ${CURL_LIBS})
99
100################################################################################
101
102#SET_TARGET_PROPERTIES(${EXE_NAME} ARCHIVE_OUTPUT_DIRECTORY "blah blah blah")
103#SET_TARGET_PROPERTIES(${EXE_NAME} RUNTIME_OUTPUT_DIRECTORY "blah blah blah")
104#SET_TARGET_PROPERTIES(${EXE_NAME} LIBRARY_OUTPUT_DIRECTORY "blah blah blah")
105
106#INCLUDE(ModuleInstall OPTIONAL)
107
108install(TARGETS ${EXE_NAME} EXPORT ${TARGETS_EXPORT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
109export(TARGETS ${EXE_NAME}
110       FILE ${PROJECT_BINARY_DIR}/curl-target.cmake
111       NAMESPACE ${PROJECT_NAME}::
112)
113