base: DestinyCore upstream @2d631f4e (fork SylvaniaCore ; sql/old retire)
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
# Collects all source files into the given variable,
|
||||
# which is useful to include all sources in subdirectories.
|
||||
# Ignores full qualified directories listed in the variadic arguments.
|
||||
#
|
||||
# Use it like:
|
||||
# CollectSourceFiles(
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
# COMMON_PRIVATE_SOURCES
|
||||
# # Exclude
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/Platform)
|
||||
#
|
||||
function(CollectSourceFiles current_dir variable)
|
||||
list(FIND ARGN "${current_dir}" IS_EXCLUDED)
|
||||
if(IS_EXCLUDED EQUAL -1)
|
||||
file(GLOB COLLECTED_SOURCES
|
||||
${current_dir}/*.c
|
||||
${current_dir}/*.cc
|
||||
${current_dir}/*.cpp
|
||||
${current_dir}/*.inl
|
||||
${current_dir}/*.def
|
||||
${current_dir}/*.h
|
||||
${current_dir}/*.hh
|
||||
${current_dir}/*.hpp)
|
||||
list(APPEND ${variable} ${COLLECTED_SOURCES})
|
||||
|
||||
file(GLOB SUB_DIRECTORIES ${current_dir}/*)
|
||||
foreach(SUB_DIRECTORY ${SUB_DIRECTORIES})
|
||||
if (IS_DIRECTORY ${SUB_DIRECTORY})
|
||||
CollectSourceFiles("${SUB_DIRECTORY}" "${variable}" "${ARGN}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(${variable} ${${variable}} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Collects all subdirectoroies into the given variable,
|
||||
# which is useful to include all subdirectories.
|
||||
# Ignores full qualified directories listed in the variadic arguments.
|
||||
#
|
||||
# Use it like:
|
||||
# CollectIncludeDirectories(
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
# COMMON_PUBLIC_INCLUDES
|
||||
# # Exclude
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/PrecompiledHeaders
|
||||
# ${CMAKE_CURRENT_SOURCE_DIR}/Platform)
|
||||
#
|
||||
function(CollectIncludeDirectories current_dir variable)
|
||||
list(FIND ARGN "${current_dir}" IS_EXCLUDED)
|
||||
if(IS_EXCLUDED EQUAL -1)
|
||||
list(APPEND ${variable} ${current_dir})
|
||||
file(GLOB SUB_DIRECTORIES ${current_dir}/*)
|
||||
foreach(SUB_DIRECTORY ${SUB_DIRECTORIES})
|
||||
if (IS_DIRECTORY ${SUB_DIRECTORY})
|
||||
CollectIncludeDirectories("${SUB_DIRECTORY}" "${variable}" "${ARGN}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(${variable} ${${variable}} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
#
|
||||
# Force out-of-source build
|
||||
#
|
||||
|
||||
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" BUILDING_IN_SOURCE)
|
||||
|
||||
if( BUILDING_IN_SOURCE )
|
||||
message(FATAL_ERROR "
|
||||
This project requires an out of source build. Remove the file 'CMakeCache.txt'
|
||||
found in this directory before continuing, create a separate build directory
|
||||
and run 'cmake path_to_project [options]' from there.
|
||||
")
|
||||
endif()
|
||||
@@ -0,0 +1,14 @@
|
||||
# check what platform we're on (64-bit or 32-bit), and create a simpler test than CMAKE_SIZEOF_VOID_P
|
||||
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
|
||||
set(PLATFORM 64)
|
||||
MESSAGE(STATUS "Detected 64-bit platform")
|
||||
else()
|
||||
set(PLATFORM 32)
|
||||
MESSAGE(STATUS "Detected 32-bit platform")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/platform/win/settings.cmake")
|
||||
elseif(UNIX)
|
||||
include("${CMAKE_SOURCE_DIR}/cmake/platform/unix/settings.cmake")
|
||||
endif()
|
||||
@@ -0,0 +1,67 @@
|
||||
# Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
# An interface library to make the target com available to other targets
|
||||
add_library(trinity-compile-option-interface INTERFACE)
|
||||
|
||||
# Use -std=c++11 instead of -std=gnu++11
|
||||
set(CXX_EXTENSIONS OFF)
|
||||
|
||||
# An interface library to make the target features available to other targets
|
||||
add_library(trinity-feature-interface INTERFACE)
|
||||
|
||||
target_compile_features(trinity-feature-interface
|
||||
INTERFACE
|
||||
cxx_std_20)
|
||||
|
||||
# An interface library to make the warnings level available to other targets
|
||||
# This interface taget is set-up through the platform specific script
|
||||
add_library(trinity-warning-interface INTERFACE)
|
||||
|
||||
# An interface used for all other interfaces
|
||||
add_library(trinity-default-interface INTERFACE)
|
||||
target_link_libraries(trinity-default-interface
|
||||
INTERFACE
|
||||
trinity-compile-option-interface
|
||||
trinity-feature-interface)
|
||||
|
||||
# An interface used for silencing all warnings
|
||||
add_library(trinity-no-warning-interface INTERFACE)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_compile_options(trinity-no-warning-interface
|
||||
INTERFACE
|
||||
/W0)
|
||||
else()
|
||||
target_compile_options(trinity-no-warning-interface
|
||||
INTERFACE
|
||||
-w)
|
||||
endif()
|
||||
|
||||
# An interface library to change the default behaviour
|
||||
# to hide symbols automatically.
|
||||
add_library(trinity-hidden-symbols-interface INTERFACE)
|
||||
|
||||
# An interface amalgamation which provides the flags and definitions
|
||||
# used by the dependency targets.
|
||||
add_library(trinity-dependency-interface INTERFACE)
|
||||
target_link_libraries(trinity-dependency-interface
|
||||
INTERFACE
|
||||
trinity-default-interface
|
||||
trinity-no-warning-interface
|
||||
trinity-hidden-symbols-interface)
|
||||
|
||||
# An interface amalgamation which provides the flags and definitions
|
||||
# used by the core targets.
|
||||
add_library(trinity-core-interface INTERFACE)
|
||||
target_link_libraries(trinity-core-interface
|
||||
INTERFACE
|
||||
trinity-default-interface
|
||||
trinity-warning-interface)
|
||||
@@ -0,0 +1,106 @@
|
||||
# Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
# Returns the base path to the script directory in the source directory
|
||||
function(WarnAboutSpacesInBuildPath)
|
||||
# Only check win32 since unix doesn't allow spaces in paths
|
||||
if (WIN32)
|
||||
string(FIND "${CMAKE_BINARY_DIR}" " " SPACE_INDEX_POS)
|
||||
|
||||
if (SPACE_INDEX_POS GREATER -1)
|
||||
message("")
|
||||
message(WARNING " *** WARNING!\n"
|
||||
" *** Your selected build directory contains spaces!\n"
|
||||
" *** Please note that this will cause issues!")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Returns the base path to the script directory in the source directory
|
||||
function(GetScriptsBasePath variable)
|
||||
set(${variable} "${CMAKE_SOURCE_DIR}/src/server/scripts" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Stores the absolut path of the given module in the variable
|
||||
function(GetPathToScriptModule module variable)
|
||||
GetScriptsBasePath(SCRIPTS_BASE_PATH)
|
||||
set(${variable} "${SCRIPTS_BASE_PATH}/${module}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Stores the project name of the given module in the variable
|
||||
function(GetProjectNameOfScriptModule module variable)
|
||||
string(TOLOWER "scripts_${SCRIPT_MODULE}" GENERATED_NAME)
|
||||
set(${variable} "${GENERATED_NAME}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Creates a list of all script modules
|
||||
# and stores it in the given variable.
|
||||
function(GetScriptModuleList variable)
|
||||
GetScriptsBasePath(BASE_PATH)
|
||||
file(GLOB LOCALE_SCRIPT_MODULE_LIST RELATIVE
|
||||
${BASE_PATH}
|
||||
${BASE_PATH}/*)
|
||||
|
||||
set(${variable})
|
||||
foreach(SCRIPT_MODULE ${LOCALE_SCRIPT_MODULE_LIST})
|
||||
GetPathToScriptModule(${SCRIPT_MODULE} SCRIPT_MODULE_PATH)
|
||||
if (IS_DIRECTORY ${SCRIPT_MODULE_PATH})
|
||||
list(APPEND ${variable} ${SCRIPT_MODULE})
|
||||
endif()
|
||||
endforeach()
|
||||
set(${variable} ${${variable}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Converts the given script module name into it's
|
||||
# variable name which holds the linkage type.
|
||||
function(ScriptModuleNameToVariable module variable)
|
||||
string(TOUPPER ${module} ${variable})
|
||||
set(${variable} "SCRIPTS_${${variable}}")
|
||||
set(${variable} ${${variable}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Stores in the given variable whether dynamic linking is required
|
||||
function(IsDynamicLinkingRequired variable)
|
||||
if(SCRIPTS MATCHES "dynamic")
|
||||
set(IS_DEFAULT_VALUE_DYNAMIC ON)
|
||||
endif()
|
||||
|
||||
GetScriptModuleList(SCRIPT_MODULE_LIST)
|
||||
set(IS_REQUIRED OFF)
|
||||
foreach(SCRIPT_MODULE ${SCRIPT_MODULE_LIST})
|
||||
ScriptModuleNameToVariable(${SCRIPT_MODULE} SCRIPT_MODULE_VARIABLE)
|
||||
if ((${SCRIPT_MODULE_VARIABLE} STREQUAL "dynamic") OR
|
||||
(${SCRIPT_MODULE_VARIABLE} STREQUAL "default" AND IS_DEFAULT_VALUE_DYNAMIC))
|
||||
set(IS_REQUIRED ON)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${variable} ${IS_REQUIRED} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Stores the native variable name
|
||||
function(GetNativeSharedLibraryName module variable)
|
||||
if(WIN32)
|
||||
set(${variable} "${module}.dll" PARENT_SCOPE)
|
||||
elseif(APPLE)
|
||||
set(${variable} "lib${module}.dylib" PARENT_SCOPE)
|
||||
else()
|
||||
set(${variable} "lib${module}.so" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Stores the native install path in the variable
|
||||
function(GetInstallOffset variable)
|
||||
if(WIN32)
|
||||
set(${variable} "${CMAKE_INSTALL_PREFIX}/scripts" PARENT_SCOPE)
|
||||
else()
|
||||
set(${variable} "${CMAKE_INSTALL_PREFIX}/bin/scripts" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -0,0 +1,115 @@
|
||||
# This file defines the following macros for developers to use in ensuring
|
||||
# that installed software is of the right version:
|
||||
#
|
||||
# ENSURE_VERSION - test that a version number is greater than
|
||||
# or equal to some minimum
|
||||
# ENSURE_VERSION_RANGE - test that a version number is greater than
|
||||
# or equal to some minimum and less than some
|
||||
# maximum
|
||||
# ENSURE_VERSION2 - deprecated, do not use in new code
|
||||
#
|
||||
|
||||
# ENSURE_VERSION
|
||||
# This macro compares version numbers of the form "x.y.z" or "x.y"
|
||||
# ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK)
|
||||
# will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION
|
||||
# Leading and trailing text is ok, e.g.
|
||||
# ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK)
|
||||
# which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system
|
||||
|
||||
# Copyright (c) 2006, David Faure, <faure@kde.org>
|
||||
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
# ENSURE_VERSION_RANGE
|
||||
# This macro ensures that a version number of the form
|
||||
# "x.y.z" or "x.y" falls within a range defined by
|
||||
# min_version <= found_version < max_version.
|
||||
# If this expression holds, FOO_VERSION_OK will be set TRUE
|
||||
#
|
||||
# Example: ENSURE_VERSION_RANGE3( "0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK )
|
||||
#
|
||||
# This macro will break silently if any of x,y,z are greater than 100.
|
||||
#
|
||||
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
# NORMALIZE_VERSION
|
||||
# Helper macro to convert version numbers of the form "x.y.z"
|
||||
# to an integer equal to 10^4 * x + 10^2 * y + z
|
||||
#
|
||||
# This macro will break silently if any of x,y,z are greater than 100.
|
||||
#
|
||||
# Copyright (c) 2006, David Faure, <faure@kde.org>
|
||||
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
# CHECK_RANGE_INCLUSIVE_LOWER
|
||||
# Helper macro to check whether x <= y < z
|
||||
#
|
||||
# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
|
||||
MACRO(NORMALIZE_VERSION _requested_version _normalized_version)
|
||||
STRING(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}")
|
||||
if (_threePartMatch)
|
||||
# parse the parts of the version string
|
||||
STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}")
|
||||
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}")
|
||||
STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}")
|
||||
else (_threePartMatch)
|
||||
STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}")
|
||||
STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}")
|
||||
set(_patch_vers "0")
|
||||
endif (_threePartMatch)
|
||||
|
||||
# compute an overall version number which can be compared at once
|
||||
MATH(EXPR ${_normalized_version} "${_major_vers}*10000 + ${_minor_vers}*100 + ${_patch_vers}")
|
||||
ENDMACRO(NORMALIZE_VERSION)
|
||||
|
||||
MACRO(CHECK_RANGE_INCLUSIVE_LOWER _lower_limit _value _upper_limit _ok)
|
||||
if (${_value} LESS ${_lower_limit})
|
||||
set( ${_ok} FALSE )
|
||||
elseif (${_value} EQUAL ${_lower_limit})
|
||||
set( ${_ok} TRUE )
|
||||
elseif (${_value} EQUAL ${_upper_limit})
|
||||
set( ${_ok} FALSE )
|
||||
elseif (${_value} GREATER ${_upper_limit})
|
||||
set( ${_ok} FALSE )
|
||||
else (${_value} LESS ${_lower_limit})
|
||||
set( ${_ok} TRUE )
|
||||
endif (${_value} LESS ${_lower_limit})
|
||||
ENDMACRO(CHECK_RANGE_INCLUSIVE_LOWER)
|
||||
|
||||
MACRO(ENSURE_VERSION requested_version found_version var_too_old)
|
||||
NORMALIZE_VERSION( ${requested_version} req_vers_num )
|
||||
NORMALIZE_VERSION( ${found_version} found_vers_num )
|
||||
|
||||
if (found_vers_num LESS req_vers_num)
|
||||
set( ${var_too_old} FALSE )
|
||||
else (found_vers_num LESS req_vers_num)
|
||||
set( ${var_too_old} TRUE )
|
||||
endif (found_vers_num LESS req_vers_num)
|
||||
|
||||
ENDMACRO(ENSURE_VERSION)
|
||||
|
||||
MACRO(ENSURE_VERSION2 requested_version2 found_version2 var_too_old2)
|
||||
ENSURE_VERSION( ${requested_version2} ${found_version2} ${var_too_old2})
|
||||
ENDMACRO(ENSURE_VERSION2)
|
||||
|
||||
MACRO(ENSURE_VERSION_RANGE min_version found_version max_version var_ok)
|
||||
NORMALIZE_VERSION( ${min_version} req_vers_num )
|
||||
NORMALIZE_VERSION( ${found_version} found_vers_num )
|
||||
NORMALIZE_VERSION( ${max_version} max_vers_num )
|
||||
|
||||
CHECK_RANGE_INCLUSIVE_LOWER( ${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok})
|
||||
ENDMACRO(ENSURE_VERSION_RANGE)
|
||||
@@ -0,0 +1,325 @@
|
||||
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
|
||||
#
|
||||
# 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; either version 2 of the License, or (at your
|
||||
# option) any later version.
|
||||
#
|
||||
# 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, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindMySQL
|
||||
-----------
|
||||
|
||||
Find MySQL.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
``MySQL::MySQL``
|
||||
MySQL client library, if found.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``MYSQL_FOUND``
|
||||
System has MySQL.
|
||||
``MYSQL_INCLUDE_DIR``
|
||||
MySQL include directory.
|
||||
``MYSQL_LIBRARY``
|
||||
MySQL library.
|
||||
``MYSQL_EXECUTABLE``
|
||||
Path to mysql client binary.
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
Set ``MYSQL_ROOT_DIR`` to the root directory of MySQL installation.
|
||||
#]=======================================================================]
|
||||
|
||||
set(MYSQL_FOUND 0)
|
||||
|
||||
set(_MYSQL_ROOT_HINTS
|
||||
${MYSQL_ROOT_DIR}
|
||||
ENV MYSQL_ROOT_DIR
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
set(MYSQL_CONFIG_PREFER_PATH "$ENV{MYSQL_HOME}/bin" CACHE FILEPATH
|
||||
"preferred path to MySQL (mysql_config)"
|
||||
)
|
||||
|
||||
find_program(MYSQL_CONFIG mysql_config
|
||||
${MYSQL_CONFIG_PREFER_PATH}
|
||||
/usr/local/mysql/bin/
|
||||
/usr/local/bin/
|
||||
/usr/bin/
|
||||
)
|
||||
|
||||
if(MYSQL_CONFIG)
|
||||
message(STATUS "Using mysql-config: ${MYSQL_CONFIG}")
|
||||
# set INCLUDE_DIR
|
||||
execute_process(
|
||||
COMMAND "${MYSQL_CONFIG}" --include
|
||||
OUTPUT_VARIABLE MY_TMP
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
string(REGEX REPLACE "-I([^ ]*)( .*)?" "\\1" MY_TMP "${MY_TMP}")
|
||||
set(MYSQL_ADD_INCLUDE_PATH ${MY_TMP} CACHE FILEPATH INTERNAL)
|
||||
#message("[DEBUG] MYSQL ADD_INCLUDE_PATH : ${MYSQL_ADD_INCLUDE_PATH}")
|
||||
# set LIBRARY_DIR
|
||||
execute_process(
|
||||
COMMAND "${MYSQL_CONFIG}" --libs_r
|
||||
OUTPUT_VARIABLE MY_TMP
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(MYSQL_ADD_LIBRARIES "")
|
||||
string(REGEX MATCHALL "-l[^ ]*" MYSQL_LIB_LIST "${MY_TMP}")
|
||||
foreach(LIB ${MYSQL_LIB_LIST})
|
||||
string(REGEX REPLACE "[ ]*-l([^ ]*)" "\\1" LIB "${LIB}")
|
||||
list(APPEND MYSQL_ADD_LIBRARIES "${LIB}")
|
||||
#message("[DEBUG] MYSQL ADD_LIBRARIES : ${MYSQL_ADD_LIBRARIES}")
|
||||
endforeach(LIB ${MYSQL_LIB_LIST})
|
||||
|
||||
set(MYSQL_ADD_LIBRARIES_PATH "")
|
||||
string(REGEX MATCHALL "-L[^ ]*" MYSQL_LIBDIR_LIST "${MY_TMP}")
|
||||
foreach(LIB ${MYSQL_LIBDIR_LIST})
|
||||
string(REGEX REPLACE "[ ]*-L([^ ]*)" "\\1" LIB "${LIB}")
|
||||
list(APPEND MYSQL_ADD_LIBRARIES_PATH "${LIB}")
|
||||
#message("[DEBUG] MYSQL ADD_LIBRARIES_PATH : ${MYSQL_ADD_LIBRARIES_PATH}")
|
||||
endforeach(LIB ${MYSQL_LIBS})
|
||||
|
||||
else(MYSQL_CONFIG)
|
||||
set(MYSQL_ADD_LIBRARIES "")
|
||||
list(APPEND MYSQL_ADD_LIBRARIES "mysqlclient_r")
|
||||
endif(MYSQL_CONFIG)
|
||||
endif(UNIX)
|
||||
|
||||
set(_MYSQL_ROOT_PATHS)
|
||||
|
||||
if(WIN32)
|
||||
# read environment variables and change \ to /
|
||||
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" PROGRAM_FILES_32)
|
||||
file(TO_CMAKE_PATH "$ENV{ProgramW6432}" PROGRAM_FILES_64)
|
||||
|
||||
cmake_host_system_information(
|
||||
RESULT
|
||||
_MYSQL_ROOT_HINTS_SUBKEYS
|
||||
QUERY
|
||||
WINDOWS_REGISTRY
|
||||
"HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB" SUBKEYS
|
||||
VIEW BOTH
|
||||
)
|
||||
list(SORT _MYSQL_ROOT_HINTS_SUBKEYS COMPARE NATURAL ORDER DESCENDING)
|
||||
|
||||
set(_MYSQL_ROOT_HINTS_REGISTRY_LOCATIONS)
|
||||
foreach(subkey IN LISTS _MYSQL_ROOT_HINTS_SUBKEYS)
|
||||
cmake_host_system_information(
|
||||
RESULT
|
||||
_MYSQL_ROOT_HINTS_REGISTRY_LOCATION
|
||||
QUERY
|
||||
WINDOWS_REGISTRY
|
||||
"HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\${subkey}" VALUE "Location"
|
||||
VIEW BOTH
|
||||
)
|
||||
list(APPEND _MYSQL_ROOT_HINTS_REGISTRY_LOCATIONS ${_MYSQL_ROOT_HINTS_REGISTRY_LOCATION})
|
||||
endforeach()
|
||||
|
||||
set(_MYSQL_ROOT_HINTS
|
||||
${_MYSQL_ROOT_HINTS}
|
||||
${_MYSQL_ROOT_HINTS_REGISTRY_LOCATIONS}
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MariaDB 10.4;INSTALLDIR]"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MariaDB 10.4 (x64);INSTALLDIR]"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MariaDB 10.5;INSTALLDIR]"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MariaDB 10.5 (x64);INSTALLDIR]"
|
||||
)
|
||||
|
||||
file(GLOB _MYSQL_ROOT_PATHS_VERSION_SUBDIRECTORIES
|
||||
LIST_DIRECTORIES TRUE
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server *"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server *"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server *"
|
||||
)
|
||||
|
||||
list(SORT _MYSQL_ROOT_PATHS_VERSION_SUBDIRECTORIES COMPARE NATURAL ORDER DESCENDING)
|
||||
|
||||
set(_MYSQL_ROOT_PATHS
|
||||
${_MYSQL_ROOT_PATHS}
|
||||
${_MYSQL_ROOT_PATHS_VERSION_SUBDIRECTORIES}
|
||||
"${PROGRAM_FILES_64}/MySQL"
|
||||
"${PROGRAM_FILES_32}/MySQL"
|
||||
"$ENV{SystemDrive}/MySQL"
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
find_path(MYSQL_INCLUDE_DIR
|
||||
NAMES
|
||||
mysql.h
|
||||
HINTS
|
||||
${_MYSQL_ROOT_HINTS}
|
||||
PATHS
|
||||
${MYSQL_ADD_INCLUDE_PATH}
|
||||
/usr/include
|
||||
/usr/include/mysql
|
||||
/usr/local/include
|
||||
/usr/local/include/mysql
|
||||
/usr/local/mysql/include
|
||||
${_MYSQL_ROOT_PATHS}
|
||||
PATH_SUFFIXES
|
||||
include
|
||||
include/mysql
|
||||
DOC
|
||||
"Specify the directory containing mysql.h."
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
foreach(LIB ${MYSQL_ADD_LIBRARIES})
|
||||
find_library(MYSQL_LIBRARY
|
||||
NAMES
|
||||
mysql libmysql ${LIB}
|
||||
PATHS
|
||||
${MYSQL_ADD_LIBRARIES_PATH}
|
||||
/usr/lib
|
||||
/usr/lib/mysql
|
||||
/usr/local/lib
|
||||
/usr/local/lib/mysql
|
||||
/usr/local/mysql/lib
|
||||
DOC "Specify the location of the mysql library here."
|
||||
)
|
||||
endforeach(LIB ${MYSQL_ADD_LIBRARY})
|
||||
endif(UNIX)
|
||||
|
||||
if(WIN32)
|
||||
find_library(MYSQL_LIBRARY
|
||||
NAMES
|
||||
libmysql libmariadb
|
||||
HINTS
|
||||
${_MYSQL_ROOT_HINTS}
|
||||
PATHS
|
||||
${MYSQL_ADD_LIBRARIES_PATH}
|
||||
${_MYSQL_ROOT_PATHS}
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
lib/opt
|
||||
DOC "Specify the location of the mysql library here."
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
# On Windows you typically don't need to include any extra libraries
|
||||
# to build MYSQL stuff.
|
||||
|
||||
if(NOT WIN32)
|
||||
find_library(MYSQL_EXTRA_LIBRARIES
|
||||
NAMES
|
||||
z zlib
|
||||
PATHS
|
||||
/usr/lib
|
||||
/usr/local/lib
|
||||
DOC
|
||||
"if more libraries are necessary to link in a MySQL client (typically zlib), specify them here."
|
||||
)
|
||||
else(NOT WIN32)
|
||||
set(MYSQL_EXTRA_LIBRARIES "")
|
||||
endif(NOT WIN32)
|
||||
|
||||
if(UNIX)
|
||||
find_program(MYSQL_EXECUTABLE mysql
|
||||
PATHS
|
||||
${MYSQL_CONFIG_PREFER_PATH}
|
||||
/usr/local/mysql/bin/
|
||||
/usr/local/bin/
|
||||
/usr/bin/
|
||||
DOC
|
||||
"path to your mysql binary."
|
||||
)
|
||||
endif(UNIX)
|
||||
|
||||
if(WIN32)
|
||||
find_program(MYSQL_EXECUTABLE mysql
|
||||
HINTS
|
||||
${_MYSQL_ROOT_HINTS}
|
||||
PATHS
|
||||
${_MYSQL_ROOT_PATHS}
|
||||
PATH_SUFFIXES
|
||||
bin
|
||||
bin/opt
|
||||
DOC
|
||||
"path to your mysql binary."
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
unset(MySQL_lib_WANTED)
|
||||
unset(MySQL_binary_WANTED)
|
||||
set(MYSQL_REQUIRED_VARS "")
|
||||
foreach(_comp IN LISTS MySQL_FIND_COMPONENTS)
|
||||
if(_comp STREQUAL "lib")
|
||||
set(MySQL_${_comp}_WANTED TRUE)
|
||||
if(MySQL_FIND_REQUIRED_${_comp})
|
||||
list(APPEND MYSQL_REQUIRED_VARS "MYSQL_LIBRARY")
|
||||
list(APPEND MYSQL_REQUIRED_VARS "MYSQL_INCLUDE_DIR")
|
||||
endif()
|
||||
if(EXISTS "${MYSQL_LIBRARY}" AND EXISTS "${MYSQL_INCLUDE_DIR}")
|
||||
set(MySQL_${_comp}_FOUND TRUE)
|
||||
else()
|
||||
set(MySQL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
elseif(_comp STREQUAL "binary")
|
||||
set(MySQL_${_comp}_WANTED TRUE)
|
||||
if(MySQL_FIND_REQUIRED_${_comp})
|
||||
list(APPEND MYSQL_REQUIRED_VARS "MYSQL_EXECUTABLE")
|
||||
endif()
|
||||
if(EXISTS "${MYSQL_EXECUTABLE}" )
|
||||
set(MySQL_${_comp}_FOUND TRUE)
|
||||
else()
|
||||
set(MySQL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "${_comp} is not a valid MySQL component")
|
||||
set(MySQL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_comp)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(MySQL
|
||||
REQUIRED_VARS
|
||||
${MYSQL_REQUIRED_VARS}
|
||||
HANDLE_COMPONENTS
|
||||
FAIL_MESSAGE
|
||||
"Could not find the MySQL libraries! Please install the development libraries and headers"
|
||||
)
|
||||
unset(MYSQL_REQUIRED_VARS)
|
||||
|
||||
if(MYSQL_FOUND)
|
||||
if(MySQL_lib_WANTED AND MySQL_lib_FOUND)
|
||||
message(STATUS "Found MySQL library: ${MYSQL_LIBRARY}")
|
||||
message(STATUS "Found MySQL headers: ${MYSQL_INCLUDE_DIR}")
|
||||
endif()
|
||||
if(MySQL_binary_WANTED AND MySQL_binary_FOUND)
|
||||
message(STATUS "Found MySQL executable: ${MYSQL_EXECUTABLE}")
|
||||
endif()
|
||||
mark_as_advanced(MYSQL_FOUND MYSQL_LIBRARY MYSQL_EXTRA_LIBRARIES MYSQL_INCLUDE_DIR MYSQL_EXECUTABLE)
|
||||
|
||||
if(NOT TARGET MySQL::MySQL AND MySQL_lib_WANTED AND MySQL_lib_FOUND)
|
||||
add_library(MySQL::MySQL UNKNOWN IMPORTED)
|
||||
set_target_properties(MySQL::MySQL
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION
|
||||
"${MYSQL_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${MYSQL_INCLUDE_DIR}")
|
||||
endif()
|
||||
else()
|
||||
message(FATAL_ERROR "Could not find the MySQL libraries! Please install the development libraries and headers")
|
||||
endif()
|
||||
@@ -0,0 +1,821 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindOpenSSL
|
||||
-----------
|
||||
|
||||
Find the OpenSSL encryption library.
|
||||
|
||||
This module finds an installed OpenSSL library and determines its version.
|
||||
|
||||
.. versionadded:: 3.19
|
||||
When a version is requested, it can be specified as a simple value or as a
|
||||
range. For a detailed description of version range usage and capabilities,
|
||||
refer to the :command:`find_package` command.
|
||||
|
||||
.. versionadded:: 3.18
|
||||
Support for OpenSSL 3.0.
|
||||
|
||||
Optional COMPONENTS
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. versionadded:: 3.12
|
||||
|
||||
This module supports two optional COMPONENTS: ``Crypto`` and ``SSL``. Both
|
||||
components have associated imported targets, as described below.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
.. versionadded:: 3.4
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||
|
||||
``OpenSSL::SSL``
|
||||
The OpenSSL ``ssl`` library, if found.
|
||||
``OpenSSL::Crypto``
|
||||
The OpenSSL ``crypto`` library, if found.
|
||||
``OpenSSL::applink``
|
||||
.. versionadded:: 3.18
|
||||
|
||||
The OpenSSL ``applink`` components that might be need to be compiled into
|
||||
projects under MSVC. This target is available only if found OpenSSL version
|
||||
is not less than 0.9.8. By linking this target the above OpenSSL targets can
|
||||
be linked even if the project has different MSVC runtime configurations with
|
||||
the above OpenSSL targets. This target has no effect on platforms other than
|
||||
MSVC.
|
||||
|
||||
NOTE: Due to how ``INTERFACE_SOURCES`` are consumed by the consuming target,
|
||||
unless you certainly know what you are doing, it is always preferred to link
|
||||
``OpenSSL::applink`` target as ``PRIVATE`` and to make sure that this target is
|
||||
linked at most once for the whole dependency graph of any library or
|
||||
executable:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
target_link_libraries(myTarget PRIVATE OpenSSL::applink)
|
||||
|
||||
Otherwise you would probably encounter unexpected random problems when building
|
||||
and linking, as both the ISO C and the ISO C++ standard claims almost nothing
|
||||
about what a link process should be.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
``OPENSSL_FOUND``
|
||||
System has the OpenSSL library. If no components are requested it only
|
||||
requires the crypto library.
|
||||
``OPENSSL_INCLUDE_DIR``
|
||||
The OpenSSL include directory.
|
||||
``OPENSSL_CRYPTO_LIBRARY``
|
||||
The OpenSSL crypto library.
|
||||
``OPENSSL_CRYPTO_LIBRARIES``
|
||||
The OpenSSL crypto library and its dependencies.
|
||||
``OPENSSL_SSL_LIBRARY``
|
||||
The OpenSSL SSL library.
|
||||
``OPENSSL_SSL_LIBRARIES``
|
||||
The OpenSSL SSL library and its dependencies.
|
||||
``OPENSSL_LIBRARIES``
|
||||
All OpenSSL libraries and their dependencies.
|
||||
``OPENSSL_VERSION``
|
||||
This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``).
|
||||
``OPENSSL_APPLINK_SOURCE``
|
||||
The sources in the target ``OpenSSL::applink`` that is mentioned above. This
|
||||
variable shall always be undefined if found openssl version is less than
|
||||
0.9.8 or if platform is not MSVC.
|
||||
|
||||
Hints
|
||||
^^^^^
|
||||
|
||||
The following variables may be set to control search behavior:
|
||||
|
||||
``OPENSSL_ROOT_DIR``
|
||||
Set to the root directory of an OpenSSL installation.
|
||||
|
||||
``OPENSSL_USE_STATIC_LIBS``
|
||||
.. versionadded:: 3.4
|
||||
|
||||
Set to ``TRUE`` to look for static libraries.
|
||||
|
||||
``OPENSSL_MSVC_STATIC_RT``
|
||||
.. versionadded:: 3.5
|
||||
|
||||
Set to ``TRUE`` to choose the MT version of the lib.
|
||||
|
||||
``ENV{PKG_CONFIG_PATH}``
|
||||
On UNIX-like systems, ``pkg-config`` is used to locate the system OpenSSL.
|
||||
Set the ``PKG_CONFIG_PATH`` environment variable to look in alternate
|
||||
locations. Useful on multi-lib systems.
|
||||
#]=======================================================================]
|
||||
|
||||
macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library)
|
||||
unset(_OpenSSL_extra_static_deps)
|
||||
if(UNIX AND
|
||||
(("${ssl_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") OR
|
||||
("${crypto_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")))
|
||||
set(_OpenSSL_has_dependencies TRUE)
|
||||
unset(_OpenSSL_has_dependency_zlib)
|
||||
if(OPENSSL_USE_STATIC_LIBS)
|
||||
set(_OpenSSL_libs "${_OPENSSL_STATIC_LIBRARIES}")
|
||||
set(_OpenSSL_ldflags_other "${_OPENSSL_STATIC_LDFLAGS_OTHER}")
|
||||
else()
|
||||
set(_OpenSSL_libs "${_OPENSSL_LIBRARIES}")
|
||||
set(_OpenSSL_ldflags_other "${_OPENSSL_LDFLAGS_OTHER}")
|
||||
endif()
|
||||
if(_OpenSSL_libs)
|
||||
unset(_OpenSSL_has_dependency_dl)
|
||||
foreach(_OPENSSL_DEP_LIB IN LISTS _OpenSSL_libs)
|
||||
if (_OPENSSL_DEP_LIB STREQUAL "ssl" OR _OPENSSL_DEP_LIB STREQUAL "crypto")
|
||||
# ignoring: these are the targets
|
||||
elseif(_OPENSSL_DEP_LIB STREQUAL CMAKE_DL_LIBS)
|
||||
set(_OpenSSL_has_dependency_dl TRUE)
|
||||
elseif(_OPENSSL_DEP_LIB STREQUAL "z")
|
||||
find_package(ZLIB)
|
||||
set(_OpenSSL_has_dependency_zlib TRUE)
|
||||
else()
|
||||
list(APPEND _OpenSSL_extra_static_deps "${_OPENSSL_DEP_LIB}")
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_OPENSSL_DEP_LIB)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(_OpenSSL_has_dependency_dl TRUE)
|
||||
endif()
|
||||
if(_OpenSSL_ldflags_other)
|
||||
unset(_OpenSSL_has_dependency_threads)
|
||||
foreach(_OPENSSL_DEP_LDFLAG IN LISTS _OpenSSL_ldflags_other)
|
||||
if (_OPENSSL_DEP_LDFLAG STREQUAL "-pthread")
|
||||
set(_OpenSSL_has_dependency_threads TRUE)
|
||||
find_package(Threads)
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_OPENSSL_DEP_LDFLAG)
|
||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(_OpenSSL_has_dependency_threads TRUE)
|
||||
find_package(Threads)
|
||||
endif()
|
||||
unset(_OpenSSL_libs)
|
||||
unset(_OpenSSL_ldflags_other)
|
||||
else()
|
||||
set(_OpenSSL_has_dependencies FALSE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
function(_OpenSSL_add_dependencies libraries_var)
|
||||
if(_OpenSSL_has_dependency_zlib)
|
||||
list(APPEND ${libraries_var} ${ZLIB_LIBRARY})
|
||||
endif()
|
||||
if(_OpenSSL_has_dependency_threads)
|
||||
list(APPEND ${libraries_var} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
if(_OpenSSL_has_dependency_dl)
|
||||
list(APPEND ${libraries_var} ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
list(APPEND ${libraries_var} ${_OpenSSL_extra_static_deps})
|
||||
set(${libraries_var} ${${libraries_var}} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(_OpenSSL_target_add_dependencies target)
|
||||
if(_OpenSSL_has_dependencies)
|
||||
if(_OpenSSL_has_dependency_zlib)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB )
|
||||
endif()
|
||||
if(_OpenSSL_has_dependency_threads)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads)
|
||||
endif()
|
||||
if(_OpenSSL_has_dependency_dl)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} )
|
||||
endif()
|
||||
if(_OpenSSL_extra_static_deps)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${_OpenSSL_extra_static_deps})
|
||||
endif()
|
||||
endif()
|
||||
if(WIN32 AND OPENSSL_USE_STATIC_LIBS)
|
||||
if(WINCE)
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ws2 )
|
||||
else()
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ws2_32 )
|
||||
endif()
|
||||
set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES crypt32 )
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if (UNIX)
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(_OPENSSL QUIET openssl)
|
||||
endif ()
|
||||
|
||||
# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
|
||||
if(OPENSSL_USE_STATIC_LIBS)
|
||||
set(_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
if(MSVC)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
else()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "QNX" AND
|
||||
CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL "7.0" AND CMAKE_SYSTEM_VERSION VERSION_LESS "7.1" AND
|
||||
OpenSSL_FIND_VERSION VERSION_GREATER_EQUAL "1.1" AND OpenSSL_FIND_VERSION VERSION_LESS "1.2")
|
||||
# QNX 7.0.x provides openssl 1.0.2 and 1.1.1 in parallel:
|
||||
# * openssl 1.0.2: libcrypto.so.2 and libssl.so.2, headers under usr/include/openssl
|
||||
# * openssl 1.1.1: libcrypto1_1.so.2.1 and libssl1_1.so.2.1, header under usr/include/openssl1_1
|
||||
# See http://www.qnx.com/developers/articles/rel_6726_0.html
|
||||
set(_OPENSSL_FIND_PATH_SUFFIX "openssl1_1")
|
||||
set(_OPENSSL_NAME_POSTFIX "1_1")
|
||||
else()
|
||||
set(_OPENSSL_FIND_PATH_SUFFIX "include")
|
||||
endif()
|
||||
|
||||
if (OPENSSL_ROOT_DIR OR NOT "$ENV{OPENSSL_ROOT_DIR}" STREQUAL "")
|
||||
set(_OPENSSL_ROOT_HINTS HINTS ${OPENSSL_ROOT_DIR} ENV OPENSSL_ROOT_DIR)
|
||||
set(_OPENSSL_ROOT_PATHS NO_DEFAULT_PATH)
|
||||
elseif (MSVC)
|
||||
# http://www.slproweb.com/products/Win32OpenSSL.html
|
||||
set(_OPENSSL_MSI_INSTALL_GUIDS "")
|
||||
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
|
||||
if(TRINITY_SYSTEM_PROCESSOR STREQUAL "arm64")
|
||||
set(_arch "Win64-ARM")
|
||||
set(_OPENSSL_MSI_INSTALL_GUIDS "99C28AFA-6419-40B1-B88D-32B810BB4234")
|
||||
else()
|
||||
set(_arch "Win64")
|
||||
set(_OPENSSL_MSI_INSTALL_GUIDS "117551DB-A110-4BBD-BB05-CFE0BCB3ED31" "50A9FBE2-0F8C-4D5D-97A4-A63A71C4EA1E")
|
||||
endif()
|
||||
file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
|
||||
set(_OPENSSL_ROOT_HINTS HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]")
|
||||
else()
|
||||
set(_arch "Win32")
|
||||
set(_progfiles_x86 "ProgramFiles(x86)")
|
||||
if(NOT "$ENV{${_progfiles_x86}}" STREQUAL "")
|
||||
# under windows 64 bit machine
|
||||
file(TO_CMAKE_PATH "$ENV{${_progfiles_x86}}" _programfiles)
|
||||
else()
|
||||
# under windows 32 bit machine
|
||||
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _programfiles)
|
||||
endif()
|
||||
set(_OPENSSL_ROOT_HINTS HINTS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]")
|
||||
set(_OPENSSL_MSI_INSTALL_GUIDS "A1EEC576-43B9-4E75-9E02-03DA542D2A38" "31D2408A-9CAE-4988-9EC3-F40FDE7D6AE5")
|
||||
endif()
|
||||
|
||||
# If OpenSSL was installed using .msi package instead of .exe, Inno Setup registry values are not written to Uninstall\OpenSSL
|
||||
# but because it is only a shim around Inno Setup it does write the location of uninstaller which we can use to determine path
|
||||
foreach(_OPENSSL_MSI_INSTALL_GUID IN LISTS _OPENSSL_MSI_INSTALL_GUIDS)
|
||||
get_filename_component(_OPENSSL_MSI_INSTALL_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Inno Setup MSIs\\${_OPENSSL_MSI_INSTALL_GUID};]" DIRECTORY)
|
||||
if(NOT _OPENSSL_MSI_INSTALL_PATH STREQUAL "/")
|
||||
list(INSERT _OPENSSL_ROOT_HINTS 2 ${_OPENSSL_MSI_INSTALL_PATH})
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_OPENSSL_MSI_INSTALL_GUIDS)
|
||||
|
||||
set(_OPENSSL_ROOT_PATHS
|
||||
PATHS
|
||||
"${_programfiles}/OpenSSL"
|
||||
"${_programfiles}/OpenSSL-${_arch}"
|
||||
"C:/OpenSSL/"
|
||||
"C:/OpenSSL-${_arch}/"
|
||||
)
|
||||
unset(_programfiles)
|
||||
unset(_arch)
|
||||
endif ()
|
||||
|
||||
if(HOMEBREW_PREFIX)
|
||||
list(APPEND _OPENSSL_ROOT_HINTS
|
||||
"${HOMEBREW_PREFIX}/opt/openssl@3")
|
||||
endif()
|
||||
|
||||
set(_OPENSSL_ROOT_HINTS_AND_PATHS
|
||||
${_OPENSSL_ROOT_HINTS}
|
||||
${_OPENSSL_ROOT_PATHS}
|
||||
)
|
||||
|
||||
find_path(OPENSSL_INCLUDE_DIR
|
||||
NAMES
|
||||
openssl/ssl.h
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_INCLUDEDIR}
|
||||
${_OPENSSL_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_FIND_PATH_SUFFIX}
|
||||
)
|
||||
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
if(MSVC)
|
||||
# /MD and /MDd are the standard values - if someone wants to use
|
||||
# others, the libnames have to change here too
|
||||
# use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
|
||||
# enable OPENSSL_MSVC_STATIC_RT to get the libs build /MT (Multithreaded no-DLL)
|
||||
# In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix:
|
||||
# * MD for dynamic-release
|
||||
# * MDd for dynamic-debug
|
||||
# * MT for static-release
|
||||
# * MTd for static-debug
|
||||
|
||||
# Implementation details:
|
||||
# We are using the libraries located in the VC subdir instead of the parent directory even though :
|
||||
# libeay32MD.lib is identical to ../libeay32.lib, and
|
||||
# ssleay32MD.lib is identical to ../ssleay32.lib
|
||||
# enable OPENSSL_USE_STATIC_LIBS to use the static libs located in lib/VC/static
|
||||
|
||||
if (OPENSSL_MSVC_STATIC_RT)
|
||||
set(_OPENSSL_MSVC_RT_MODE "MT")
|
||||
else ()
|
||||
set(_OPENSSL_MSVC_RT_MODE "MD")
|
||||
endif ()
|
||||
|
||||
# Since OpenSSL 1.1, lib names are like libcrypto32MTd.lib and libssl32MTd.lib
|
||||
if( "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8" )
|
||||
set(_OPENSSL_MSVC_ARCH_SUFFIX "64")
|
||||
if(TRINITY_SYSTEM_PROCESSOR STREQUAL "arm64")
|
||||
set(_OPENSSL_MSVC_ARCH_DIRECTORY "arm64")
|
||||
else()
|
||||
set(_OPENSSL_MSVC_ARCH_DIRECTORY "x64")
|
||||
endif()
|
||||
else()
|
||||
set(_OPENSSL_MSVC_ARCH_SUFFIX "32")
|
||||
set(_OPENSSL_MSVC_ARCH_DIRECTORY "x86")
|
||||
endif()
|
||||
|
||||
if(OPENSSL_USE_STATIC_LIBS)
|
||||
set(_OPENSSL_STATIC_SUFFIX
|
||||
"_static"
|
||||
)
|
||||
set(_OPENSSL_PATH_SUFFIXES
|
||||
"lib/VC/static"
|
||||
"VC/static"
|
||||
"lib"
|
||||
)
|
||||
else()
|
||||
set(_OPENSSL_STATIC_SUFFIX
|
||||
""
|
||||
)
|
||||
set(_OPENSSL_PATH_SUFFIXES
|
||||
"lib/VC"
|
||||
"VC"
|
||||
"lib"
|
||||
)
|
||||
endif ()
|
||||
|
||||
find_library(LIB_EAY_DEBUG
|
||||
NAMES
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
"lib/VC/${_OPENSSL_MSVC_ARCH_DIRECTORY}/${_OPENSSL_MSVC_RT_MODE}d"
|
||||
)
|
||||
|
||||
if(NOT LIB_EAY_DEBUG)
|
||||
find_library(LIB_EAY_DEBUG
|
||||
NAMES
|
||||
# When OpenSSL is built with default options, the static library name is suffixed with "_static".
|
||||
# Looking the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the
|
||||
# import library of "libcrypto.dll".
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}d
|
||||
libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libeay32${_OPENSSL_STATIC_SUFFIX}d
|
||||
crypto${_OPENSSL_STATIC_SUFFIX}d
|
||||
# When OpenSSL is built with the "-static" option, only the static build is produced,
|
||||
# and it is not suffixed with "_static".
|
||||
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libcrypto${_OPENSSL_MSVC_RT_MODE}d
|
||||
libcryptod
|
||||
libeay32${_OPENSSL_MSVC_RT_MODE}d
|
||||
libeay32d
|
||||
cryptod
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_PATH_SUFFIXES}
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(LIB_EAY_RELEASE
|
||||
NAMES
|
||||
# When OpenSSL is built with default options, the static library name is suffixed with "_static".
|
||||
# Looking the "libcrypto_static.lib" with a higher priority than "libcrypto.lib" which is the
|
||||
# import library of "libcrypto.dll".
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libcrypto${_OPENSSL_STATIC_SUFFIX}
|
||||
libeay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libeay32${_OPENSSL_STATIC_SUFFIX}
|
||||
crypto${_OPENSSL_STATIC_SUFFIX}
|
||||
# When OpenSSL is built with the "-static" option, only the static build is produced,
|
||||
# and it is not suffixed with "_static".
|
||||
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libcrypto${_OPENSSL_MSVC_RT_MODE}
|
||||
libcrypto
|
||||
libeay32${_OPENSSL_MSVC_RT_MODE}
|
||||
libeay32
|
||||
crypto
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_PATH_SUFFIXES}
|
||||
"lib/VC/${_OPENSSL_MSVC_ARCH_DIRECTORY}/${_OPENSSL_MSVC_RT_MODE}"
|
||||
)
|
||||
|
||||
find_library(SSL_EAY_DEBUG
|
||||
NAMES
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
"lib/VC/${_OPENSSL_MSVC_ARCH_DIRECTORY}/${_OPENSSL_MSVC_RT_MODE}d"
|
||||
)
|
||||
|
||||
if(NOT SSL_EAY_DEBUG)
|
||||
find_library(SSL_EAY_DEBUG
|
||||
NAMES
|
||||
# When OpenSSL is built with default options, the static library name is suffixed with "_static".
|
||||
# Looking the "libssl_static.lib" with a higher priority than "libssl.lib" which is the
|
||||
# import library of "libssl.dll".
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}d
|
||||
ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
ssleay32${_OPENSSL_STATIC_SUFFIX}d
|
||||
ssl${_OPENSSL_STATIC_SUFFIX}d
|
||||
# When OpenSSL is built with the "-static" option, only the static build is produced,
|
||||
# and it is not suffixed with "_static".
|
||||
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
|
||||
libssl${_OPENSSL_MSVC_RT_MODE}d
|
||||
libssld
|
||||
ssleay32${_OPENSSL_MSVC_RT_MODE}d
|
||||
ssleay32d
|
||||
ssld
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_PATH_SUFFIXES}
|
||||
)
|
||||
endif()
|
||||
|
||||
find_library(SSL_EAY_RELEASE
|
||||
NAMES
|
||||
# When OpenSSL is built with default options, the static library name is suffixed with "_static".
|
||||
# Looking the "libssl_static.lib" with a higher priority than "libssl.lib" which is the
|
||||
# import library of "libssl.dll".
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libssl${_OPENSSL_STATIC_SUFFIX}
|
||||
ssleay32${_OPENSSL_STATIC_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
ssleay32${_OPENSSL_STATIC_SUFFIX}
|
||||
ssl${_OPENSSL_STATIC_SUFFIX}
|
||||
# When OpenSSL is built with the "-static" option, only the static build is produced,
|
||||
# and it is not suffixed with "_static".
|
||||
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
|
||||
libssl${_OPENSSL_MSVC_RT_MODE}
|
||||
libssl
|
||||
ssleay32${_OPENSSL_MSVC_RT_MODE}
|
||||
ssleay32
|
||||
ssl
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
${_OPENSSL_PATH_SUFFIXES}
|
||||
"lib/VC/${_OPENSSL_MSVC_ARCH_DIRECTORY}/${_OPENSSL_MSVC_RT_MODE}"
|
||||
)
|
||||
|
||||
set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}")
|
||||
set(LIB_EAY_LIBRARY_RELEASE "${LIB_EAY_RELEASE}")
|
||||
set(SSL_EAY_LIBRARY_DEBUG "${SSL_EAY_DEBUG}")
|
||||
set(SSL_EAY_LIBRARY_RELEASE "${SSL_EAY_RELEASE}")
|
||||
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(LIB_EAY)
|
||||
select_library_configurations(SSL_EAY)
|
||||
|
||||
mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE
|
||||
SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE)
|
||||
set(OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY} )
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY} )
|
||||
elseif(MINGW)
|
||||
# same player, for MinGW
|
||||
set(LIB_EAY_NAMES crypto libeay32)
|
||||
set(SSL_EAY_NAMES ssl ssleay32)
|
||||
find_library(LIB_EAY
|
||||
NAMES
|
||||
${LIB_EAY_NAMES}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
"lib/MinGW"
|
||||
"lib"
|
||||
"lib64"
|
||||
)
|
||||
|
||||
find_library(SSL_EAY
|
||||
NAMES
|
||||
${SSL_EAY_NAMES}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES
|
||||
"lib/MinGW"
|
||||
"lib"
|
||||
"lib64"
|
||||
)
|
||||
|
||||
mark_as_advanced(SSL_EAY LIB_EAY)
|
||||
set(OPENSSL_SSL_LIBRARY ${SSL_EAY} )
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} )
|
||||
unset(LIB_EAY_NAMES)
|
||||
unset(SSL_EAY_NAMES)
|
||||
else()
|
||||
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
|
||||
find_library(LIB_EAY
|
||||
NAMES
|
||||
libcrypto
|
||||
libeay32
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_LIBDIR}
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
)
|
||||
|
||||
find_library(SSL_EAY
|
||||
NAMES
|
||||
libssl
|
||||
ssleay32
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_LIBDIR}
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
)
|
||||
|
||||
mark_as_advanced(SSL_EAY LIB_EAY)
|
||||
set(OPENSSL_SSL_LIBRARY ${SSL_EAY} )
|
||||
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} )
|
||||
endif()
|
||||
else()
|
||||
|
||||
find_library(OPENSSL_SSL_LIBRARY
|
||||
NAMES
|
||||
ssl${_OPENSSL_NAME_POSTFIX}
|
||||
ssleay32
|
||||
ssleay32MD
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_LIBDIR}
|
||||
${_OPENSSL_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES
|
||||
lib lib64
|
||||
)
|
||||
|
||||
find_library(OPENSSL_CRYPTO_LIBRARY
|
||||
NAMES
|
||||
crypto${_OPENSSL_NAME_POSTFIX}
|
||||
NAMES_PER_DIR
|
||||
${_OPENSSL_ROOT_HINTS_AND_PATHS}
|
||||
HINTS
|
||||
${_OPENSSL_LIBDIR}
|
||||
${_OPENSSL_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES
|
||||
lib lib64
|
||||
)
|
||||
|
||||
mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
|
||||
|
||||
endif()
|
||||
|
||||
set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY})
|
||||
set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
|
||||
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} )
|
||||
_OpenSSL_test_and_find_dependencies("${OPENSSL_SSL_LIBRARY}" "${OPENSSL_CRYPTO_LIBRARY}")
|
||||
if(_OpenSSL_has_dependencies)
|
||||
_OpenSSL_add_dependencies( OPENSSL_SSL_LIBRARIES )
|
||||
_OpenSSL_add_dependencies( OPENSSL_CRYPTO_LIBRARIES )
|
||||
_OpenSSL_add_dependencies( OPENSSL_LIBRARIES )
|
||||
endif()
|
||||
|
||||
function(from_hex HEX DEC)
|
||||
string(TOUPPER "${HEX}" HEX)
|
||||
set(_res 0)
|
||||
string(LENGTH "${HEX}" _strlen)
|
||||
|
||||
while (_strlen GREATER 0)
|
||||
math(EXPR _res "${_res} * 16")
|
||||
string(SUBSTRING "${HEX}" 0 1 NIBBLE)
|
||||
string(SUBSTRING "${HEX}" 1 -1 HEX)
|
||||
if (NIBBLE STREQUAL "A")
|
||||
math(EXPR _res "${_res} + 10")
|
||||
elseif (NIBBLE STREQUAL "B")
|
||||
math(EXPR _res "${_res} + 11")
|
||||
elseif (NIBBLE STREQUAL "C")
|
||||
math(EXPR _res "${_res} + 12")
|
||||
elseif (NIBBLE STREQUAL "D")
|
||||
math(EXPR _res "${_res} + 13")
|
||||
elseif (NIBBLE STREQUAL "E")
|
||||
math(EXPR _res "${_res} + 14")
|
||||
elseif (NIBBLE STREQUAL "F")
|
||||
math(EXPR _res "${_res} + 15")
|
||||
else()
|
||||
math(EXPR _res "${_res} + ${NIBBLE}")
|
||||
endif()
|
||||
|
||||
string(LENGTH "${HEX}" _strlen)
|
||||
endwhile()
|
||||
|
||||
set(${DEC} ${_res} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
|
||||
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
|
||||
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
|
||||
|
||||
if(openssl_version_str)
|
||||
# The version number is encoded as 0xMNNFFPPS: major minor fix patch status
|
||||
# The status gives if this is a developer or prerelease and is ignored here.
|
||||
# Major, minor, and fix directly translate into the version numbers shown in
|
||||
# the string. The patch field translates to the single character suffix that
|
||||
# indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so
|
||||
# on.
|
||||
|
||||
string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
|
||||
"\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}")
|
||||
list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
|
||||
list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
|
||||
from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR)
|
||||
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
|
||||
from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX)
|
||||
list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)
|
||||
|
||||
if (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
|
||||
from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
|
||||
# 96 is the ASCII code of 'a' minus 1
|
||||
math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96")
|
||||
unset(_tmp)
|
||||
# Once anyone knows how OpenSSL would call the patch versions beyond 'z'
|
||||
# this should be updated to handle that, too. This has not happened yet
|
||||
# so it is simply ignored here for now.
|
||||
string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
|
||||
endif ()
|
||||
|
||||
set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
|
||||
else ()
|
||||
# Since OpenSSL 3.0.0, the new version format is MAJOR.MINOR.PATCH and
|
||||
# a new OPENSSL_VERSION_STR macro contains exactly that
|
||||
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSL_VERSION_STR
|
||||
REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_STR[\t ]+\"([0-9])+\\.([0-9])+\\.([0-9])+\".*")
|
||||
string(REGEX REPLACE "^.*OPENSSL_VERSION_STR[\t ]+\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*$"
|
||||
"\\1" OPENSSL_VERSION_STR "${OPENSSL_VERSION_STR}")
|
||||
|
||||
set(OPENSSL_VERSION "${OPENSSL_VERSION_STR}")
|
||||
|
||||
unset(OPENSSL_VERSION_STR)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
foreach(_comp IN LISTS OpenSSL_FIND_COMPONENTS)
|
||||
if(_comp STREQUAL "Crypto")
|
||||
if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
|
||||
(EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR
|
||||
EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR
|
||||
EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
|
||||
)
|
||||
set(OpenSSL_${_comp}_FOUND TRUE)
|
||||
else()
|
||||
set(OpenSSL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
elseif(_comp STREQUAL "SSL")
|
||||
if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
|
||||
(EXISTS "${OPENSSL_SSL_LIBRARY}" OR
|
||||
EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
|
||||
EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
|
||||
)
|
||||
set(OpenSSL_${_comp}_FOUND TRUE)
|
||||
else()
|
||||
set(OpenSSL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "${_comp} is not a valid OpenSSL component")
|
||||
set(OpenSSL_${_comp}_FOUND FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
unset(_comp)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(OpenSSL
|
||||
REQUIRED_VARS
|
||||
OPENSSL_CRYPTO_LIBRARY
|
||||
OPENSSL_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
OPENSSL_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
FAIL_MESSAGE
|
||||
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
|
||||
)
|
||||
|
||||
mark_as_advanced(OPENSSL_INCLUDE_DIR)
|
||||
|
||||
if(OPENSSL_FOUND)
|
||||
if(NOT TARGET OpenSSL::Crypto AND
|
||||
(EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR
|
||||
EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR
|
||||
EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
|
||||
)
|
||||
add_library(OpenSSL::Crypto UNKNOWN IMPORTED)
|
||||
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
|
||||
if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}")
|
||||
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}")
|
||||
endif()
|
||||
if(EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
|
||||
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||
IMPORTED_LOCATION_RELEASE "${LIB_EAY_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
if(EXISTS "${LIB_EAY_LIBRARY_DEBUG}")
|
||||
set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(OpenSSL::Crypto PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
|
||||
IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
_OpenSSL_target_add_dependencies(OpenSSL::Crypto)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET OpenSSL::SSL AND
|
||||
(EXISTS "${OPENSSL_SSL_LIBRARY}" OR
|
||||
EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
|
||||
EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
|
||||
)
|
||||
add_library(OpenSSL::SSL UNKNOWN IMPORTED)
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
|
||||
if(EXISTS "${OPENSSL_SSL_LIBRARY}")
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||
IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}")
|
||||
endif()
|
||||
if(EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
|
||||
set_property(TARGET OpenSSL::SSL APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS RELEASE)
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
|
||||
IMPORTED_LOCATION_RELEASE "${SSL_EAY_LIBRARY_RELEASE}")
|
||||
endif()
|
||||
if(EXISTS "${SSL_EAY_LIBRARY_DEBUG}")
|
||||
set_property(TARGET OpenSSL::SSL APPEND PROPERTY
|
||||
IMPORTED_CONFIGURATIONS DEBUG)
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
|
||||
IMPORTED_LOCATION_DEBUG "${SSL_EAY_LIBRARY_DEBUG}")
|
||||
endif()
|
||||
if(TARGET OpenSSL::Crypto)
|
||||
set_target_properties(OpenSSL::SSL PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)
|
||||
endif()
|
||||
_OpenSSL_target_add_dependencies(OpenSSL::SSL)
|
||||
endif()
|
||||
|
||||
if("${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}" VERSION_GREATER_EQUAL "0.9.8")
|
||||
if(MSVC)
|
||||
if(EXISTS "${OPENSSL_INCLUDE_DIR}")
|
||||
set(_OPENSSL_applink_paths PATHS ${OPENSSL_INCLUDE_DIR})
|
||||
endif()
|
||||
find_file(OPENSSL_APPLINK_SOURCE
|
||||
NAMES
|
||||
openssl/applink.c
|
||||
${_OPENSSL_applink_paths}
|
||||
NO_DEFAULT_PATH)
|
||||
if(OPENSSL_APPLINK_SOURCE)
|
||||
set(_OPENSSL_applink_interface_srcs ${OPENSSL_APPLINK_SOURCE})
|
||||
endif()
|
||||
endif()
|
||||
if(NOT TARGET OpenSSL::applink)
|
||||
add_library(OpenSSL::applink INTERFACE IMPORTED)
|
||||
set_property(TARGET OpenSSL::applink APPEND
|
||||
PROPERTY INTERFACE_SOURCES
|
||||
${_OPENSSL_applink_interface_srcs})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Restore the original find library ordering
|
||||
if(OPENSSL_USE_STATIC_LIBS)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
endif()
|
||||
|
||||
unset(_OPENSSL_FIND_PATH_SUFFIX)
|
||||
unset(_OPENSSL_NAME_POSTFIX)
|
||||
unset(_OpenSSL_extra_static_deps)
|
||||
unset(_OpenSSL_has_dependency_dl)
|
||||
unset(_OpenSSL_has_dependency_threads)
|
||||
unset(_OpenSSL_has_dependency_zlib)
|
||||
@@ -0,0 +1,35 @@
|
||||
if (CMAKE_VERSION VERSION_LESS "3.16.0")
|
||||
if (MSVC)
|
||||
# Specify the maximum PreCompiled Header memory allocation limit
|
||||
# Fixes a compiler-problem when using PCH - the /Ym flag is adjusted by the compiler in MSVC2012,
|
||||
# hence we need to set an upper limit with /Zm to avoid discrepancies)
|
||||
# (And yes, this is a verified, unresolved bug with MSVC... *sigh*)
|
||||
#
|
||||
# Note: This workaround was verified to be required on MSVC 2017 as well
|
||||
set(COTIRE_PCH_MEMORY_SCALING_FACTOR 500)
|
||||
endif ()
|
||||
|
||||
include(cotire)
|
||||
|
||||
function(ADD_CXX_PCH TARGET_NAME_LIST PCH_HEADER)
|
||||
# Use the header for every target
|
||||
foreach (TARGET_NAME ${TARGET_NAME_LIST})
|
||||
# Disable unity builds
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES COTIRE_ADD_UNITY_BUILD OFF)
|
||||
|
||||
# Set the prefix header
|
||||
set_target_properties(${TARGET_NAME} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT ${PCH_HEADER})
|
||||
|
||||
# Workaround for cotire bug: https://github.com/sakra/cotire/issues/138
|
||||
set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 14)
|
||||
endforeach ()
|
||||
|
||||
cotire(${TARGET_NAME_LIST})
|
||||
endfunction(ADD_CXX_PCH)
|
||||
else()
|
||||
function(ADD_CXX_PCH TARGET_NAME_LIST PCH_HEADER)
|
||||
foreach(TARGET_NAME ${TARGET_NAME_LIST})
|
||||
target_precompile_headers(${TARGET_NAME} PRIVATE ${PCH_HEADER})
|
||||
endforeach()
|
||||
endfunction(ADD_CXX_PCH)
|
||||
endif()
|
||||
@@ -0,0 +1,51 @@
|
||||
# Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
|
||||
#
|
||||
# This file is free software; as a special exception the author gives
|
||||
# unlimited permission to copy and/or distribute it, with or without
|
||||
# modifications, as long as this notice is preserved.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
macro(GroupSources dir)
|
||||
# Skip this if WITH_SOURCE_TREE is not set (empty string).
|
||||
if (NOT ${WITH_SOURCE_TREE} STREQUAL "")
|
||||
# Include all header and c files
|
||||
file(GLOB_RECURSE elements RELATIVE ${dir} *.h *.hpp *.c *.cpp *.cc)
|
||||
|
||||
foreach(element ${elements})
|
||||
# Extract filename and directory
|
||||
get_filename_component(element_name ${element} NAME)
|
||||
get_filename_component(element_dir ${element} DIRECTORY)
|
||||
|
||||
if (NOT ${element_dir} STREQUAL "")
|
||||
# If the file is in a subdirectory use it as source group.
|
||||
if (${WITH_SOURCE_TREE} STREQUAL "flat")
|
||||
# Build flat structure by using only the first subdirectory.
|
||||
string(FIND ${element_dir} "/" delemiter_pos)
|
||||
if (NOT ${delemiter_pos} EQUAL -1)
|
||||
string(SUBSTRING ${element_dir} 0 ${delemiter_pos} group_name)
|
||||
source_group("${group_name}" FILES ${dir}/${element})
|
||||
else()
|
||||
# Build hierarchical structure.
|
||||
# File is in root directory.
|
||||
source_group("${element_dir}" FILES ${dir}/${element})
|
||||
endif()
|
||||
else()
|
||||
# Use the full hierarchical structure to build source_groups.
|
||||
string(REPLACE "/" "\\" group_name ${element_dir})
|
||||
source_group("${group_name}" FILES ${dir}/${element})
|
||||
endif()
|
||||
else()
|
||||
# If the file is in the root directory, place it in the root source_group.
|
||||
source_group("\\" FILES ${dir}/${element})
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
if (WITH_SOURCE_TREE STREQUAL "hierarchical-folders")
|
||||
# Use folders
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
endif()
|
||||
Reference in New Issue
Block a user