Commit 4f84d9ce authored by Sergei Golubchik's avatar Sergei Golubchik

cmake: MYSQL_PARSE_ARGUMENTS -> CMAKE_PARSE_ARGUMENTS

parent 061f84ab
......@@ -14,11 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# Avoid warnings in higher versions
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.6)
CMAKE_POLICY(VERSION 2.8)
endif()
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.3)
# explicitly set the policy to OLD
# (cannot use NEW, not everyone is on cmake-2.8.12 yet)
......
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# Handy macro to parse macro arguments
MACRO(MYSQL_PARSE_ARGUMENTS prefix arg_names option_names)
SET(DEFAULT_ARGS)
FOREACH(arg_name ${arg_names})
SET(${prefix}_${arg_name})
ENDFOREACH(arg_name)
FOREACH(option ${option_names})
SET(${prefix}_${option} FALSE)
ENDFOREACH(option)
SET(current_arg_name DEFAULT_ARGS)
SET(current_arg_list)
FOREACH(arg ${ARGN})
SET(larg_names ${arg_names})
LIST(FIND larg_names "${arg}" is_arg_name)
IF (is_arg_name GREATER -1)
SET(${prefix}_${current_arg_name} ${current_arg_list})
SET(current_arg_name ${arg})
SET(current_arg_list)
ELSE (is_arg_name GREATER -1)
SET(loption_names ${option_names})
LIST(FIND loption_names "${arg}" is_option)
IF (is_option GREATER -1)
SET(${prefix}_${arg} TRUE)
ELSE (is_option GREATER -1)
SET(current_arg_list ${current_arg_list} ${arg})
ENDIF (is_option GREATER -1)
ENDIF (is_arg_name GREATER -1)
ENDFOREACH(arg)
SET(${prefix}_${current_arg_name} ${current_arg_list})
ENDMACRO()
\ No newline at end of file
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
INCLUDE(CMakeParseArguments)
MACRO(MY_ADD_TEST name)
ADD_TEST(${name} ${name}-t)
ENDMACRO()
MACRO(MY_ADD_TESTS)
MYSQL_PARSE_ARGUMENTS(ARG "LINK_LIBRARIES;EXT" "" ${ARGN})
CMAKE_PARSE_ARGUMENTS(ARG "" "EXT" "LINK_LIBRARIES" ${ARGN})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/unittest/mytap)
......@@ -15,7 +15,7 @@ MACRO(MY_ADD_TESTS)
SET(ARG_EXT "c")
ENDIF()
FOREACH(name ${ARG_DEFAULT_ARGS})
FOREACH(name ${ARG_UNPARSED_ARGUMENTS})
ADD_EXECUTABLE(${name}-t "${name}-t.${ARG_EXT}")
TARGET_LINK_LIBRARIES(${name}-t mytap ${ARG_LINK_LIBRARIES})
MY_ADD_TEST(${name})
......
......@@ -13,12 +13,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
INCLUDE(CMakeParseArguments)
FUNCTION (INSTALL_DEBUG_SYMBOLS)
IF(MSVC)
MYSQL_PARSE_ARGUMENTS(ARG
CMAKE_PARSE_ARGUMENTS(ARG
""
"COMPONENT;INSTALL_LOCATION"
""
${ARGN}
......@@ -30,7 +30,7 @@ FUNCTION (INSTALL_DEBUG_SYMBOLS)
IF(NOT ARG_INSTALL_LOCATION)
SET(ARG_INSTALL_LOCATION lib)
ENDIF()
SET(targets ${ARG_DEFAULT_ARGS})
SET(targets ${ARG_UNPARSED_ARGUMENTS})
FOREACH(target ${targets})
GET_TARGET_PROPERTY(type ${target} TYPE)
GET_TARGET_PROPERTY(location ${target} LOCATION)
......@@ -110,13 +110,14 @@ FUNCTION(INSTALL_MANPAGE file)
ENDFUNCTION()
FUNCTION(INSTALL_SCRIPT)
MYSQL_PARSE_ARGUMENTS(ARG
CMAKE_PARSE_ARGUMENTS(ARG
""
"DESTINATION;COMPONENT"
""
${ARGN}
)
SET(script ${ARG_DEFAULT_ARGS})
SET(script ${ARG_UNPARSED_ARGUMENTS})
IF(NOT ARG_DESTINATION)
SET(ARG_DESTINATION ${INSTALL_BINDIR})
ENDIF()
......@@ -132,8 +133,8 @@ ENDFUNCTION()
FUNCTION(INSTALL_DOCUMENTATION)
MYSQL_PARSE_ARGUMENTS(ARG "COMPONENT" "" ${ARGN})
SET(files ${ARG_DEFAULT_ARGS})
CMAKE_PARSE_ARGUMENTS(ARG "" "COMPONENT" "" ${ARGN})
SET(files ${ARG_UNPARSED_ARGUMENTS})
IF(NOT ARG_COMPONENT)
SET(ARG_COMPONENT Server)
ENDIF()
......@@ -212,8 +213,8 @@ IF(WIN32)
ENDIF()
MACRO(SIGN_TARGET)
MYSQL_PARSE_ARGUMENTS(ARG "COMPONENT" "" ${ARGN})
SET(target ${ARG_DEFAULT_ARGS})
CMAKE_PARSE_ARGUMENTS(ARG "" "COMPONENT" "" ${ARGN})
SET(target ${ARG_UNPARSED_ARGUMENTS})
IF(ARG_COMPONENT)
SET(comp COMPONENT ${ARG_COMPONENT})
ELSE()
......@@ -248,8 +249,9 @@ ENDMACRO()
#
FUNCTION(MYSQL_INSTALL_TARGETS)
MYSQL_PARSE_ARGUMENTS(ARG
"DESTINATION;COMPONENT"
CMAKE_PARSE_ARGUMENTS(ARG
""
"DESTINATION;COMPONENT"
""
${ARGN}
)
......@@ -259,7 +261,7 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
MESSAGE(FATAL_ERROR "COMPONENT argument required")
ENDIF()
SET(TARGETS ${ARG_DEFAULT_ARGS})
SET(TARGETS ${ARG_UNPARSED_ARGUMENTS})
IF(NOT TARGETS)
MESSAGE(FATAL_ERROR "Need target list for MYSQL_INSTALL_TARGETS")
ENDIF()
......@@ -267,10 +269,9 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
MESSAGE(FATAL_ERROR "Need DESTINATION parameter for MYSQL_INSTALL_TARGETS")
ENDIF()
FOREACH(target ${TARGETS})
# If signing is required, sign executables before installing
IF(SIGNCODE)
IF(SIGNCODE)
SIGN_TARGET(${target} ${COMP})
ENDIF()
# Install man pages on Unix
......@@ -293,7 +294,8 @@ SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug
FUNCTION(INSTALL_DEBUG_TARGET target)
MYSQL_PARSE_ARGUMENTS(ARG
CMAKE_PARSE_ARGUMENTS(ARG
""
"DESTINATION;RENAME;PDB_DESTINATION;COMPONENT"
""
${ARGN}
......
......@@ -57,7 +57,7 @@ IF(WIN32 OR CYGWIN OR APPLE OR WITH_PIC OR DISABLE_SHARED OR NOT CMAKE_SHARED_LI
SET(_SKIP_PIC 1)
ENDIF()
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
INCLUDE(CMakeParseArguments)
# CREATE_EXPORT_FILE (VAR target api_functions)
# Internal macro, used to create source file for shared libraries that
# otherwise consists entirely of "convenience" libraries. On Windows,
......@@ -213,13 +213,14 @@ ENDMACRO()
# [OUTPUT_NAME output_name]
#)
MACRO(MERGE_LIBRARIES)
MYSQL_PARSE_ARGUMENTS(ARG
"EXPORTS;OUTPUT_NAME;COMPONENT;VERSION;SOVERSION"
CMAKE_PARSE_ARGUMENTS(ARG
"STATIC;SHARED;MODULE;NOINSTALL"
"OUTPUT_NAME;COMPONENT;VERSION;SOVERSION"
"EXPORTS"
${ARGN}
)
LIST(GET ARG_DEFAULT_ARGS 0 TARGET)
SET(LIBS ${ARG_DEFAULT_ARGS})
LIST(GET ARG_UNPARSED_ARGUMENTS 0 TARGET)
SET(LIBS ${ARG_UNPARSED_ARGUMENTS})
LIST(REMOVE_AT LIBS 0)
IF(ARG_STATIC)
IF (NOT ARG_OUTPUT_NAME)
......
......@@ -24,21 +24,37 @@
# - add version resource
# - instruct CPack to do autenticode signing if SIGNCODE is set
INCLUDE(cmake_parse_arguments)
INCLUDE(CMakeParseArguments)
FUNCTION (MYSQL_ADD_EXECUTABLE)
# Pass-through arguments for ADD_EXECUTABLE
MYSQL_PARSE_ARGUMENTS(ARG
"WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL;DESTINATION;COMPONENT"
CMAKE_PARSE_ARGUMENTS(ARG
"WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL"
"DESTINATION;COMPONENT"
""
${ARGN}
)
LIST(GET ARG_DEFAULT_ARGS 0 target)
LIST(REMOVE_AT ARG_DEFAULT_ARGS 0)
LIST(GET ARG_UNPARSED_ARGUMENTS 0 target)
LIST(REMOVE_AT ARG_UNPARSED_ARGUMENTS 0)
SET(sources ${ARG_DEFAULT_ARGS})
SET(sources ${ARG_UNPARSED_ARGUMENTS})
ADD_VERSION_INFO(${target} EXECUTABLE sources)
ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources})
IF (ARG_WIN32)
SET(WIN32 WIN32)
ELSE()
UNSET(WIN32)
ENDIF()
IF (ARG_MACOSX_BUNDLE)
SET(MACOSX_BUNDLE MACOSX_BUNDLE)
ELSE()
UNSET(MACOSX_BUNDLE)
ENDIF()
IF (ARG_EXCLUDE_FROM_ALL)
SET(EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL)
ELSE()
UNSET(EXCLUDE_FROM_ALL)
ENDIF()
ADD_EXECUTABLE(${target} ${WIN32} ${MACOSX_BUNDLE} ${EXCLUDE_FROM_ALL} ${sources})
# tell CPack where to install
IF(NOT ARG_EXCLUDE_FROM_ALL)
IF(NOT ARG_DESTINATION)
......
......@@ -14,8 +14,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
INCLUDE(CMakeParseArguments)
# MYSQL_ADD_PLUGIN(plugin_name source1...sourceN
# [STORAGE_ENGINE]
......@@ -28,9 +27,10 @@ INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
# [DEPENDENCIES target1...targetN]
MACRO(MYSQL_ADD_PLUGIN)
MYSQL_PARSE_ARGUMENTS(ARG
"LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG"
CMAKE_PARSE_ARGUMENTS(ARG
"STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED"
"MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG"
"LINK_LIBRARIES;DEPENDENCIES"
${ARGN}
)
......@@ -41,8 +41,8 @@ MACRO(MYSQL_ADD_PLUGIN)
${SSL_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR})
LIST(GET ARG_DEFAULT_ARGS 0 plugin)
SET(SOURCES ${ARG_DEFAULT_ARGS})
LIST(GET ARG_UNPARSED_ARGUMENTS 0 plugin)
SET(SOURCES ${ARG_UNPARSED_ARGUMENTS})
LIST(REMOVE_AT SOURCES 0)
STRING(TOUPPER ${plugin} plugin)
STRING(TOLOWER ${plugin} target)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment