Browse Source

Get rid of the MySQL stuff and use a new one

I already tested this new one with Yc. I am going to push this change
and then do some style fixing.
master
Gavin Howard 4 years ago
parent
commit
3d2e0eff31
Signed by: gavin GPG Key ID: C08038BDF280D33E
  1. 2
      CMakeLists.txt
  2. 264
      LICENSE.md
  3. 9
      README.md
  4. 175
      functions.cmake
  5. 14
      merge.cmake.in
  6. 14
      mysql/README.md
  7. 46
      mysql/cmake_parse_arguments.cmake
  8. 309
      mysql/libutils.cmake
  9. 63
      mysql/merge_archives_unix.cmake.in

2
CMakeLists.txt

@ -24,6 +24,4 @@
#
# ****** END LICENSE BLOCK ******
add_subdirectory("mysql")
include("functions.cmake")

264
LICENSE.md

@ -1,264 +0,0 @@
The GNU General Public License, Version 2, June 1991 (GPLv2)
============================================================
> Copyright (C) 1989, 1991 Free Software Foundation, Inc.
> 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
--------
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public License is intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to most
of the Free Software Foundation's software and to any other program whose
authors commit to using it. (Some other Free Software Foundation software is
covered by the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom to
distribute copies of free software (and charge for this service if you wish),
that you receive source code or can get it if you want it, that you can change
the software or use pieces of it in new free programs; and that you know you can
do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny
you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of the
software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or for a
fee, you must give the recipients all the rights that you have. You must make
sure that they, too, receive or can get the source code. And you must show them
these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2) offer
you this license which gives you legal permission to copy, distribute and/or
modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If the
software is modified by someone else and passed on, we want its recipients to
know that what they have is not the original, so that any problems introduced by
others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We wish
to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's free
use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
Terms And Conditions For Copying, Distribution And Modification
---------------------------------------------------------------
**0.** This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms of
this General Public License. The "Program", below, refers to any such program or
work, and a "work based on the Program" means either the Program or any
derivative work under copyright law: that is to say, a work containing the
Program or a portion of it, either verbatim or with modifications and/or
translated into another language. (Hereinafter, translation is included without
limitation in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered by
this License; they are outside its scope. The act of running the Program is not
restricted, and the output from the Program is covered only if its contents
constitute a work based on the Program (independent of having been made by
running the Program). Whether that is true depends on what the Program does.
**1.** You may copy and distribute verbatim copies of the Program's source code
as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this License
and to the absence of any warranty; and give any other recipients of the Program
a copy of this License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you may at
your option offer warranty protection in exchange for a fee.
**2.** You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such
modifications or work under the terms of Section 1 above, provided that you also
meet all of these conditions:
* **a)** You must cause the modified files to carry prominent notices stating
that you changed the files and the date of any change.
* **b)** You must cause any work that you distribute or publish, that in whole
or in part contains or is derived from the Program or any part thereof, to
be licensed as a whole at no charge to all third parties under the terms of
this License.
* **c)** If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use in the
most ordinary way, to print or display an announcement including an
appropriate copyright notice and a notice that there is no warranty (or
else, saying that you provide a warranty) and that users may redistribute
the program under these conditions, and telling the user how to view a copy
of this License. (Exception: if the Program itself is interactive but does
not normally print such an announcement, your work based on the Program is
not required to print an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License, and
its terms, do not apply to those sections when you distribute them as separate
works. But when you distribute the same sections as part of a whole which is a
work based on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the entire whole,
and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise the
right to control the distribution of derivative or collective works based on the
Program.
In addition, mere aggregation of another work not based on the Program with the
Program (or with a work based on the Program) on a volume of a storage or
distribution medium does not bring the other work under the scope of this
License.
**3.** You may copy and distribute the Program (or a work based on it, under
Section 2) in object code or executable form under the terms of Sections 1 and 2
above provided that you also do one of the following:
* **a)** Accompany it with the complete corresponding machine-readable source
code, which must be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,
* **b)** Accompany it with a written offer, valid for at least three years, to
give any third party, for a charge no more than your cost of physically
performing source distribution, a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of Sections 1
and 2 above on a medium customarily used for software interchange; or,
* **c)** Accompany it with the information you received as to the offer to
distribute corresponding source code. (This alternative is allowed only for
noncommercial distribution and only if you received the program in object
code or executable form with such an offer, in accord with Subsection b
above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code means all the
source code for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation and installation
of the executable. However, as a special exception, the source code distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
If distribution of executable or object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the source code
from the same place counts as distribution of the source code, even though third
parties are not compelled to copy the source along with the object code.
**4.** You may not copy, modify, sublicense, or distribute the Program except as
expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies, or
rights, from you under this License will not have their licenses terminated so
long as such parties remain in full compliance.
**5.** You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you do
not accept this License. Therefore, by modifying or distributing the Program (or
any work based on the Program), you indicate your acceptance of this License to
do so, and all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
**6.** Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these terms and
conditions. You may not impose any further restrictions on the recipients'
exercise of the rights granted herein. You are not responsible for enforcing
compliance by third parties to this License.
**7.** If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues), conditions
are imposed on you (whether by court order, agreement or otherwise) that
contradict the conditions of this License, they do not excuse you from the
conditions of this License. If you cannot distribute so as to satisfy
simultaneously your obligations under this License and any other pertinent
obligations, then as a consequence you may not distribute the Program at all.
For example, if a patent license would not permit royalty-free redistribution of
the Program by all those who receive copies directly or indirectly through you,
then the only way you could satisfy both it and this License would be to refrain
entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and the
section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents or
other property right claims or to contest validity of any such claims; this
section has the sole purpose of protecting the integrity of the free software
distribution system, which is implemented by public license practices. Many
people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose that
choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
**8.** If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit
geographical distribution limitation excluding those countries, so that
distribution is permitted only in or among countries not thus excluded. In such
case, this License incorporates the limitation as if written in the body of this
License.
**9.** The Free Software Foundation may publish revised and/or new versions of
the General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Program does not specify a version number of this License, you may choose any
version ever published by the Free Software Foundation.
**10.** If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this.
Our decision will be guided by the two goals of preserving the free status of
all derivatives of our free software and of promoting the sharing and reuse of
software generally.
No Warranty
-----------
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA
BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER
OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

9
README.md

@ -3,13 +3,6 @@
This project contains all of the CMake tools for Yzena repos. It is usually
included as a git submodule in other projects.
## License
Because some code in the repository comes from the
[MySQL repo](https://github.com/mysql/mysql-server), and is licensed under the
GNU General Public License, Version 2, all code in the repository is under that
same license.
## Contents
Files:
@ -18,5 +11,3 @@ Files:
all of the other CMake files in the directory and adds all
subdirectories.
functions.cmake All CMake functions used in Yzena repositories.
LICENSE.md A Markdown version of the GNU General Public License,
Version 2.

175
functions.cmake

@ -22,60 +22,199 @@
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
# The function merge_static_libs is under the following copyright and license:
# Copyright (C) 2012 Modelon AB
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the BSD style 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
# FMILIB_License.txt file for more details.
#
# You should have received a copy of the BSD license along with this program.
# If not, contact Modelon AB <http://www.modelon.com>.
#
# ****** END LICENSE BLOCK ******
function (create_test target)
# Make sure we save this.
set(SCRIPT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
# Merge_static_libs(outlib lib1 lib2 ... libn) merges a number of static
# libs into a single static library
function(merge_static_libs outlib )
set(libs ${ARGV})
list(REMOVE_AT libs 0)
# Create a dummy file that the target will depend on
set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/${outlib}_dummy.c)
file(WRITE ${dummyfile} "// ${dummyfile}")
add_library(${outlib} STATIC ${dummyfile})
if("${CMAKE_CFG_INTDIR}" STREQUAL ".")
set(multiconfig FALSE)
else()
set(multiconfig TRUE)
endif()
# First get the file names of the libraries to be merged
foreach(lib ${libs})
get_target_property(libtype ${lib} TYPE)
if(NOT libtype STREQUAL "STATIC_LIBRARY")
message(FATAL_ERROR "Merge_static_libs can only process static libraries")
endif()
if(multiconfig)
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
get_target_property("libfile_${CONFIG_TYPE}" ${lib} "LOCATION_${CONFIG_TYPE}")
list(APPEND libfiles_${CONFIG_TYPE} ${libfile_${CONFIG_TYPE}})
endforeach()
else()
get_target_property(libfile ${lib} LOCATION)
list(APPEND libfiles "${libfile}")
endif(multiconfig)
endforeach()
message(STATUS "will be merging ${libfiles}")
# Just to be sure: cleanup from duplicates
if(multiconfig)
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
list(REMOVE_DUPLICATES libfiles_${CONFIG_TYPE})
set(libfiles ${libfiles} ${libfiles_${CONFIG_TYPE}})
endforeach()
endif()
list(REMOVE_DUPLICATES libfiles)
# Now the easy part for MSVC and for MAC
if(MSVC)
# lib.exe does the merging of libraries just need to conver the list into string
foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
set(flags "")
foreach(lib ${libfiles_${CONFIG_TYPE}})
set(flags "${flags} ${lib}")
endforeach()
string(TOUPPER "STATIC_LIBRARY_FLAGS_${CONFIG_TYPE}" PROPNAME)
set_target_properties(${outlib} PROPERTIES ${PROPNAME} "${flags}")
endforeach()
elseif(APPLE)
# Use OSX's libtool to merge archives
if(multiconfig)
message(FATAL_ERROR "Multiple configurations are not supported")
endif()
get_target_property(outfile ${outlib} LOCATION)
add_custom_command(TARGET ${outlib} POST_BUILD
COMMAND rm ${outfile}
COMMAND /usr/bin/libtool -static -o ${outfile}
${libfiles})
else()
# general UNIX - need to "ar -x" and then "ar -ru"
if(multiconfig)
message(FATAL_ERROR "Multiple configurations are not supported")
endif()
get_target_property(outfile ${outlib} LOCATION)
message(STATUS "outfile location is ${outfile}")
foreach(lib ${libfiles})
# objlistfile will contain the list of object files for the library
set(objlistfile ${lib}.objlist)
set(objdir ${lib}.objdir)
set(objlistcmake ${objlistfile}.cmake)
# we only need to extract files once
if(${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/cmake.check_cache IS_NEWER_THAN ${objlistcmake})
#---------------------------------
configure_file("${SCRIPT_DIR}/merge.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/merge_${objlistfile}.cmake" @ONLY)
#---------------------------------
file(MAKE_DIRECTORY ${objdir})
add_custom_command(
OUTPUT ${objlistfile}
COMMAND ${CMAKE_COMMAND} -P ${objlistcmake}
DEPENDS ${lib})
endif()
list(APPEND extrafiles "${objlistfile}")
# relative path is needed by ar under MSYS
file(RELATIVE_PATH objlistfilerpath ${objdir} ${objlistfile})
add_custom_command(TARGET ${outlib} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_AR} ru ${outfile} @${objlistfilerpath}"
COMMAND ${CMAKE_AR} ru "${outfile}" @"${objlistfilerpath}"
WORKING_DIRECTORY ${objdir})
endforeach()
add_custom_command(TARGET ${outlib}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Running: ${CMAKE_RANLIB} ${outfile}"
COMMAND ${CMAKE_RANLIB} ${outfile})
endif()
file(WRITE ${dummyfile}.base "const char* ${outlib}_sublibs=\"${libs}\";")
add_custom_command(
OUTPUT ${dummyfile}
COMMAND ${CMAKE_COMMAND} -E copy ${dummyfile}.base ${dummyfile}
DEPENDS ${libs} ${extrafiles})
endfunction()
function(create_test target)
add_executable("${target}" "${target}.c")
target_link_libraries("${target}" "${ARGN}")
add_test (NAME ${target} COMMAND $<TARGET_FILE:${target}>)
add_test(NAME ${target} COMMAND $<TARGET_FILE:${target}>)
endfunction (create_test)
endfunction(create_test)
function (create_shared_library name output_name src doinstall)
function(create_shared_library name output_name src doinstall)
add_library("${name}" SHARED "${src}")
target_link_libraries("${name}" "${ARGN}")
set_target_properties("${name}" PROPERTIES OUTPUT_NAME "${output_name}")
set_target_properties("${name}"
PROPERTIES
LOCATION "${CMAKE_CURRENT_BINARY_DIR}"
OUTPUT_NAME "${output_name}")
if (doinstall)
if(doinstall)
install(TARGETS "${name}" LIBRARY DESTINATION lib/)
endif(doinstall)
endfunction (create_shared_library)
endfunction(create_shared_library)
function (create_static_library name output_name src doinstall)
function(create_static_library name output_name src doinstall)
add_library("${name}" STATIC "${src}")
target_link_libraries("${name}" "${ARGN}")
set_target_properties("${name}" PROPERTIES OUTPUT_NAME "${output_name}")
set_target_properties("${name}"
PROPERTIES
LOCATION "${CMAKE_CURRENT_BINARY_DIR}"
OUTPUT_NAME "${output_name}")
if (doinstall)
if(doinstall)
install(TARGETS "${name}" ARCHIVE DESTINATION lib/)
endif(doinstall)
endfunction (create_static_library)
endfunction(create_static_library)
function (create_pic_library name output_name src doinstall)
function(create_pic_library name output_name src doinstall)
add_library("${name}" STATIC "${src}")
target_link_libraries("${name}" "${ARGN}")
set_target_properties("${name}" PROPERTIES OUTPUT_NAME "${output_name}")
set_property(TARGET "${name}" PROPERTY POSITION_INDEPENDENT_CODE ON)
set_target_properties("${name}"
PROPERTIES
LOCATION "${CMAKE_CURRENT_BINARY_DIR}"
OUTPUT_NAME "${output_name}"
POSITION_INDEPENDENT_CODE ON)
if (doinstall)
if(doinstall)
install(TARGETS "${name}" ARCHIVE DESTINATION lib/)
endif(doinstall)
endfunction (create_pic_library)
endfunction(create_pic_library)
function (create_all_libraries shared_name static_name pic_name output_name src doinstall)
function(create_all_libraries shared_name static_name pic_name output_name src doinstall)
create_shared_library("${shared_name}" "${output_name}" "${src}" "${doinstall}" "${ARGN}")
create_static_library("${static_name}" "${output_name}" "${src}" "${doinstall}" "${ARGN}")
create_pic_library("${pic_name}" "${output_name}_pic" "${src}" "${doinstall}" "${ARGN}")
endfunction (create_all_libraries)
endfunction(create_all_libraries)

14
mysql/CMakeLists.txt → merge.cmake.in

@ -24,4 +24,16 @@
#
# ****** END LICENSE BLOCK ******
include("libutils.cmake")
set(LIB @lib@)
set(OBJDIR @objdir@)
set(OBJLISTFILE @objlistfile@)
# Extract object files from the library
message(STATUS "Extracting object files from ${LIB}")
execute_process(COMMAND ${CMAKE_AR} -x ${LIB}
WORKING_DIRECTORY ${OBJDIR})
# Save the list of object files.
execute_process(COMMAND ls .
OUTPUT_FILE ${OBJLISTFILE}
WORKING_DIRECTORY ${OBJDIR})

14
mysql/README.md

@ -1,14 +0,0 @@
# mysql
Files that came from [MySQL CMake](https://github.com/mysql/mysql-server/cmake).
## Contents
Files:
CMakeLists.txt The CMake config file for this directory. It
just includes all of the other CMake files in
the directory.
cmake_parse_arguments.cmake A file to parse args from MySQL.
libutils.cmake Macros that came from the MySQL project.
merge_archives_unix.cmake.in A file from MySQL used to merge libs on Unix.

46
mysql/cmake_parse_arguments.cmake

@ -1,46 +0,0 @@
# 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()

309
mysql/libutils.cmake

@ -1,309 +0,0 @@
# Copyright (c) 2009, 2017, 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
# This file exports macros that emulate some functionality found in GNU libtool
# on Unix systems. One such feature is convenience libraries. In this context,
# convenience library is a static library that can be linked to shared library
# On systems that force position-independent code, linking into shared library
# normally requires compilation with a special flag (often -fPIC).
# Some systems, like Windows or OSX do not need special compilation (Windows
# never uses PIC and OSX always uses it).
#
# The intention behind convenience libraries is simplify the build and to reduce
# excessive recompiles.
# Except for convenience libraries, this file provides macros to merge static
# libraries (we need it for mysqlclient) and to create shared library out of
# convenience libraries(again, for mysqlclient)
# Following macros are exported
# - ADD_CONVENIENCE_LIBRARY(target source1...sourceN)
# This macro creates convenience library. The functionality is similar to
# ADD_LIBRARY(target STATIC source1...sourceN), the difference is that resulting
# library can always be linked to shared library
#
# - MERGE_LIBRARIES(target [STATIC|SHARED|MODULE] [linklib1 .... linklibN]
# [EXPORTS exported_func1 .... exported_func_N]
# [OUTPUT_NAME output_name]
# This macro merges several static libraries into a single one or creates a shared
# library from several convenience libraries
# Important global flags
#
# - DISABLE_SHARED: If set, it is assumed that shared libraries are not produced
# during the build. ADD_CONVENIENCE_LIBRARY does not add anything to compile flags
GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
IF(WIN32 OR APPLE OR DISABLE_SHARED)
SET(_SKIP_PIC 1)
ENDIF()
INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
# CREATE_EXPORT_FILE (VAR target api_functions)
# Internal macro, used on Windows to export API functions as dllexport.
# Returns a list of extra files that should be linked into the library
# (in the variable pointed to by VAR).
MACRO(CREATE_EXPORT_FILE VAR TARGET API_FUNCTIONS)
SET(DUMMY ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_dummy.c)
CONFIGURE_FILE_CONTENT("" ${DUMMY})
IF(WIN32)
SET(EXPORTS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_exports.def)
SET(CONTENT "EXPORTS\n")
FOREACH(FUNC ${API_FUNCTIONS})
SET(CONTENT "${CONTENT} ${FUNC}\n")
ENDFOREACH()
CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS})
SET(${VAR} ${DUMMY} ${EXPORTS})
ELSE()
SET(${VAR} ${DUMMY})
ENDIF()
ENDMACRO()
# MYSQL_ADD_CONVENIENCE_LIBRARY(name source1...sourceN)
# Create static library that can be linked to shared library.
# On systems that force position-independent code, adds -fPIC or
# equivalent flag to compile flags.
MACRO(ADD_CONVENIENCE_LIBRARY)
SET(TARGET ${ARGV0})
SET(SOURCES ${ARGN})
LIST(REMOVE_AT SOURCES 0)
ADD_LIBRARY(${TARGET} STATIC ${SOURCES})
ENDMACRO()
# Write content to file, using CONFIGURE_FILE
# The advantage compared to FILE(WRITE) is that timestamp
# does not change if file already has the same content
MACRO(CONFIGURE_FILE_CONTENT content file)
SET(CMAKE_CONFIGURABLE_FILE_CONTENT
"${content}\n")
CONFIGURE_FILE(
${MYSQL_CMAKE_SCRIPT_DIR}/configurable_file_content.in
${file}
@ONLY)
ENDMACRO()
# Merge static libraries into a big static lib. The resulting library
# should not not have dependencies on other static libraries.
# We use it in MySQL to merge mysys,dbug,vio etc into mysqlclient
MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
# To produce a library we need at least one source file.
# It is created by ADD_CUSTOM_COMMAND below and will
# also help to track dependencies.
SET(SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_depends.c)
ADD_LIBRARY(${TARGET} STATIC ${SOURCE_FILE})
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})
SET(OSLIBS)
FOREACH(LIB ${LIBS_TO_MERGE})
GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION)
GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE)
IF(NOT LIB_LOCATION)
# 3rd party library like libz.so. Make sure that everything
# that links to our library links to this one as well.
LIST(APPEND OSLIBS ${LIB})
ELSE()
# This is a target in current project
# (can be a static or shared lib)
IF(LIB_TYPE STREQUAL "STATIC_LIBRARY")
SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION})
ADD_DEPENDENCIES(${TARGET} ${LIB})
# Extract dependend OS libraries
GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS)
LIST(APPEND OSLIBS ${LIB_OSLIBS})
ELSE()
# This is a shared library our static lib depends on.
LIST(APPEND OSLIBS ${LIB})
ENDIF()
ENDIF()
ENDFOREACH()
IF(OSLIBS)
LIST(REMOVE_DUPLICATES OSLIBS)
TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS})
MESSAGE(STATUS "Library ${TARGET} depends on OSLIBS ${OSLIBS}")
ENDIF()
IF(STATIC_LIBS)
LIST(REMOVE_DUPLICATES STATIC_LIBS)
ENDIF()
# Make the generated dummy source file depended on all static input
# libs. If input lib changes,the source file is touched
# which causes the desired effect (relink).
ADD_CUSTOM_COMMAND(
OUTPUT ${SOURCE_FILE}
COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE}
DEPENDS ${STATIC_LIBS})
IF(MSVC)
# To merge libs, just pass them to lib.exe command line.
SET(LINKER_EXTRA_FLAGS "")
FOREACH(LIB ${STATIC_LIBS})
SET(LINKER_EXTRA_FLAGS "${LINKER_EXTRA_FLAGS} ${LIB}")
ENDFOREACH()
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS
"${LINKER_EXTRA_FLAGS}")
ELSE()
GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION)
IF(APPLE)
# Use OSX's libtool to merge archives (ihandles universal
# binaries properly)
ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
COMMAND rm ${TARGET_LOCATION}
COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION}
${STATIC_LIBS}
)
ELSE()
# Generic Unix or MinGW. In post-build step, call
# script, that extracts objects from archives with "ar x"
# and repacks them with "ar r"
SET(TARGET ${TARGET})
CONFIGURE_FILE(
${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake
@ONLY
)
ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
COMMAND rm ${TARGET_LOCATION}
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake
)
ENDIF()
ENDIF()
ENDMACRO()
# Create libs from libs.
# Merges static libraries, creates shared libraries out of convenience libraries.
# MERGE_LIBRARIES(target [STATIC|SHARED|MODULE]
# [linklib1 .... linklibN]
# [EXPORTS exported_func1 .... exportedFuncN]
# [OUTPUT_NAME output_name]
#)
MACRO(MERGE_LIBRARIES)
MYSQL_PARSE_ARGUMENTS(ARG
"EXPORTS;OUTPUT_NAME;COMPONENT"
"STATIC;SHARED;MODULE;SKIP_INSTALL"
${ARGN}
)
LIST(GET ARG_DEFAULT_ARGS 0 TARGET)
SET(LIBS ${ARG_DEFAULT_ARGS})
LIST(REMOVE_AT LIBS 0)
IF(ARG_STATIC)
IF (NOT ARG_OUTPUT_NAME)
SET(ARG_OUTPUT_NAME ${TARGET})
ENDIF()
MERGE_STATIC_LIBS(${TARGET} ${ARG_OUTPUT_NAME} "${LIBS}")
ELSEIF(ARG_SHARED OR ARG_MODULE)
IF(ARG_SHARED)
SET(LIBTYPE SHARED)
ELSE()
SET(LIBTYPE MODULE)
ENDIF()
# check for non-PIC libraries
IF(NOT _SKIP_PIC)
FOREACH(LIB ${LIBS})
GET_TARGET_PROPERTY(${LIB} TYPE LIBTYPE)
IF(LIBTYPE STREQUAL "STATIC_LIBRARY")
GET_TARGET_PROPERTY(LIB COMPILE_FLAGS LIB_COMPILE_FLAGS)
IF(NOT LIB_COMPILE_FLAGS MATCHES "<PIC_FLAG>")
MESSAGE(FATAL_ERROR
"Attempted to link non-PIC static library ${LIB} to shared library ${TARGET}\n"
"Please use ADD_CONVENIENCE_LIBRARY, instead of ADD_LIBRARY for ${LIB}"
)
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
CREATE_EXPORT_FILE(SRC ${TARGET} "${ARG_EXPORTS}")
IF(UNIX)
# Mark every export as explicitly needed, so that ld won't remove the .a files
# containing them. This has a similar effect as --Wl,--no-whole-archive,
# but is more focused.
FOREACH(SYMBOL ${ARG_EXPORTS})
IF(APPLE)
SET(export_link_flags "${export_link_flags} -Wl,-u,_${SYMBOL}")
ELSE()
SET(export_link_flags "${export_link_flags} -Wl,-u,${SYMBOL}")
ENDIF()
ENDFOREACH()
ENDIF()
IF(NOT ARG_SKIP_INSTALL)
ADD_VERSION_INFO(${TARGET} SHARED SRC)
ENDIF()
ADD_LIBRARY(${TARGET} ${LIBTYPE} ${SRC})
# Collect all dynamic libraries in the same directory
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/library_output_directory)
TARGET_LINK_LIBRARIES(${TARGET} ${LIBS})
IF(ARG_OUTPUT_NAME)
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME "${ARG_OUTPUT_NAME}")
ENDIF()
SET_TARGET_PROPERTIES(${TARGET} PROPERTIES LINK_FLAGS "${export_link_flags}")
IF(APPLE AND HAVE_CRYPTO_DYLIB AND HAVE_OPENSSL_DYLIB)
ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
COMMAND install_name_tool -change
"${CRYPTO_VERSION}" "@loader_path/${CRYPTO_VERSION}"
$<TARGET_SONAME_FILE:${TARGET}>
COMMAND install_name_tool -change
"${OPENSSL_VERSION}" "@loader_path/${OPENSSL_VERSION}"
$<TARGET_SONAME_FILE:${TARGET}>
COMMAND install_name_tool -id "$<TARGET_SONAME_FILE_NAME:${TARGET}>"
$<TARGET_SONAME_FILE:${TARGET}>
)
# All executables have dependencies: "@loader_path/../lib/xxx.dylib
# Create a symlink so that this works for Xcode also.
IF(NOT BUILD_IS_SINGLE_CONFIG)
ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
$<TARGET_SONAME_FILE_DIR:${TARGET}> lib
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/runtime_output_directory
)
ENDIF()
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "Unknown library type")
ENDIF()
IF(NOT ARG_SKIP_INSTALL)
IF(ARG_COMPONENT)
SET(COMP COMPONENT ${ARG_COMPONENT})
ENDIF()
IF(ARG_SHARED OR ARG_MODULE OR INSTALL_STATIC_LIBRARIES)
MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION "${INSTALL_LIBDIR}" ${COMP})
ENDIF()
ENDIF()
ENDMACRO()
FUNCTION(GET_DEPENDEND_OS_LIBS target result)
SET(deps ${${target}_LIB_DEPENDS})
IF(deps)
FOREACH(lib ${deps})
# Filter out keywords for used for debug vs optimized builds
IF(NOT lib MATCHES "general" AND NOT lib MATCHES "debug" AND NOT lib MATCHES "optimized")
GET_TARGET_PROPERTY(lib_location ${lib} LOCATION)
IF(NOT lib_location)
SET(ret ${ret} ${lib})
ENDIF()
ENDIF()
ENDFOREACH()
ENDIF()
SET(${result} ${ret} PARENT_SCOPE)
ENDFUNCTION()

63
mysql/merge_archives_unix.cmake.in

@ -1,63 +0,0 @@
# Copyright (c) 2009 Sun Microsystems, Inc.
# Use is subject to license terms.
#
# 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
# This script merges many static libraries into
# one big library on Unix.
SET(TARGET_LOCATION "@TARGET_LOCATION@")
SET(TARGET "@TARGET@")
SET(STATIC_LIBS "@STATIC_LIBS@")
SET(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
SET(CMAKE_AR "@CMAKE_AR@")
SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
SET(TEMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET})
MAKE_DIRECTORY(${TEMP_DIR})
# Extract each archive to its own subdirectory(avoid object filename clashes)
FOREACH(LIB ${STATIC_LIBS})
GET_FILENAME_COMPONENT(NAME_NO_EXT ${LIB} NAME_WE)
SET(TEMP_SUBDIR ${TEMP_DIR}/${NAME_NO_EXT})
MAKE_DIRECTORY(${TEMP_SUBDIR})
EXECUTE_PROCESS(
COMMAND ${CMAKE_AR} -x ${LIB}
WORKING_DIRECTORY ${TEMP_SUBDIR}
)
FILE(GLOB_RECURSE LIB_OBJECTS "${TEMP_SUBDIR}/*")
SET(OBJECTS ${OBJECTS} ${LIB_OBJECTS})
ENDFOREACH()
# Use relative paths, makes command line shorter.
GET_FILENAME_COMPONENT(ABS_TEMP_DIR ${TEMP_DIR} ABSOLUTE)
FOREACH(OBJ ${OBJECTS})
FILE(RELATIVE_PATH OBJ ${ABS_TEMP_DIR} ${OBJ})
FILE(TO_NATIVE_PATH ${OBJ} OBJ)
SET(ALL_OBJECTS ${ALL_OBJECTS} ${OBJ})
ENDFOREACH()
FILE(TO_NATIVE_PATH ${TARGET_LOCATION} ${TARGET_LOCATION})
# Now pack the objects into library with ar.
EXECUTE_PROCESS(
COMMAND ${CMAKE_AR} -r ${TARGET_LOCATION} ${ALL_OBJECTS}
WORKING_DIRECTORY ${TEMP_DIR}
)
EXECUTE_PROCESS(
COMMAND ${CMAKE_RANLIB} ${TARGET_LOCATION}
WORKING_DIRECTORY ${TEMP_DIR}
)
# Cleanup
FILE(REMOVE_RECURSE ${TEMP_DIR})
Loading…
Cancel
Save