1# Copyright (c) 2009, 2021, Oracle and/or its affiliates.
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License, version 2.0,
5# as published by the Free Software Foundation.
6#
7# This program is also distributed with certain software (including
8# but not limited to OpenSSL) that is licensed under separate terms,
9# as designated in a particular file or component or in included license
10# documentation.  The authors of MySQL hereby grant you an additional
11# permission to link the program and your derivative works with the
12# separately licensed software that they have included with MySQL.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License, version 2.0, for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22
23# Add executable plus some additional MySQL specific stuff
24# Usage (same as for standard CMake's ADD_EXECUTABLE)
25#
26# MYSQL_ADD_EXECUTABLE(target source1...sourceN)
27# MySQL specifics:
28# - instruct CPack to install executable under
29#   ${CMAKE_INSTALL_PREFIX}/bin directory
30# On Windows :
31# - add version resource
32
33INCLUDE(cmake_parse_arguments)
34
35FUNCTION (MYSQL_ADD_EXECUTABLE)
36  # Pass-through arguments for ADD_EXECUTABLE
37  MYSQL_PARSE_ARGUMENTS(ARG
38   "WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL;DESTINATION;COMPONENT"
39   ""
40   ${ARGN}
41  )
42  LIST(GET ARG_DEFAULT_ARGS 0 target)
43  LIST(REMOVE_AT  ARG_DEFAULT_ARGS 0)
44
45  SET(sources ${ARG_DEFAULT_ARGS})
46  ADD_VERSION_INFO(${target} EXECUTABLE sources)
47  ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources})
48  # tell CPack where to install
49  IF(NOT ARG_EXCLUDE_FROM_ALL)
50    IF(NOT ARG_DESTINATION)
51      SET(ARG_DESTINATION ${INSTALL_BINDIR})
52    ENDIF()
53    IF(ARG_COMPONENT)
54      SET(COMP COMPONENT ${ARG_COMPONENT})
55    ELSEIF(MYSQL_INSTALL_COMPONENT)
56      SET(COMP COMPONENT ${MYSQL_INSTALL_COMPONENT})
57    ELSE()
58      SET(COMP COMPONENT Client)
59    ENDIF()
60    MYSQL_INSTALL_TARGETS(${target} DESTINATION ${ARG_DESTINATION} ${COMP})
61  ENDIF()
62ENDFUNCTION()
63