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#
24# Headers which need to be checked for abi/api compatibility are in
25# API_PREPROCESSOR_HEADER. plugin.h is tested implicitly via
26# plugin_audit.h and plugin_ftparser.h.
27#
28# We use gcc specific preprocessing command and sed/diff, so it will
29# only be run  on Unix and only if gcc is used. On some Unixes,
30# (Solaris) sed or diff might act differently from GNU, so we run only
31# on systems we can trust.
32IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux")
33 SET(RUN_ABI_CHECK 1)
34ELSE()
35 SET(RUN_ABI_CHECK 0)
36ENDIF()
37
38IF(CMAKE_COMPILER_IS_GNUCC AND RUN_ABI_CHECK)
39  IF(CMAKE_C_COMPILER MATCHES "ccache$")
40    SET(COMPILER ${CMAKE_C_COMPILER_ARG1})
41    STRING(REGEX REPLACE "^ " "" COMPILER ${COMPILER})
42  ELSE()
43    SET(COMPILER ${CMAKE_C_COMPILER})
44  ENDIF()
45  SET(API_PREPROCESSOR_HEADER
46    ${CMAKE_SOURCE_DIR}/include/mysql/plugin_audit.h
47    ${CMAKE_SOURCE_DIR}/include/mysql/plugin_ftparser.h
48    ${CMAKE_SOURCE_DIR}/include/mysql.h
49    ${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_v0.h
50    ${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_v1.h
51    ${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_v2.h
52    ${CMAKE_SOURCE_DIR}/include/mysql/client_plugin.h
53    ${CMAKE_SOURCE_DIR}/include/mysql/plugin_auth.h
54    ${CMAKE_SOURCE_DIR}/include/mysql/services.h
55    ${CMAKE_SOURCE_DIR}/include/mysql/plugin_keyring.h
56  )
57
58  ADD_CUSTOM_TARGET(abi_check ALL
59  COMMAND ${CMAKE_COMMAND}
60    -DCOMPILER=${COMPILER}
61    -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
62    -DBINARY_DIR=${CMAKE_BINARY_DIR}
63    "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
64    -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
65    VERBATIM
66  )
67
68  ADD_CUSTOM_TARGET(abi_check_all
69  COMMAND ${CMAKE_COMMAND}
70    -DCOMPILER=${COMPILER}
71    -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
72    -DBINARY_DIR=${CMAKE_BINARY_DIR}
73    "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
74    -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
75    VERBATIM
76  )
77ENDIF()
78
79