solocraft + dynamicxp
This commit is contained in:
21
cmake/compiler/clang/settings.cmake
Normal file
21
cmake/compiler/clang/settings.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
# Set build-directive (used in core to tell which buildtype we used)
|
||||
add_definitions(-D_BUILD_DIRECTIVE='"${CMAKE_BUILD_TYPE}"')
|
||||
|
||||
if(WITH_WARNINGS)
|
||||
set(WARNING_FLAGS "-W -Wall -Wextra -Winit-self -Wfatal-errors -Wno-mismatched-tags")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -Woverloaded-virtual")
|
||||
message(STATUS "Clang: All warnings enabled")
|
||||
endif()
|
||||
|
||||
if(WITH_COREDEBUG)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
||||
message(STATUS "Clang: Debug-flags set (-g3)")
|
||||
endif()
|
||||
|
||||
# -Wno-narrowing needed to suppress a warning in g3d
|
||||
# -Wno-deprecated-register is needed to suppress 185 gsoap warnings on Unix systems.
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-narrowing -Wno-deprecated-register")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=1")
|
||||
|
||||
30
cmake/compiler/gcc/settings.cmake
Normal file
30
cmake/compiler/gcc/settings.cmake
Normal file
@@ -0,0 +1,30 @@
|
||||
# Set build-directive (used in core to tell which buildtype we used)
|
||||
add_definitions(-D_BUILD_DIRECTIVE='"${CMAKE_BUILD_TYPE}"')
|
||||
|
||||
add_definitions(-fno-delete-null-pointer-checks)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||
message(STATUS "GCC: Enabled c++11 support")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
||||
message(STATUS "GCC: Enabled C99 support")
|
||||
|
||||
if(PLATFORM EQUAL 32)
|
||||
# Required on 32-bit systems to enable SSE2 (standard on x64)
|
||||
add_definitions(-msse2 -mfpmath=sse)
|
||||
endif()
|
||||
add_definitions(-DHAVE_SSE2 -D__SSE2__)
|
||||
message(STATUS "GCC: SSE2 flags forced")
|
||||
|
||||
if( WITH_WARNINGS )
|
||||
add_definitions(-Wall -Wfatal-errors -Wextra)
|
||||
message(STATUS "GCC: All warnings enabled")
|
||||
else()
|
||||
add_definitions(--no-warnings)
|
||||
message(STATUS "GCC: All warnings disabled")
|
||||
endif()
|
||||
|
||||
if( WITH_COREDEBUG )
|
||||
add_definitions(-ggdb3)
|
||||
message(STATUS "GCC: Debug-flags set (-ggdb3)")
|
||||
endif()
|
||||
18
cmake/compiler/icc/settings.cmake
Normal file
18
cmake/compiler/icc/settings.cmake
Normal file
@@ -0,0 +1,18 @@
|
||||
# Set build-directive (used in core to tell which buildtype we used)
|
||||
add_definitions(-D_BUILD_DIRECTIVE="'${CMAKE_BUILD_TYPE}'")
|
||||
|
||||
if(PLATFORM EQUAL 32)
|
||||
add_definitions(-axSSE2)
|
||||
else()
|
||||
add_definitions(-xSSE2)
|
||||
endif()
|
||||
|
||||
if( WITH_WARNINGS )
|
||||
add_definitions(-w1)
|
||||
message(STATUS "ICC: All warnings enabled")
|
||||
endif()
|
||||
|
||||
if( WITH_COREDEBUG )
|
||||
add_definitions(-g)
|
||||
message(STATUS "ICC: Debug-flag set (-g)")
|
||||
endif()
|
||||
27
cmake/compiler/mingw/settings.cmake
Normal file
27
cmake/compiler/mingw/settings.cmake
Normal file
@@ -0,0 +1,27 @@
|
||||
# set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
# Set build-directive (used in core to tell which buildtype we used)
|
||||
add_definitions(-D_BUILD_DIRECTIVE=\\"${CMAKE_BUILD_TYPE}\\")
|
||||
|
||||
if(PLATFORM EQUAL 32)
|
||||
# Required on 32-bit systems to enable SSE2 (standard on x64)
|
||||
set(SSE_FLAGS "-msse2 -mfpmath=sse")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SSE_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SSE_FLAGS}")
|
||||
endif()
|
||||
add_definitions(-DHAVE_SSE2 -D__SSE2__)
|
||||
message(STATUS "GCC: SFMT enabled, SSE2 flags forced")
|
||||
|
||||
if( WITH_WARNINGS )
|
||||
set(WARNING_FLAGS "-W -Wall -Wextra -Winit-self -Winvalid-pch -Wfatal-errors")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} -Woverloaded-virtual")
|
||||
message(STATUS "GCC: All warnings enabled")
|
||||
endif()
|
||||
|
||||
if( WITH_COREDEBUG )
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
|
||||
message(STATUS "GCC: Debug-flags set (-g3)")
|
||||
endif()
|
||||
104
cmake/compiler/msvc/settings.cmake
Normal file
104
cmake/compiler/msvc/settings.cmake
Normal file
@@ -0,0 +1,104 @@
|
||||
# set up output paths for executable binaries (.exe-files, and .dll-files on DLL-capable platforms)
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
set(MSVC_EXPECTED_VERSION 19.10)
|
||||
set(MSVC_EXPECTED_VERSION_STRING "MSVC 2017")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_EXPECTED_VERSION)
|
||||
message(FATAL_ERROR "MSVC: TrinityCore requires version ${MSVC_EXPECTED_VERSION} (${MSVC_EXPECTED_VERSION_STRING}) to build but found ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
endif()
|
||||
|
||||
# set up output paths ofr static libraries etc (commented out - shown here as an example only)
|
||||
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
||||
|
||||
if(PLATFORM EQUAL 64)
|
||||
# This definition is necessary to work around a bug with Intellisense described
|
||||
# here: http://tinyurl.com/2cb428. Syntax highlighting is important for proper
|
||||
# debugger functionality.
|
||||
add_definitions("-D_WIN64")
|
||||
message(STATUS "MSVC: 64-bit platform, enforced -D_WIN64 parameter")
|
||||
|
||||
else()
|
||||
# mark 32 bit executables large address aware so they can use > 2GB address space
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
|
||||
message(STATUS "MSVC: Enabled large address awareness")
|
||||
|
||||
add_definitions(/arch:SSE2)
|
||||
message(STATUS "MSVC: Enabled SSE2 support")
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /SAFESEH:NO")
|
||||
message(STATUS "MSVC: Disabled Safe Exception Handlers for debug builds")
|
||||
endif()
|
||||
|
||||
# Set build-directive (used in core to tell which buildtype we used)
|
||||
if(CMAKE_MAKE_PROGRAM MATCHES "nmake")
|
||||
add_definitions(-D_BUILD_DIRECTIVE=\\"${CMAKE_BUILD_TYPE}\\")
|
||||
else()
|
||||
add_definitions(-D_BUILD_DIRECTIVE=\\"$(ConfigurationName)\\")
|
||||
endif()
|
||||
|
||||
# multithreaded compiling on VS
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
|
||||
|
||||
if((PLATFORM EQUAL 64) OR (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0))
|
||||
# Enable extended object support
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
||||
message(STATUS "MSVC: Enabled increased number of sections in object files")
|
||||
endif()
|
||||
|
||||
# /Zc:throwingNew.
|
||||
# When you specify Zc:throwingNew on the command line, it instructs the compiler to assume
|
||||
# that the program will eventually be linked with a conforming operator new implementation,
|
||||
# and can omit all of these extra null checks from your program.
|
||||
# http://blogs.msdn.com/b/vcblog/archive/2015/08/06/new-in-vs-2015-zc-throwingnew.aspx
|
||||
if(NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0))
|
||||
# makes this flag a requirement to build TC at all
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:throwingNew")
|
||||
endif()
|
||||
|
||||
# Define _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES - eliminates the warning by changing the strcpy call to strcpy_s, which prevents buffer overruns
|
||||
add_definitions(-D_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES)
|
||||
message(STATUS "MSVC: Overloaded standard names")
|
||||
|
||||
# Ignore warnings about older, less secure functions
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
message(STATUS "MSVC: Disabled NON-SECURE warnings")
|
||||
|
||||
# Ignore warnings about POSIX deprecation
|
||||
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
|
||||
message(STATUS "MSVC: Disabled POSIX warnings")
|
||||
|
||||
# Ignore specific warnings
|
||||
# C4351: new behavior: elements of array 'x' will be default initialized
|
||||
# C4091: 'typedef ': ignored on left of '' when no variable is declared
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4351 /wd4091")
|
||||
|
||||
if(NOT WITH_WARNINGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267 /wd4619 /wd4512")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267 /wd4619 /wd4512 /wd4522")
|
||||
message(STATUS "MSVC: Disabled generic compiletime warnings")
|
||||
endif()
|
||||
|
||||
# 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*)
|
||||
string(REGEX REPLACE "/Zm[0-9]+ *" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zm500" CACHE STRING "" FORCE)
|
||||
|
||||
# Enable and treat as errors the following warnings to easily detect virtual function signature failures:
|
||||
# 'function' : member function does not override any base class virtual member function
|
||||
# 'virtual_function' : no override available for virtual member function from base 'class'; function is hidden
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4263 /we4264 /EHsc")
|
||||
|
||||
# Disable incremental linking in debug builds.
|
||||
# To prevent linking getting stuck (which might be fixed in a later VS version).
|
||||
macro(DisableIncrementalLinking variable)
|
||||
string(REGEX REPLACE "/INCREMENTAL *" "" ${variable} "${${variable}}")
|
||||
set(${variable} "${${variable}} /INCREMENTAL:NO")
|
||||
endmacro()
|
||||
|
||||
DisableIncrementalLinking(CMAKE_EXE_LINKER_FLAGS_DEBUG)
|
||||
DisableIncrementalLinking(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO)
|
||||
DisableIncrementalLinking(CMAKE_SHARED_LINKER_FLAGS_DEBUG)
|
||||
DisableIncrementalLinking(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO)
|
||||
82
cmake/genrev.cmake
Normal file
82
cmake/genrev.cmake
Normal file
@@ -0,0 +1,82 @@
|
||||
# Copyright (C) 2008-2012 Trinity <http://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.
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/macros/EnsureVersion.cmake)
|
||||
|
||||
set(_REQUIRED_GIT_VERSION "1.7")
|
||||
|
||||
find_program(_GIT_EXEC
|
||||
NAMES
|
||||
git git.cmd
|
||||
HINTS
|
||||
ENV PATH
|
||||
DOC "git installation path"
|
||||
)
|
||||
|
||||
if(_GIT_EXEC)
|
||||
execute_process(
|
||||
COMMAND "${_GIT_EXEC}" --version
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE _GIT_VERSION
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
# make sure we're using minimum the required version of git, so the "dirty-testing" will work properly
|
||||
ensure_version( "${_REQUIRED_GIT_VERSION}" "${_GIT_VERSION}" _GIT_VERSION_OK)
|
||||
endif()
|
||||
|
||||
if(_GIT_VERSION_OK)
|
||||
execute_process(
|
||||
COMMAND "${_GIT_EXEC}" describe --tags --dirty --long --abbrev=10
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE rev_info
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
execute_process(
|
||||
COMMAND "${_GIT_EXEC}" show -s --format=%ci
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE rev_date
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
else()
|
||||
message("")
|
||||
message(STATUS "WARNING - Missing or outdated git - did you forget to install a recent version?")
|
||||
message(STATUS "WARNING - Observe that for revision hash/date to work you need at least version ${_REQUIRED_GIT_VERSION}")
|
||||
endif()
|
||||
|
||||
# Last minute check - ensure that we have a proper revision
|
||||
# If everything above fails (means the user has erased the git revision control directory or removed the origin/HEAD tag)
|
||||
if(NOT rev_info)
|
||||
# No valid ways available to find/set the revision/hash, so let's force some defaults
|
||||
message(STATUS "WARNING - Missing repository tags - you may need to pull tags with git fetch -t")
|
||||
message(STATUS "WARNING - Continuing anyway - note that the versionstring will be set to 0000-00-00 00:00:00 (Archived)")
|
||||
set(rev_date "0000-00-00 00:00:00 +0000")
|
||||
set(rev_hash "Archived")
|
||||
else()
|
||||
# Extract information required to build a proper versionstring
|
||||
string(REGEX REPLACE init-|[0-9]+-g "" rev_hash ${rev_info})
|
||||
endif()
|
||||
|
||||
# Its not set during initial run
|
||||
if(NOT BUILDDIR)
|
||||
set(BUILDDIR ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
# Create the actual revision_data.h file from the above params
|
||||
if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}")
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/revision_data.h.in.cmake"
|
||||
"${BUILDDIR}/revision_data.h"
|
||||
@ONLY
|
||||
)
|
||||
set(rev_hash_cached "${rev_hash}" CACHE INTERNAL "Cached commit-hash")
|
||||
endif()
|
||||
71
cmake/macros/AutoCollect.cmake
Normal file
71
cmake/macros/AutoCollect.cmake
Normal file
@@ -0,0 +1,71 @@
|
||||
# Copyright (C) 2008-2016 TrinityCore <http://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()
|
||||
23
cmake/macros/CheckBuildDir.cmake
Normal file
23
cmake/macros/CheckBuildDir.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
# Copyright (C) 2008-2012 Trinity <http://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()
|
||||
14
cmake/macros/CheckPlatform.cmake
Normal file
14
cmake/macros/CheckPlatform.cmake
Normal file
@@ -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()
|
||||
115
cmake/macros/EnsureVersion.cmake
Normal file
115
cmake/macros/EnsureVersion.cmake
Normal file
@@ -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)
|
||||
202
cmake/macros/FindBackward.cmake
Normal file
202
cmake/macros/FindBackward.cmake
Normal file
@@ -0,0 +1,202 @@
|
||||
#
|
||||
# BackwardMacros.cmake
|
||||
# Copyright 2013 Google Inc. All Rights Reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
###############################################################################
|
||||
# OPTIONS
|
||||
###############################################################################
|
||||
|
||||
set(STACK_WALKING_UNWIND TRUE CACHE BOOL
|
||||
"Use compiler's unwind API")
|
||||
set(STACK_WALKING_BACKTRACE FALSE CACHE BOOL
|
||||
"Use backtrace from (e)glibc for stack walking")
|
||||
|
||||
set(STACK_DETAILS_AUTO_DETECT TRUE CACHE BOOL
|
||||
"Auto detect backward's stack details dependencies")
|
||||
|
||||
set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE CACHE BOOL
|
||||
"Use backtrace from (e)glibc for symbols resolution")
|
||||
set(STACK_DETAILS_DW FALSE CACHE BOOL
|
||||
"Use libdw to read debug info")
|
||||
set(STACK_DETAILS_BFD FALSE CACHE BOOL
|
||||
"Use libbfd to read debug info")
|
||||
set(STACK_DETAILS_DWARF FALSE CACHE BOOL
|
||||
"Use libdwarf/libelf to read debug info")
|
||||
|
||||
set(BACKWARD_TESTS FALSE CACHE BOOL "Enable tests")
|
||||
|
||||
###############################################################################
|
||||
# CONFIGS
|
||||
###############################################################################
|
||||
if (${STACK_DETAILS_AUTO_DETECT})
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# find libdw
|
||||
find_path(LIBDW_INCLUDE_DIR NAMES "elfutils/libdw.h" "elfutils/libdwfl.h")
|
||||
find_library(LIBDW_LIBRARY dw)
|
||||
set(LIBDW_INCLUDE_DIRS ${LIBDW_INCLUDE_DIR} )
|
||||
set(LIBDW_LIBRARIES ${LIBDW_LIBRARY} )
|
||||
find_package_handle_standard_args(libdw DEFAULT_MSG
|
||||
LIBDW_LIBRARY LIBDW_INCLUDE_DIR)
|
||||
mark_as_advanced(LIBDW_INCLUDE_DIR LIBDW_LIBRARY)
|
||||
|
||||
# find libbfd
|
||||
find_path(LIBBFD_INCLUDE_DIR NAMES "bfd.h")
|
||||
find_path(LIBDL_INCLUDE_DIR NAMES "dlfcn.h")
|
||||
find_library(LIBBFD_LIBRARY bfd)
|
||||
find_library(LIBDL_LIBRARY dl)
|
||||
set(LIBBFD_INCLUDE_DIRS ${LIBBFD_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR})
|
||||
set(LIBBFD_LIBRARIES ${LIBBFD_LIBRARY} ${LIBDL_LIBRARY})
|
||||
find_package_handle_standard_args(libbfd DEFAULT_MSG
|
||||
LIBBFD_LIBRARY LIBBFD_INCLUDE_DIR
|
||||
LIBDL_LIBRARY LIBDL_INCLUDE_DIR)
|
||||
mark_as_advanced(LIBBFD_INCLUDE_DIR LIBBFD_LIBRARY
|
||||
LIBDL_INCLUDE_DIR LIBDL_LIBRARY)
|
||||
|
||||
# find libdwarf
|
||||
find_path(LIBDWARF_INCLUDE_DIR NAMES "libdwarf.h" PATH_SUFFIXES libdwarf)
|
||||
find_path(LIBELF_INCLUDE_DIR NAMES "libelf.h")
|
||||
find_path(LIBDL_INCLUDE_DIR NAMES "dlfcn.h")
|
||||
find_library(LIBDWARF_LIBRARY dwarf)
|
||||
find_library(LIBELF_LIBRARY elf)
|
||||
find_library(LIBDL_LIBRARY dl)
|
||||
set(LIBDWARF_INCLUDE_DIRS ${LIBDWARF_INCLUDE_DIR} ${LIBELF_INCLUDE_DIR} ${LIBDL_INCLUDE_DIR})
|
||||
set(LIBDWARF_LIBRARIES ${LIBDWARF_LIBRARY} ${LIBELF_LIBRARY} ${LIBDL_LIBRARY})
|
||||
find_package_handle_standard_args(libdwarf DEFAULT_MSG
|
||||
LIBDWARF_LIBRARY LIBDWARF_INCLUDE_DIR
|
||||
LIBELF_LIBRARY LIBELF_INCLUDE_DIR
|
||||
LIBDL_LIBRARY LIBDL_INCLUDE_DIR)
|
||||
mark_as_advanced(LIBDWARF_INCLUDE_DIR LIBDWARF_LIBRARY
|
||||
LIBELF_INCLUDE_DIR LIBELF_LIBRARY
|
||||
LIBDL_INCLUDE_DIR LIBDL_LIBRARY)
|
||||
|
||||
if (LIBDW_FOUND)
|
||||
LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBDW_INCLUDE_DIRS})
|
||||
LIST(APPEND _BACKWARD_LIBRARIES ${LIBDW_LIBRARIES})
|
||||
set(STACK_DETAILS_DW TRUE)
|
||||
set(STACK_DETAILS_BFD FALSE)
|
||||
set(STACK_DETAILS_DWARF FALSE)
|
||||
set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE)
|
||||
elseif(LIBBFD_FOUND)
|
||||
LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBBFD_INCLUDE_DIRS})
|
||||
LIST(APPEND _BACKWARD_LIBRARIES ${LIBBFD_LIBRARIES})
|
||||
|
||||
# If we attempt to link against static bfd, make sure to link its dependencies, too
|
||||
get_filename_component(bfd_lib_ext "${LIBBFD_LIBRARY}" EXT)
|
||||
if (bfd_lib_ext STREQUAL "${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
list(APPEND _BACKWARD_LIBRARIES iberty z)
|
||||
endif()
|
||||
|
||||
set(STACK_DETAILS_DW FALSE)
|
||||
set(STACK_DETAILS_BFD TRUE)
|
||||
set(STACK_DETAILS_DWARF FALSE)
|
||||
set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE)
|
||||
elseif(LIBDWARF_FOUND)
|
||||
LIST(APPEND _BACKWARD_INCLUDE_DIRS ${LIBDWARF_INCLUDE_DIRS})
|
||||
LIST(APPEND BACKWARD_LIBRARIES ${LIBDWARF_LIBRARIES})
|
||||
|
||||
set(STACK_DETAILS_DW FALSE)
|
||||
set(STACK_DETAILS_BFD FALSE)
|
||||
set(STACK_DETAILS_DWARF TRUE)
|
||||
set(STACK_DETAILS_BACKTRACE_SYMBOL FALSE)
|
||||
else()
|
||||
set(STACK_DETAILS_DW FALSE)
|
||||
set(STACK_DETAILS_BFD FALSE)
|
||||
set(STACK_DETAILS_DWARF FALSE)
|
||||
set(STACK_DETAILS_BACKTRACE_SYMBOL TRUE)
|
||||
endif()
|
||||
else()
|
||||
if (STACK_DETAILS_DW)
|
||||
LIST(APPEND _BACKWARD_LIBRARIES dw)
|
||||
endif()
|
||||
|
||||
if (STACK_DETAILS_BFD)
|
||||
LIST(APPEND _BACKWARD_LIBRARIES bfd dl)
|
||||
endif()
|
||||
|
||||
if (STACK_DETAILS_DWARF)
|
||||
LIST(APPEND _BACKWARD_LIBRARIES dwarf elf dl)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
macro(map_definitions var_prefix define_prefix)
|
||||
foreach(def ${ARGN})
|
||||
if (${${var_prefix}${def}})
|
||||
LIST(APPEND _BACKWARD_DEFINITIONS "${define_prefix}${def}=1")
|
||||
else()
|
||||
LIST(APPEND _BACKWARD_DEFINITIONS "${define_prefix}${def}=0")
|
||||
endif()
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
if (NOT _BACKWARD_DEFINITIONS)
|
||||
map_definitions("STACK_WALKING_" "BACKWARD_HAS_" UNWIND BACKTRACE)
|
||||
map_definitions("STACK_DETAILS_" "BACKWARD_HAS_" BACKTRACE_SYMBOL DW BFD DWARF)
|
||||
endif()
|
||||
|
||||
set(BACKWARD_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
set(BACKWARD_HAS_EXTERNAL_LIBRARIES FALSE)
|
||||
set(FIND_PACKAGE_REQUIRED_VARS BACKWARD_INCLUDE_DIR)
|
||||
if(DEFINED _BACKWARD_LIBRARIES)
|
||||
set(BACKWARD_HAS_EXTERNAL_LIBRARIES TRUE)
|
||||
list(APPEND FIND_PACKAGE_REQUIRED_VARS _BACKWARD_LIBRARIES)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Backward
|
||||
REQUIRED_VARS ${FIND_PACKAGE_REQUIRED_VARS}
|
||||
)
|
||||
list(APPEND _BACKWARD_INCLUDE_DIRS ${BACKWARD_INCLUDE_DIR})
|
||||
|
||||
macro(add_backward target)
|
||||
target_include_directories(${target} PRIVATE ${BACKWARD_INCLUDE_DIRS})
|
||||
set_property(TARGET ${target} APPEND PROPERTY COMPILE_DEFINITIONS ${BACKWARD_DEFINITIONS})
|
||||
set_property(TARGET ${target} APPEND PROPERTY LINK_LIBRARIES ${BACKWARD_LIBRARIES})
|
||||
endmacro()
|
||||
|
||||
set(BACKWARD_INCLUDE_DIRS ${_BACKWARD_INCLUDE_DIRS} CACHE INTERNAL "_BACKWARD_INCLUDE_DIRS")
|
||||
set(BACKWARD_DEFINITIONS ${_BACKWARD_DEFINITIONS} CACHE INTERNAL "BACKWARD_DEFINITIONS")
|
||||
set(BACKWARD_LIBRARIES ${_BACKWARD_LIBRARIES} CACHE INTERNAL "BACKWARD_LIBRARIES")
|
||||
mark_as_advanced(BACKWARD_INCLUDE_DIRS BACKWARD_DEFINITIONS BACKWARD_LIBRARIES)
|
||||
|
||||
# Expand each definition in BACKWARD_DEFINITIONS to its own cmake var and export
|
||||
# to outer scope
|
||||
foreach(var ${BACKWARD_DEFINITIONS})
|
||||
string(REPLACE "=" ";" var_as_list ${var})
|
||||
list(GET var_as_list 0 var_name)
|
||||
list(GET var_as_list 1 var_value)
|
||||
set(${var_name} ${var_value})
|
||||
mark_as_advanced(${var_name})
|
||||
endforeach()
|
||||
|
||||
if (NOT TARGET Backward::Backward)
|
||||
add_library(Backward::Backward INTERFACE IMPORTED)
|
||||
set_target_properties(Backward::Backward PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${BACKWARD_INCLUDE_DIRS}"
|
||||
INTERFACE_COMPILE_DEFINITIONS "${BACKWARD_DEFINITIONS}"
|
||||
)
|
||||
if(BACKWARD_HAS_EXTERNAL_LIBRARIES)
|
||||
set_target_properties(Backward::Backward PROPERTIES
|
||||
INTERFACE_LINK_LIBRARIES "${BACKWARD_LIBRARIES}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
1285
cmake/macros/FindBoost.cmake
Normal file
1285
cmake/macros/FindBoost.cmake
Normal file
File diff suppressed because it is too large
Load Diff
38
cmake/macros/FindGit.cmake
Normal file
38
cmake/macros/FindGit.cmake
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/macros/EnsureVersion.cmake)
|
||||
|
||||
set(_REQUIRED_GIT_VERSION "1.7")
|
||||
|
||||
find_program(GIT_EXECUTABLE
|
||||
NAMES
|
||||
git git.cmd
|
||||
HINTS
|
||||
ENV PATH
|
||||
DOC "Full path to git commandline client"
|
||||
)
|
||||
MARK_AS_ADVANCED(GIT_EXECUTABLE)
|
||||
|
||||
if(NOT GIT_EXECUTABLE)
|
||||
message(FATAL_ERROR "
|
||||
Git was NOT FOUND on your system - did you forget to install a recent version, or setting the path to it?
|
||||
Observe that for revision hash/date to work you need at least version ${_REQUIRED_GIT_VERSION}")
|
||||
else()
|
||||
message(STATUS "Found git binary : ${GIT_EXECUTABLE}")
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" --version
|
||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE _GIT_VERSION
|
||||
ERROR_QUIET
|
||||
)
|
||||
|
||||
# make sure we're using minimum the required version of git, so the "dirty-testing" will work properly
|
||||
ensure_version( "${_REQUIRED_GIT_VERSION}" "${_GIT_VERSION}" _GIT_VERSION_OK)
|
||||
|
||||
# throw an error if we don't have a recent enough version of git...
|
||||
if(NOT _GIT_VERSION_OK)
|
||||
message(STATUS "Git version too old : ${_GIT_VERSION}")
|
||||
message(FATAL_ERROR "
|
||||
Git was found but is OUTDATED - did you forget to install a recent version, or setting the path to it?
|
||||
Observe that for revision hash/date to work you need at least version ${_REQUIRED_GIT_VERSION}")
|
||||
endif()
|
||||
endif()
|
||||
290
cmake/macros/FindMySQL.cmake
Normal file
290
cmake/macros/FindMySQL.cmake
Normal file
@@ -0,0 +1,290 @@
|
||||
#
|
||||
# Find the MySQL client includes and library
|
||||
#
|
||||
|
||||
# This module defines
|
||||
# MYSQL_INCLUDE_DIR, where to find mysql.h
|
||||
# MYSQL_LIBRARIES, the libraries to link against to connect to MySQL
|
||||
# MYSQL_EXECUTABLE, the MySQL executable.
|
||||
# MYSQL_FOUND, if false, you cannot build anything that requires MySQL.
|
||||
|
||||
# also defined, but not for general use are
|
||||
# MYSQL_LIBRARY, where to find the MySQL library.
|
||||
|
||||
set( MYSQL_FOUND 0 )
|
||||
|
||||
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
|
||||
exec_program(${MYSQL_CONFIG}
|
||||
ARGS --include
|
||||
OUTPUT_VARIABLE MY_TMP
|
||||
)
|
||||
|
||||
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
|
||||
exec_program(${MYSQL_CONFIG}
|
||||
ARGS --libs_r
|
||||
OUTPUT_VARIABLE MY_TMP
|
||||
)
|
||||
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 )
|
||||
|
||||
if( WIN32 )
|
||||
# read environment variables and change \ to /
|
||||
SET(PROGRAM_FILES_32 $ENV{ProgramFiles})
|
||||
if (${PROGRAM_FILES_32})
|
||||
STRING(REPLACE "\\\\" "/" PROGRAM_FILES_32 ${PROGRAM_FILES_32})
|
||||
endif(${PROGRAM_FILES_32})
|
||||
|
||||
SET(PROGRAM_FILES_64 $ENV{ProgramW6432})
|
||||
if (${PROGRAM_FILES_64})
|
||||
STRING(REPLACE "\\\\" "/" PROGRAM_FILES_64 ${PROGRAM_FILES_64})
|
||||
endif(${PROGRAM_FILES_64})
|
||||
endif ( WIN32 )
|
||||
|
||||
find_path(MYSQL_INCLUDE_DIR
|
||||
NAMES
|
||||
mysql.h
|
||||
PATHS
|
||||
${MYSQL_ADD_INCLUDE_PATH}
|
||||
/usr/include
|
||||
/usr/include/mysql
|
||||
/usr/local/include
|
||||
/usr/local/include/mysql
|
||||
/usr/local/mysql/include
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.7/include"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.6/include"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.5/include"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.1/include"
|
||||
"${PROGRAM_FILES_64}/MySQL/include"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.7/include"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.6/include"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.5/include"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.1/include"
|
||||
"${PROGRAM_FILES_32}/MySQL/include"
|
||||
"C:/MySQL/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.7;Location]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.6;Location]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.5;Location]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.7;Location]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.6;Location]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.5;Location]/include"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.1;Location]/include"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.7/include"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.6/include"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.5/include"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.1/include"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.7/include"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.6/include"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.5/include"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.1/include"
|
||||
"c:/msys/local/include"
|
||||
"$ENV{MYSQL_ROOT}/include"
|
||||
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
|
||||
PATHS
|
||||
${MYSQL_ADD_LIBRARIES_PATH}
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.7/lib"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.6/lib"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.5/lib"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.1/lib"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.7/lib/opt"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.6/lib/opt"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.5/lib/opt"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.1/lib/opt"
|
||||
"${PROGRAM_FILES_64}/MySQL/lib"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.7/lib"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.6/lib"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.5/lib"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.1/lib"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.7/lib/opt"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.6/lib/opt"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.5/lib/opt"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.1/lib/opt"
|
||||
"${PROGRAM_FILES_32}/MySQL/lib"
|
||||
"C:/MySQL/lib/debug"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.7;Location]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.6;Location]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.5;Location]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.7;Location]/lib/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.6;Location]/lib/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.5;Location]/lib/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/lib/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.7;Location]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.6;Location]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.5;Location]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.1;Location]/lib"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.7;Location]/lib/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.6;Location]/lib/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.5;Location]/lib/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.1;Location]/lib/opt"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.7/lib/opt"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.6/lib/opt"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.5/lib/opt"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.1/lib/opt"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.7/lib/opt"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.6/lib/opt"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.5/lib/opt"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.1/lib/opt"
|
||||
"c:/msys/local/include"
|
||||
"$ENV{MYSQL_ROOT}/lib"
|
||||
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
|
||||
PATHS
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.7/bin"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.6/bin"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.5/bin"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.1/bin"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.7/bin/opt"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.6/bin/opt"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.5/bin/opt"
|
||||
"${PROGRAM_FILES_64}/MySQL/MySQL Server 5.1/bin/opt"
|
||||
"${PROGRAM_FILES_64}/MySQL/bin"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.7/bin"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.6/bin"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.5/bin"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.1/bin"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.7/bin/opt"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.6/bin/opt"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.5/bin/opt"
|
||||
"${PROGRAM_FILES_32}/MySQL/MySQL Server 5.1/bin/opt"
|
||||
"${PROGRAM_FILES_32}/MySQL/bin"
|
||||
"C:/MySQL/bin/debug"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.7;Location]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.6;Location]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.5;Location]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.7;Location]/bin/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.6;Location]/bin/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.5;Location]/bin/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/bin/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.7;Location]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.6;Location]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.5;Location]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.1;Location]/bin"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.7;Location]/bin/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.6;Location]/bin/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.5;Location]/bin/opt"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.1;Location]/bin/opt"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.7/bin/opt"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.6/bin/opt"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.5/bin/opt"
|
||||
"$ENV{ProgramFiles}/MySQL/MySQL Server 5.1/bin/opt"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.7/bin/opt"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.6/bin/opt"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.5/bin/opt"
|
||||
"$ENV{SystemDrive}/MySQL/MySQL Server 5.1/bin/opt"
|
||||
"c:/msys/local/include"
|
||||
"$ENV{MYSQL_ROOT}/bin"
|
||||
DOC
|
||||
"path to your mysql binary."
|
||||
)
|
||||
endif( WIN32 )
|
||||
|
||||
if( MYSQL_LIBRARY )
|
||||
if( MYSQL_INCLUDE_DIR )
|
||||
set( MYSQL_FOUND 1 )
|
||||
message(STATUS "Found MySQL library: ${MYSQL_LIBRARY}")
|
||||
message(STATUS "Found MySQL headers: ${MYSQL_INCLUDE_DIR}")
|
||||
else( MYSQL_INCLUDE_DIR )
|
||||
message(FATAL_ERROR "Could not find MySQL headers! Please install the development libraries and headers")
|
||||
endif( MYSQL_INCLUDE_DIR )
|
||||
if( MYSQL_EXECUTABLE )
|
||||
message(STATUS "Found MySQL executable: ${MYSQL_EXECUTABLE}")
|
||||
endif( MYSQL_EXECUTABLE )
|
||||
mark_as_advanced( MYSQL_FOUND MYSQL_LIBRARY MYSQL_EXTRA_LIBRARIES MYSQL_INCLUDE_DIR MYSQL_EXECUTABLE)
|
||||
else( MYSQL_LIBRARY )
|
||||
message(FATAL_ERROR "Could not find the MySQL libraries! Please install the development libraries and headers")
|
||||
endif( MYSQL_LIBRARY )
|
||||
238
cmake/macros/FindOpenSSL.cmake
Normal file
238
cmake/macros/FindOpenSSL.cmake
Normal file
@@ -0,0 +1,238 @@
|
||||
# - Try to find the OpenSSL encryption library
|
||||
# Once done this will define
|
||||
#
|
||||
# OPENSSL_ROOT_DIR - Set this variable to the root installation of OpenSSL
|
||||
#
|
||||
# Read-Only variables:
|
||||
# OPENSSL_FOUND - system has the OpenSSL library
|
||||
# OPENSSL_INCLUDE_DIR - the OpenSSL include directory
|
||||
# OPENSSL_LIBRARIES - The libraries needed to use OpenSSL
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2006-2009 Kitware, Inc.
|
||||
# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
|
||||
# Copyright 2009-2010 Mathieu Malaterre <mathieu.malaterre@gmail.com>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distributed this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
# http://www.slproweb.com/products/Win32OpenSSL.html
|
||||
|
||||
set(OPENSSL_EXPECTED_VERSION "1.0")
|
||||
set(OPENSSL_MAX_VERSION "1.2")
|
||||
|
||||
SET(_OPENSSL_ROOT_HINTS
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
|
||||
)
|
||||
|
||||
IF(PLATFORM EQUAL 64)
|
||||
SET(_OPENSSL_ROOT_PATHS
|
||||
"${PROJECT_SOURCE_DIR}/../Requirements/Win64/OpenSSL_1.1.1e_Win64"
|
||||
#"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;InstallLocation]"
|
||||
#"C:/OpenSSL-Win64/"
|
||||
#"C:/OpenSSL/"
|
||||
)
|
||||
ELSE()
|
||||
SET(_OPENSSL_ROOT_PATHS
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;InstallLocation]"
|
||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;InstallLocation]"
|
||||
"C:/OpenSSL/"
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
FIND_PATH(OPENSSL_ROOT_DIR
|
||||
NAMES
|
||||
include/openssl/ssl.h
|
||||
HINTS
|
||||
${_OPENSSL_ROOT_HINTS}
|
||||
PATHS
|
||||
${_OPENSSL_ROOT_PATHS}
|
||||
)
|
||||
MARK_AS_ADVANCED(OPENSSL_ROOT_DIR)
|
||||
|
||||
# Re-use the previous path:
|
||||
FIND_PATH(OPENSSL_INCLUDE_DIR openssl/ssl.h
|
||||
${OPENSSL_ROOT_DIR}/include
|
||||
)
|
||||
|
||||
IF(WIN32 AND NOT CYGWIN)
|
||||
# MINGW should go here too
|
||||
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
|
||||
# TODO: handle /MT and static lib
|
||||
# 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 eventhough :
|
||||
# libeay32MD.lib is identical to ../libeay32.lib, and
|
||||
# ssleay32MD.lib is identical to ../ssleay32.lib
|
||||
|
||||
# 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")
|
||||
else()
|
||||
set(_OPENSSL_MSVC_ARCH_SUFFIX "32")
|
||||
endif()
|
||||
|
||||
FIND_LIBRARY(LIB_EAY_DEBUG
|
||||
NAMES
|
||||
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}MDd libeay32MDd libeay32
|
||||
PATHS
|
||||
${OPENSSL_ROOT_DIR}/lib/VC
|
||||
)
|
||||
|
||||
FIND_LIBRARY(LIB_EAY_RELEASE
|
||||
NAMES
|
||||
libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}MD libeay32MD libeay32
|
||||
PATHS
|
||||
${OPENSSL_ROOT_DIR}/lib/VC
|
||||
)
|
||||
|
||||
FIND_LIBRARY(SSL_EAY_DEBUG
|
||||
NAMES
|
||||
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}MDd ssleay32MDd ssleay32 ssl
|
||||
PATHS
|
||||
${OPENSSL_ROOT_DIR}/lib/VC
|
||||
)
|
||||
|
||||
FIND_LIBRARY(SSL_EAY_RELEASE
|
||||
NAMES
|
||||
libssl${_OPENSSL_MSVC_ARCH_SUFFIX}MD ssleay32MD ssleay32 ssl
|
||||
PATHS
|
||||
${OPENSSL_ROOT_DIR}/lib/VC
|
||||
)
|
||||
|
||||
if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
|
||||
set( OPENSSL_LIBRARIES
|
||||
optimized ${SSL_EAY_RELEASE} optimized ${LIB_EAY_RELEASE}
|
||||
debug ${SSL_EAY_DEBUG} debug ${LIB_EAY_DEBUG}
|
||||
)
|
||||
else()
|
||||
set( OPENSSL_LIBRARIES
|
||||
${SSL_EAY_RELEASE}
|
||||
${LIB_EAY_RELEASE}
|
||||
)
|
||||
endif()
|
||||
|
||||
MARK_AS_ADVANCED(SSL_EAY_DEBUG SSL_EAY_RELEASE LIB_EAY_DEBUG LIB_EAY_RELEASE)
|
||||
ELSEIF(MINGW)
|
||||
|
||||
# same player, for MingW
|
||||
FIND_LIBRARY(LIB_EAY
|
||||
NAMES
|
||||
libeay32
|
||||
PATHS
|
||||
${OPENSSL_ROOT_DIR}/lib/MinGW
|
||||
)
|
||||
|
||||
FIND_LIBRARY(SSL_EAY NAMES
|
||||
NAMES
|
||||
ssleay32
|
||||
PATHS
|
||||
${OPENSSL_ROOT_DIR}/lib/MinGW
|
||||
)
|
||||
|
||||
MARK_AS_ADVANCED(SSL_EAY LIB_EAY)
|
||||
|
||||
set( OPENSSL_LIBRARIES
|
||||
${SSL_EAY}
|
||||
${LIB_EAY}
|
||||
)
|
||||
ELSE(MSVC)
|
||||
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
|
||||
FIND_LIBRARY(LIB_EAY
|
||||
NAMES
|
||||
libeay32
|
||||
PATHS
|
||||
${OPENSSL_ROOT_DIR}/lib
|
||||
${OPENSSL_ROOT_DIR}/lib/VC
|
||||
)
|
||||
|
||||
FIND_LIBRARY(SSL_EAY
|
||||
NAMES
|
||||
ssleay32
|
||||
PATHS
|
||||
${OPENSSL_ROOT_DIR}/lib
|
||||
${OPENSSL_ROOT_DIR}/lib/VC
|
||||
)
|
||||
MARK_AS_ADVANCED(SSL_EAY LIB_EAY)
|
||||
|
||||
SET( OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY} )
|
||||
ENDIF(MSVC)
|
||||
ELSE(WIN32 AND NOT CYGWIN)
|
||||
FIND_LIBRARY(OPENSSL_SSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD)
|
||||
FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARIES NAMES crypto)
|
||||
MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARIES OPENSSL_SSL_LIBRARIES)
|
||||
|
||||
SET(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES})
|
||||
|
||||
ENDIF(WIN32 AND NOT CYGWIN)
|
||||
|
||||
if (NOT OPENSSL_INCLUDE_DIR)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(OpenSSL DEFAULT_MSG
|
||||
OPENSSL_LIBRARIES
|
||||
OPENSSL_INCLUDE_DIR
|
||||
)
|
||||
endif()
|
||||
|
||||
if (OPENSSL_INCLUDE_DIR)
|
||||
message( STATUS "Found OpenSSL library: ${OPENSSL_LIBRARIES}")
|
||||
message( STATUS "Found OpenSSL headers: ${OPENSSL_INCLUDE_DIR}")
|
||||
if (_OPENSSL_VERSION)
|
||||
set(OPENSSL_VERSION "${_OPENSSL_VERSION}")
|
||||
else (_OPENSSL_VERSION)
|
||||
file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
|
||||
REGEX "^# *define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x[0-9][0-9][0-9][0-9][0-9][0-9].*")
|
||||
|
||||
# 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-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-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)
|
||||
list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
|
||||
list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)
|
||||
|
||||
string(REGEX REPLACE "^0(.)" "\\1" OPENSSL_VERSION_MINOR "${OPENSSL_VERSION_MINOR}")
|
||||
string(REGEX REPLACE "^0(.)" "\\1" OPENSSL_VERSION_FIX "${OPENSSL_VERSION_FIX}")
|
||||
|
||||
if (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
|
||||
# 96 is the ASCII code of 'a' minus 1
|
||||
math(EXPR OPENSSL_VERSION_PATCH_ASCII "${OPENSSL_VERSION_PATCH} + 96")
|
||||
# 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 (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
|
||||
|
||||
set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
|
||||
endif (_OPENSSL_VERSION)
|
||||
|
||||
include(EnsureVersion)
|
||||
ENSURE_VERSION_RANGE("${OPENSSL_EXPECTED_VERSION}" "${OPENSSL_VERSION}" "${OPENSSL_MAX_VERSION}" OPENSSL_VERSION_OK)
|
||||
if (NOT OPENSSL_VERSION_OK)
|
||||
message(FATAL_ERROR "TrinityCore needs OpenSSL version ${OPENSSL_EXPECTED_VERSION} but found version ${OPENSSL_VERSION}")
|
||||
endif()
|
||||
endif (OPENSSL_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
|
||||
163
cmake/macros/FindPCHSupport.cmake
Normal file
163
cmake/macros/FindPCHSupport.cmake
Normal file
@@ -0,0 +1,163 @@
|
||||
FUNCTION(GET_COMMON_PCH_PARAMS TARGET_NAME_LIST PCH_HEADER PCH_FE INCLUDE_PREFIX)
|
||||
GET_FILENAME_COMPONENT(PCH_HEADER_N ${PCH_HEADER} NAME)
|
||||
GET_DIRECTORY_PROPERTY(TARGET_INCLUDES INCLUDE_DIRECTORIES)
|
||||
|
||||
# Stores the inherited dependency definitions and include directories
|
||||
# from the given target into the given variables
|
||||
MACRO(CollectIncludes target inherited_includes inherited_definitions)
|
||||
# Append the includes and definitions of the current target to the list
|
||||
get_property(included TARGET ${target} PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
|
||||
LIST(APPEND "${inherited_includes}" ${included})
|
||||
get_property(definitions TARGET ${target} PROPERTY INTERFACE_COMPILE_DEFINITIONS)
|
||||
FOREACH(def ${definitions})
|
||||
LIST(APPEND "${inherited_definitions}" "-D${def}")
|
||||
ENDFOREACH()
|
||||
# Add all inherited link targets which weren't included already
|
||||
get_property(links TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES)
|
||||
# TODO Maybe catch circular dependencies?
|
||||
FOREACH(target_link ${links})
|
||||
IF(TARGET ${target_link})
|
||||
CollectIncludes(${target_link} "${inherited_includes}" "${inherited_definitions}")
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
ENDMACRO()
|
||||
|
||||
FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
|
||||
CollectIncludes(${TARGET_NAME} TARGET_INCLUDES TARGET_DEFINITIONS)
|
||||
ENDFOREACH()
|
||||
|
||||
LIST(REMOVE_DUPLICATES TARGET_INCLUDES)
|
||||
LIST(REMOVE_DUPLICATES TARGET_DEFINITIONS)
|
||||
|
||||
FOREACH(ITEM ${TARGET_INCLUDES})
|
||||
LIST(APPEND INCLUDE_FLAGS_LIST "${INCLUDE_PREFIX}\"${ITEM}\" ")
|
||||
ENDFOREACH(ITEM)
|
||||
|
||||
SET(PCH_INCLUDES ${TARGET_INCLUDES} PARENT_SCOPE)
|
||||
SET(PCH_DEFINITIONS ${TARGET_DEFINITIONS} PARENT_SCOPE)
|
||||
SET(PCH_HEADER_NAME ${PCH_HEADER_N} PARENT_SCOPE)
|
||||
SET(PCH_HEADER_OUT ${CMAKE_CURRENT_BINARY_DIR}/${PCH_HEADER_N}.${PCH_FE} PARENT_SCOPE)
|
||||
SET(INCLUDE_FLAGS ${INCLUDE_FLAGS_LIST} PARENT_SCOPE)
|
||||
ENDFUNCTION(GET_COMMON_PCH_PARAMS)
|
||||
|
||||
FUNCTION(GENERATE_CXX_PCH_COMMAND TARGET_NAME_LIST INCLUDE_FLAGS IN PCH_SRC OUT)
|
||||
include_directories(${PCH_INCLUDES})
|
||||
add_definitions(${PCH_DEFINITIONS})
|
||||
|
||||
IF (CMAKE_BUILD_TYPE)
|
||||
STRING(TOUPPER _${CMAKE_BUILD_TYPE} CURRENT_BUILD_TYPE)
|
||||
ENDIF ()
|
||||
|
||||
SET(COMPILE_FLAGS ${CMAKE_CXX_FLAGS${CURRENT_BUILD_TYPE}})
|
||||
LIST(APPEND COMPILE_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
IF ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
||||
IF (NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "")
|
||||
LIST(APPEND COMPILE_FLAGS "-arch ${CMAKE_OSX_ARCHITECTURES}")
|
||||
ENDIF ()
|
||||
IF (NOT "${CMAKE_OSX_SYSROOT}" STREQUAL "")
|
||||
LIST(APPEND COMPILE_FLAGS "-isysroot ${CMAKE_OSX_SYSROOT}")
|
||||
ENDIF ()
|
||||
IF (NOT "${CMAKE_OSX_DEPLOYMENT_TARGET}" STREQUAL "")
|
||||
LIST(APPEND COMPILE_FLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
||||
ENDIF ()
|
||||
ENDIF ()
|
||||
|
||||
GET_DIRECTORY_PROPERTY(TARGET_DEFINITIONS COMPILE_DEFINITIONS)
|
||||
FOREACH(ITEM ${TARGET_DEFINITIONS})
|
||||
LIST(APPEND DEFINITION_FLAGS "-D${ITEM} ")
|
||||
ENDFOREACH(ITEM)
|
||||
|
||||
SEPARATE_ARGUMENTS(COMPILE_FLAGS)
|
||||
SEPARATE_ARGUMENTS(INCLUDE_FLAGS)
|
||||
SEPARATE_ARGUMENTS(DEFINITION_FLAGS)
|
||||
|
||||
GET_FILENAME_COMPONENT(PCH_SRC_N ${PCH_SRC} NAME)
|
||||
ADD_LIBRARY(${PCH_SRC_N}_dephelp MODULE ${PCH_SRC})
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${OUT}
|
||||
COMMAND ${CMAKE_CXX_COMPILER}
|
||||
ARGS ${DEFINITION_FLAGS} ${COMPILE_FLAGS} ${INCLUDE_FLAGS} -x c++-header -c ${IN} -o ${OUT}
|
||||
DEPENDS ${IN} ${PCH_SRC_N}_dephelp
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
ADD_CUSTOM_TARGET(generate_${PCH_SRC_N}
|
||||
DEPENDS ${OUT}
|
||||
)
|
||||
|
||||
FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
|
||||
ADD_DEPENDENCIES(${TARGET_NAME} generate_${PCH_SRC_N})
|
||||
ENDFOREACH()
|
||||
|
||||
ENDFUNCTION(GENERATE_CXX_PCH_COMMAND)
|
||||
|
||||
FUNCTION(ADD_CXX_PCH_GCC TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
|
||||
GET_COMMON_PCH_PARAMS("${TARGET_NAME_LIST}" ${PCH_HEADER} "gch" "-I")
|
||||
GENERATE_CXX_PCH_COMMAND("${TARGET_NAME_LIST}" "${INCLUDE_FLAGS}" ${PCH_HEADER} ${PCH_SOURCE} ${PCH_HEADER_OUT})
|
||||
|
||||
FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
|
||||
SET_TARGET_PROPERTIES(
|
||||
${TARGET_NAME} PROPERTIES
|
||||
COMPILE_FLAGS "-include ${CMAKE_CURRENT_BINARY_DIR}/${PCH_HEADER_NAME}"
|
||||
)
|
||||
ENDFOREACH()
|
||||
ENDFUNCTION(ADD_CXX_PCH_GCC)
|
||||
|
||||
FUNCTION(ADD_CXX_PCH_CLANG TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
|
||||
GET_COMMON_PCH_PARAMS("${TARGET_NAME_LIST}" ${PCH_HEADER} "pch" "-I")
|
||||
GENERATE_CXX_PCH_COMMAND("${TARGET_NAME_LIST}" "${INCLUDE_FLAGS}" ${PCH_HEADER} ${PCH_SOURCE} ${PCH_HEADER_OUT})
|
||||
|
||||
FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
|
||||
SET_TARGET_PROPERTIES(
|
||||
${TARGET_NAME} PROPERTIES
|
||||
COMPILE_FLAGS "-include-pch ${PCH_HEADER_OUT}"
|
||||
)
|
||||
ENDFOREACH()
|
||||
ENDFUNCTION(ADD_CXX_PCH_CLANG)
|
||||
|
||||
FUNCTION(ADD_CXX_PCH_MSVC TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
|
||||
GET_COMMON_PCH_PARAMS("${TARGET_NAME_LIST}" ${PCH_HEADER} "pch" "/I")
|
||||
|
||||
FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
|
||||
SET(PCH_COMPILE_FLAGS "/FI${PCH_HEADER_NAME} /Yu${PCH_HEADER_NAME}")
|
||||
IF (NOT ${CMAKE_MAKE_PROGRAM} MATCHES "MSBuild")
|
||||
SET(PCH_COMPILE_FLAGS "${PCH_COMPILE_FLAGS} /Fp${PCH_HEADER_OUT}")
|
||||
SET(TARGET_SOURCES_LIST "")
|
||||
GET_PROPERTY(TARGET_SOURCES_LIST TARGET ${TARGET_NAME} PROPERTY SOURCES)
|
||||
LIST(REMOVE_ITEM TARGET_SOURCES_LIST ${PCH_SOURCE})
|
||||
SET_SOURCE_FILES_PROPERTIES(${TARGET_SOURCES_LIST} PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${TARGET_NAME}.dir/${PCH_SOURCE}.obj")
|
||||
ENDIF()
|
||||
SET_TARGET_PROPERTIES(
|
||||
${TARGET_NAME} PROPERTIES
|
||||
COMPILE_FLAGS "${PCH_COMPILE_FLAGS}"
|
||||
)
|
||||
ENDFOREACH()
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(
|
||||
${PCH_SOURCE} PROPERTIES
|
||||
COMPILE_FLAGS "/Yc${PCH_HEADER_NAME}"
|
||||
)
|
||||
ENDFUNCTION(ADD_CXX_PCH_MSVC)
|
||||
|
||||
FUNCTION(ADD_CXX_PCH_XCODE TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
|
||||
FOREACH(TARGET_NAME ${TARGET_NAME_LIST})
|
||||
SET_TARGET_PROPERTIES("${TARGET_NAME}" PROPERTIES
|
||||
XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER YES
|
||||
XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/${PCH_HEADER}"
|
||||
)
|
||||
ENDFOREACH()
|
||||
ENDFUNCTION(ADD_CXX_PCH_XCODE)
|
||||
|
||||
FUNCTION(ADD_CXX_PCH TARGET_NAME_LIST PCH_HEADER PCH_SOURCE)
|
||||
IF (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
ADD_CXX_PCH_MSVC("${TARGET_NAME_LIST}" ${PCH_HEADER} ${PCH_SOURCE})
|
||||
ELSEIF ("${CMAKE_GENERATOR}" MATCHES "Xcode")
|
||||
ADD_CXX_PCH_XCODE("${TARGET_NAME_LIST}" ${PCH_HEADER} ${PCH_SOURCE})
|
||||
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
ADD_CXX_PCH_CLANG("${TARGET_NAME_LIST}" ${PCH_HEADER} ${PCH_SOURCE})
|
||||
ELSEIF ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
|
||||
ADD_CXX_PCH_GCC("${TARGET_NAME_LIST}" ${PCH_HEADER} ${PCH_SOURCE})
|
||||
ENDIF ()
|
||||
ENDFUNCTION(ADD_CXX_PCH)
|
||||
18
cmake/macros/FindReadline.cmake
Normal file
18
cmake/macros/FindReadline.cmake
Normal file
@@ -0,0 +1,18 @@
|
||||
# find Readline (terminal input library) includes and library
|
||||
#
|
||||
# READLINE_INCLUDE_DIR - where the directory containing the READLINE headers can be found
|
||||
# READLINE_LIBRARY - full path to the READLINE library
|
||||
# READLINE_FOUND - TRUE if READLINE was found
|
||||
|
||||
FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h)
|
||||
FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
|
||||
|
||||
IF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
|
||||
SET(READLINE_FOUND TRUE)
|
||||
MESSAGE(STATUS "Found Readline library: ${READLINE_LIBRARY}")
|
||||
MESSAGE(STATUS "Include dir is: ${READLINE_INCLUDE_DIR}")
|
||||
INCLUDE_DIRECTORIES(${READLINE_INCLUDE_DIR})
|
||||
ELSE (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
|
||||
SET(READLINE_FOUND FALSE)
|
||||
MESSAGE(FATAL_ERROR "** Readline library not found!\n** Your distro may provide a binary for Readline e.g. for ubuntu try apt-get install libreadline5-dev")
|
||||
ENDIF (READLINE_INCLUDE_DIR AND READLINE_LIBRARY)
|
||||
51
cmake/macros/GroupSources.cmake
Normal file
51
cmake/macros/GroupSources.cmake
Normal file
@@ -0,0 +1,51 @@
|
||||
# Copyright (C) 2008-2015 TrinityCore <http://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()
|
||||
125
cmake/macros/Macros.cmake
Normal file
125
cmake/macros/Macros.cmake
Normal file
@@ -0,0 +1,125 @@
|
||||
macro(GetFilesWithSourceGroups GLOB_TYPE VARIABLE RELATIVE_TO)
|
||||
file(${GLOB_TYPE} files ${ARGN})
|
||||
foreach(file ${files})
|
||||
file(RELATIVE_PATH relFile ${RELATIVE_TO} ${file})
|
||||
get_filename_component(folder ${relFile} PATH)
|
||||
string(REPLACE / \\ folder "${folder}")
|
||||
source_group("${folder}" FILES ${file})
|
||||
endforeach()
|
||||
list(APPEND ${VARIABLE} ${files})
|
||||
endmacro()
|
||||
|
||||
function(SimpleCompileCheck VARIABLE DESCRIPTION SOURCE)
|
||||
if(MSVC)
|
||||
# Force warning as error to detect "noexcept" warning when exceptions are disabled:
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
|
||||
endif()
|
||||
string(MD5 hashInputs "${CMAKE_CXX_FLAGS}${SOURCE}")
|
||||
if(NOT DEFINED ${VARIABLE} OR NOT "${${VARIABLE}_HASH}" STREQUAL "${hashInputs}")
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CompileCheck.cpp "${SOURCE}\nint main() { return 0; };")
|
||||
try_compile(${VARIABLE} ${CMAKE_BINARY_DIR}/CMakeTmp ${CMAKE_BINARY_DIR}/CMakeTmp/CompileCheck.cpp OUTPUT_VARIABLE output)
|
||||
if(${VARIABLE})
|
||||
message("${DESCRIPTION} -- yes")
|
||||
else()
|
||||
message("${DESCRIPTION} -- no")
|
||||
endif()
|
||||
set(${VARIABLE} ${${VARIABLE}} CACHE INTERNAL "${DESCRIPTION}")
|
||||
set("${VARIABLE}_HASH" "${hashInputs}" CACHE INTERNAL "${DESCRIPTION} (hashed inputs)")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(GetAbsoluteRelativeTo VARIABLE ROOT RELATIVE)
|
||||
if(IS_ABSOLUTE "${RELATIVE}")
|
||||
set(${VARIABLE} "${RELATIVE}")
|
||||
else()
|
||||
get_filename_component(${VARIABLE} "${ROOT}/${RELATIVE}" ABSOLUTE)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(ConfigureFileIfChanged SRC_FILE DST_FILE SOURCE_FILES_VAR)
|
||||
get_filename_component(fullSrcPath "${SRC_FILE}" ABSOLUTE)
|
||||
list(APPEND ${SOURCE_FILES_VAR} ${fullSrcPath} ${DST_FILE})
|
||||
source_group("config" FILES ${fullSrcPath} ${DST_FILE})
|
||||
configure_file("${fullSrcPath}" "${DST_FILE}.compare")
|
||||
file(READ "${DST_FILE}.compare" newContents)
|
||||
file(TO_NATIVE_PATH "${fullSrcPath}" fullScrPathNative)
|
||||
file(TO_NATIVE_PATH "${CMAKE_CURRENT_LIST_FILE}" currentListFileNative)
|
||||
set(newContents
|
||||
"//--------------------------------------------
|
||||
// This file was autogenerated from: ${fullScrPathNative}
|
||||
// while running: ${currentListFileNative}
|
||||
// Do not edit!
|
||||
//--------------------------------------------
|
||||
|
||||
${newContents}")
|
||||
file(REMOVE "${DST_FILE}.compare")
|
||||
if(EXISTS "${DST_FILE}")
|
||||
file(READ "${DST_FILE}" oldContents)
|
||||
if (NOT oldContents STREQUAL newContents)
|
||||
file(WRITE "${DST_FILE}" "${newContents}")
|
||||
endif()
|
||||
else()
|
||||
file(WRITE "${DST_FILE}" "${newContents}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(WriteFileIfDifferent CONTENTS DST_FILE SOURCE_FILES_VAR)
|
||||
list(APPEND ${SOURCE_FILES_VAR} ${DST_FILE})
|
||||
source_group("config" FILES ${SRC_FILE} ${DST_FILE})
|
||||
if(EXISTS "${DST_FILE}")
|
||||
file(READ "${DST_FILE}" oldContents)
|
||||
if(NOT oldContents STREQUAL CONTENTS)
|
||||
file(WRITE "${DST_FILE}" "${CONTENTS}")
|
||||
endif()
|
||||
else()
|
||||
file(WRITE "${DST_FILE}" "${CONTENTS}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(ApplyTurfBuildSettings)
|
||||
if(MSVC)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "/ignore:4221")
|
||||
set(CMAKE_STATIC_LINKER_FLAGS "/ignore:4221")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "/ignore:4221")
|
||||
if(TURF_WITH_EXCEPTIONS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
|
||||
else()
|
||||
add_definitions(-D_HAS_EXCEPTIONS=0)
|
||||
endif()
|
||||
if(NOT TURF_WITH_SECURE_COMPILER)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GS-")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS-")
|
||||
endif()
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "-g -std=gnu99 -fno-stack-protector")
|
||||
if(DEFINED TURF_ENABLE_CPP11 AND NOT "${TURF_ENABLE_CPP11}")
|
||||
set(CMAKE_CXX_FLAGS "-g -fno-stack-protector")
|
||||
else()
|
||||
if(MINGW)
|
||||
set(CMAKE_CXX_FLAGS "-g -std=gnu++11 -fno-stack-protector")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "-g -std=c++11 -fno-stack-protector")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT TURF_WITH_EXCEPTIONS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
|
||||
endif()
|
||||
if(NOT CYGWIN) # Don't specify -pthread on Cygwin
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
endif()
|
||||
endif()
|
||||
# Define custom build configs
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DTURF_WITH_ASSERTS=1")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DTURF_WITH_ASSERTS=1")
|
||||
set(CMAKE_C_FLAGS_RELWITHASSERTS "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DTURF_WITH_ASSERTS=1")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHASSERTS "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DTURF_WITH_ASSERTS=1")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELWITHASSERTS "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
|
||||
endmacro()
|
||||
|
||||
macro(AddDLLCopyStep TARGET_NAME)
|
||||
foreach(DLL ${ARGN})
|
||||
add_custom_command(TARGET ${TARGET_NAME} POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND} -E copy_if_different ${DLL} $<TARGET_FILE_DIR:${TARGET_NAME}>)
|
||||
endforeach()
|
||||
endmacro()
|
||||
20
cmake/options.cmake
Normal file
20
cmake/options.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
# Copyright (C) 2008-2012 Trinity <http://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.
|
||||
|
||||
option(SERVERS "Build worldserver and bnetserver" 1)
|
||||
option(SCRIPTS "Build core with scripts included" 1)
|
||||
option(USE_SCRIPTPCH "Use precompiled headers when compiling scripts" 1)
|
||||
option(USE_COREPCH "Use precompiled headers when compiling servers" 1)
|
||||
option(WITH_WARNINGS "Show all warnings during compile" 0)
|
||||
option(WITH_COREDEBUG "Include additional debug-code in core" 0)
|
||||
|
||||
set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.")
|
||||
set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical hierarchical-folders)
|
||||
option(WITHOUT_GIT "Disable the GIT testing routines" 1)
|
||||
23
cmake/platform/cmake_uninstall.in.cmake
Normal file
23
cmake/platform/cmake_uninstall.in.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
# from cmake wiki
|
||||
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
STRING(REGEX REPLACE "\n" ";" files "${files}")
|
||||
FOREACH(file ${files})
|
||||
MESSAGE(STATUS "Uninstalling \"${file}\"")
|
||||
IF(EXISTS "${file}")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF("${rm_retval}" STREQUAL 0)
|
||||
ELSE("${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"")
|
||||
ENDIF("${rm_retval}" STREQUAL 0)
|
||||
ELSE(EXISTS "${file}")
|
||||
MESSAGE(STATUS "File \"${file}\" does not exist.")
|
||||
ENDIF(EXISTS "${file}")
|
||||
ENDFOREACH(file)
|
||||
36
cmake/platform/unix/settings.cmake
Normal file
36
cmake/platform/unix/settings.cmake
Normal file
@@ -0,0 +1,36 @@
|
||||
# set default configuration directory
|
||||
if( NOT CONF_DIR )
|
||||
set(CONF_DIR ${CMAKE_INSTALL_PREFIX}/etc)
|
||||
message(STATUS "UNIX: Using default configuration directory")
|
||||
endif()
|
||||
|
||||
# set default library directory
|
||||
if( NOT LIBSDIR )
|
||||
set(LIBSDIR ${CMAKE_INSTALL_PREFIX}/lib)
|
||||
message(STATUS "UNIX: Using default library directory")
|
||||
endif()
|
||||
|
||||
# configure uninstaller
|
||||
configure_file(
|
||||
"${CMAKE_SOURCE_DIR}/cmake/platform/cmake_uninstall.in.cmake"
|
||||
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
@ONLY
|
||||
)
|
||||
message(STATUS "UNIX: Configuring uninstall target")
|
||||
|
||||
# create uninstaller target (allows for using "make uninstall")
|
||||
add_custom_target(uninstall
|
||||
"${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
)
|
||||
message(STATUS "UNIX: Created uninstall target")
|
||||
|
||||
message(STATUS "UNIX: Detected compiler: ${CMAKE_C_COMPILER}")
|
||||
if(CMAKE_C_COMPILER MATCHES "gcc" OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler/gcc/settings.cmake)
|
||||
elseif(CMAKE_C_COMPILER MATCHES "icc")
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler/icc/settings.cmake)
|
||||
elseif(CMAKE_C_COMPILER MATCHES "clang" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler/clang/settings.cmake)
|
||||
else()
|
||||
add_definitions(-D_BUILD_DIRECTIVE='"${CMAKE_BUILD_TYPE}"')
|
||||
endif()
|
||||
11
cmake/platform/win/settings.cmake
Normal file
11
cmake/platform/win/settings.cmake
Normal file
@@ -0,0 +1,11 @@
|
||||
add_definitions(-D_WIN32_WINNT=0x0601)
|
||||
add_definitions(-DWIN32_LEAN_AND_MEAN)
|
||||
add_definitions(-DNOMINMAX)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
|
||||
elseif (CMAKE_CXX_PLATFORM_ID MATCHES "MinGW")
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler/mingw/settings.cmake)
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
include(${CMAKE_SOURCE_DIR}/cmake/compiler/clang/settings.cmake)
|
||||
endif()
|
||||
62
cmake/showoptions.cmake
Normal file
62
cmake/showoptions.cmake
Normal file
@@ -0,0 +1,62 @@
|
||||
# output generic information about the core and buildtype chosen
|
||||
message("")
|
||||
message("* LegionCore")
|
||||
if( UNIX )
|
||||
message("* LegionCore")
|
||||
endif()
|
||||
message("")
|
||||
|
||||
# Show infomation about the options selected during configuration
|
||||
|
||||
if( SERVERS )
|
||||
message("* Build world/auth : Yes (default)")
|
||||
else()
|
||||
message("* Build world/bnetserver : No")
|
||||
endif()
|
||||
|
||||
if( SCRIPTS )
|
||||
message("* Build with scripts : Yes (default)")
|
||||
add_definitions(-DSCRIPTS)
|
||||
else()
|
||||
message("* Build with scripts : No")
|
||||
endif()
|
||||
|
||||
if( USE_COREPCH )
|
||||
message("* Build core w/PCH : Yes (default)")
|
||||
else()
|
||||
message("* Build core w/PCH : No")
|
||||
endif()
|
||||
|
||||
if( USE_SCRIPTPCH )
|
||||
message("* Build scripts w/PCH : Yes (default)")
|
||||
else()
|
||||
message("* Build scripts w/PCH : No")
|
||||
endif()
|
||||
|
||||
if( WITH_WARNINGS )
|
||||
message("* Show all warnings : Yes")
|
||||
else()
|
||||
message("* Show compile-warnings : No (default)")
|
||||
endif()
|
||||
|
||||
if( WITH_COREDEBUG )
|
||||
message("")
|
||||
message(" *** WITH_COREDEBUG - WARNING!")
|
||||
message(" *** additional core debug logs have been enabled!")
|
||||
message(" *** this setting doesn't help to get better crash logs!")
|
||||
message(" *** in case you are searching for better crash logs use")
|
||||
message(" *** -DCMAKE_BUILD_TYPE=RelWithDebug")
|
||||
message(" *** DO NOT ENABLE IT UNLESS YOU KNOW WHAT YOU'RE DOING!")
|
||||
message("* Use coreside debug : Yes")
|
||||
add_definitions(-DTRINITY_DEBUG)
|
||||
else()
|
||||
message("* Use coreside debug : No (default)")
|
||||
endif()
|
||||
|
||||
if( NOT WITH_SOURCE_TREE STREQUAL "no" )
|
||||
message("* Show source tree : Yes - \"${WITH_SOURCE_TREE}\"")
|
||||
else()
|
||||
message("* Show source tree : No")
|
||||
endif()
|
||||
|
||||
message("")
|
||||
31
cmake/stack_direction.c
Normal file
31
cmake/stack_direction.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2009 Sun Microsystems, Inc
|
||||
|
||||
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 */
|
||||
|
||||
/* Check stack direction (0-down, 1-up) */
|
||||
int f(int *a)
|
||||
{
|
||||
int b;
|
||||
return(&b > a)?1:0;
|
||||
}
|
||||
/*
|
||||
Prevent compiler optimizations by calling function
|
||||
through pointer.
|
||||
*/
|
||||
volatile int (*ptr_f)(int *) = f;
|
||||
int main()
|
||||
{
|
||||
int a;
|
||||
return ptr_f(&a);
|
||||
}
|
||||
Reference in New Issue
Block a user