1# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
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  )
55
56  ADD_CUSTOM_TARGET(abi_check ALL
57  COMMAND ${CMAKE_COMMAND}
58    -DCOMPILER=${COMPILER}
59    -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
60    -DBINARY_DIR=${CMAKE_BINARY_DIR}
61    "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
62    -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
63    VERBATIM
64  )
65
66  ADD_CUSTOM_TARGET(abi_check_all
67  COMMAND ${CMAKE_COMMAND}
68    -DCOMPILER=${COMPILER}
69    -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
70    -DBINARY_DIR=${CMAKE_BINARY_DIR}
71    "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
72    -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
73    VERBATIM
74  )
75ENDIF()
76
77