aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/genrev.cmake16
-rw-r--r--cmake/macros/ConfigureBoost.cmake27
-rw-r--r--cmake/macros/FindMySQL.cmake67
-rw-r--r--cmake/macros/FindOpenSSL.cmake2
-rw-r--r--cmake/macros/GroupSources.cmake46
-rw-r--r--cmake/options.cmake2
-rw-r--r--cmake/showoptions.cmake23
7 files changed, 171 insertions, 12 deletions
diff --git a/cmake/genrev.cmake b/cmake/genrev.cmake
index c34e9d75973..1f5f02ceeec 100644
--- a/cmake/genrev.cmake
+++ b/cmake/genrev.cmake
@@ -12,21 +12,19 @@
# This is done EACH compile so they can be alerted about the consequences.
if(NOT BUILDDIR)
- # Workaround for funny MSVC behaviour - this segment only run during compile
- set(NO_GIT ${WITHOUT_GIT})
- set(GIT_EXEC ${GIT_EXECUTABLE})
+ # Workaround for funny MSVC behaviour - this segment is only used when using cmake gui
set(BUILDDIR ${CMAKE_BINARY_DIR})
endif()
-if(NO_GIT)
+if(WITHOUT_GIT)
set(rev_date "1970-01-01 00:00:00 +0000")
set(rev_hash "unknown")
set(rev_branch "Archived")
else()
- if(GIT_EXEC)
+ if(GIT_EXECUTABLE)
# Create a revision-string that we can use
execute_process(
- COMMAND "${GIT_EXEC}" describe --match init --dirty=+ --abbrev=12
+ COMMAND "${GIT_EXECUTABLE}" describe --match init --dirty=+ --abbrev=12
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_info
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -35,7 +33,7 @@ else()
# And grab the commits timestamp
execute_process(
- COMMAND "${GIT_EXEC}" show -s --format=%ci
+ COMMAND "${GIT_EXECUTABLE}" show -s --format=%ci
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_date
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -44,7 +42,7 @@ else()
# Also retrieve branch name
execute_process(
- COMMAND "${GIT_EXEC}" rev-parse --abbrev-ref HEAD
+ COMMAND "${GIT_EXECUTABLE}" rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_VARIABLE rev_branch
OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -69,7 +67,7 @@ else()
endif()
# Create the actual revision.h file from the above params
-if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}" OR NOT "${rev_branch_cached}" MATCHES "${rev_branch}")
+if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}" OR NOT "${rev_branch_cached}" MATCHES "${rev_branch}" OR NOT EXISTS "${BUILDDIR}/revision.h")
configure_file(
"${CMAKE_SOURCE_DIR}/revision.h.in.cmake"
"${BUILDDIR}/revision.h"
diff --git a/cmake/macros/ConfigureBoost.cmake b/cmake/macros/ConfigureBoost.cmake
index 3d3791b8a93..16c817d9d25 100644
--- a/cmake/macros/ConfigureBoost.cmake
+++ b/cmake/macros/ConfigureBoost.cmake
@@ -25,11 +25,36 @@ if(WIN32)
add_definitions(-D_WIN32_WINNT=${ver})
endif()
-find_package(Boost 1.49 REQUIRED system thread program_options)
+find_package(Boost 1.49 REQUIRED system filesystem thread program_options iostreams)
add_definitions(-DBOOST_DATE_TIME_NO_LIB)
add_definitions(-DBOOST_REGEX_NO_LIB)
add_definitions(-DBOOST_CHRONO_NO_LIB)
+# Find if Boost was compiled in C++03 mode because it requires -DBOOST_NO_CXX11_SCOPED_ENUMS
+
+include (CheckCXXSourceCompiles)
+
+set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
+set(CMAKE_REQUIRED_LIBRARIES ${Boost_SYSTEM_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_IOSTREAMS_LIBRARY})
+set(CMAKE_REQUIRED_FLAGS "-std=c++11")
+unset(boost_filesystem_copy_links_without_NO_SCOPED_ENUM CACHE)
+check_cxx_source_compiles("
+ #include <boost/filesystem/path.hpp>
+ #include <boost/filesystem/operations.hpp>
+ int main() { boost::filesystem::copy_file(boost::filesystem::path(), boost::filesystem::path()); }"
+boost_filesystem_copy_links_without_NO_SCOPED_ENUM)
+unset(CMAKE_REQUIRED_INCLUDES CACHE)
+unset(CMAKE_REQUIRED_LIBRARIES CACHE)
+unset(CMAKE_REQUIRED_FLAGS CACHE)
+
+if (NOT boost_filesystem_copy_links_without_NO_SCOPED_ENUM)
+ if (Boost_VERSION LESS 105100) # 1.51
+ add_definitions(-DBOOST_NO_SCOPED_ENUMS)
+ else()
+ add_definitions(-DBOOST_NO_CXX11_SCOPED_ENUMS)
+ endif()
+endif()
+
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
diff --git a/cmake/macros/FindMySQL.cmake b/cmake/macros/FindMySQL.cmake
index 2c393463c47..6b00510ba42 100644
--- a/cmake/macros/FindMySQL.cmake
+++ b/cmake/macros/FindMySQL.cmake
@@ -5,6 +5,7 @@
# 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
@@ -94,6 +95,7 @@ find_path(MYSQL_INCLUDE_DIR
"$ENV{ProgramFiles}/MySQL/*/include"
"$ENV{SystemDrive}/MySQL/*/include"
"c:/msys/local/include"
+ "$ENV{MYSQL_ROOT}/include"
DOC
"Specify the directory containing mysql.h."
)
@@ -159,6 +161,7 @@ if( WIN32 )
"$ENV{ProgramFiles}/MySQL/*/lib/opt"
"$ENV{SystemDrive}/MySQL/*/lib/opt"
"c:/msys/local/include"
+ "$ENV{MYSQL_ROOT}/lib"
DOC "Specify the location of the mysql library here."
)
endif( WIN32 )
@@ -180,6 +183,65 @@ 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
+ "C:/Program Files/MySQL/MySQL Server 5.6/bin"
+ "C:/Program Files/MySQL/MySQL Server 5.6/bin/opt"
+ "C:/Program Files/MySQL/MySQL Server 5.5/bin"
+ "C:/Program Files/MySQL/MySQL Server 5.5/bin/opt"
+ "C:/Program Files/MySQL/MySQL Server 5.1/bin"
+ "C:/Program Files/MySQL/MySQL Server 5.1/bin/opt"
+ "C:/Program Files/MySQL/MySQL Server 5.0/bin"
+ "C:/Program Files/MySQL/MySQL Server 5.0/bin/opt"
+ "C:/Program Files/MySQL/bin"
+ "C:/Program Files (x86)/MySQL/MySQL Server 5.6/bin"
+ "C:/Program Files (x86)/MySQL/MySQL Server 5.6/bin/opt"
+ "C:/Program Files (x86)/MySQL/MySQL Server 5.5/bin"
+ "C:/Program Files (x86)/MySQL/MySQL Server 5.5/bin/opt"
+ "C:/Program Files (x86)/MySQL/MySQL Server 5.1/bin"
+ "C:/Program Files (x86)/MySQL/MySQL Server 5.1/bin/opt"
+ "C:/Program Files (x86)/MySQL/MySQL Server 5.0/bin"
+ "C:/Program Files (x86)/MySQL/MySQL Server 5.0/bin/opt"
+ "C:/Program Files (x86)/MySQL/bin"
+ "C:/MySQL/bin/debug"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.6;Location]/bin"
+ "[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"
+ "[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"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.1;Location]/bin/opt"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.0;Location]/bin"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MySQL AB\\MySQL Server 5.0;Location]/bin/opt"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.6;Location]/bin"
+ "[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"
+ "[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"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.1;Location]/bin/opt"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.0;Location]/bin"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MySQL AB\\MySQL Server 5.0;Location]/bin/opt"
+ "$ENV{ProgramFiles}/MySQL/*/bin/opt"
+ "$ENV{SystemDrive}/MySQL/*/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 )
@@ -188,7 +250,10 @@ if( MYSQL_LIBRARY )
else( MYSQL_INCLUDE_DIR )
message(FATAL_ERROR "Could not find MySQL headers! Please install the development libraries and headers")
endif( MYSQL_INCLUDE_DIR )
- mark_as_advanced( MYSQL_FOUND MYSQL_LIBRARY MYSQL_EXTRA_LIBRARIES 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 )
diff --git a/cmake/macros/FindOpenSSL.cmake b/cmake/macros/FindOpenSSL.cmake
index 1cc34b36a4c..7baa43274ab 100644
--- a/cmake/macros/FindOpenSSL.cmake
+++ b/cmake/macros/FindOpenSSL.cmake
@@ -186,7 +186,7 @@ if (OPENSSL_INCLUDE_DIR)
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].*")
+ 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.
diff --git a/cmake/macros/GroupSources.cmake b/cmake/macros/GroupSources.cmake
new file mode 100644
index 00000000000..3acb03e7b4c
--- /dev/null
+++ b/cmake/macros/GroupSources.cmake
@@ -0,0 +1,46 @@
+# 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()
diff --git a/cmake/options.cmake b/cmake/options.cmake
index 83783fdc1b6..486cc909605 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -15,4 +15,6 @@ option(USE_SCRIPTPCH "Use precompiled headers when compiling scripts"
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 "no" CACHE STRING "Build the source tree for IDE's.")
+set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical)
option(WITHOUT_GIT "Disable the GIT testing routines" 0)
diff --git a/cmake/showoptions.cmake b/cmake/showoptions.cmake
index ea4820a01f0..bb848a2a9c0 100644
--- a/cmake/showoptions.cmake
+++ b/cmake/showoptions.cmake
@@ -62,6 +62,29 @@ else()
message("* Use coreside debug : No (default)")
endif()
+if( WITH_SOURCE_TREE STREQUAL "flat" OR WITH_SOURCE_TREE STREQUAL "hierarchical" )
+ # TODO: Remove this after Debian 8 is released and set general required version to 2.8.12
+ # Debian 7 is shipped with CMake 2.8.9 . But DIRECTORY flag of get_filename_component requires 2.8.12 .
+ if (NOT CMAKE_VERSION VERSION_LESS 2.8.12)
+ message("* Show source tree : Yes - ${WITH_SOURCE_TREE}")
+ set(_WITH_SOURCE_TREE ${WITH_SOURCE_TREE} CACHE INTERNAL "WITH_SOURCE_TREE support enabled.")
+ else()
+ message("* Show source tree : No (default)")
+
+ message("")
+ message(" *** WITH_SOURCE_TREE - WARNING!")
+ message(" *** This functionality is ONLY supported on CMake 2.8.12 or higher.")
+ message(" *** You are running ${CMAKE_VERSION}, which does not have the functions needed")
+ message(" *** to create a sourcetree - this option is thus forced to disabled!")
+ message("")
+
+ set(_WITH_SOURCE_TREE "" CACHE INTERNAL "WITH_SOURCE_TREE support disabled.")
+ endif()
+else()
+ message("* Show source tree : No (default)")
+ set(_WITH_SOURCE_TREE "" CACHE INTERNAL "WITH_SOURCE_TREE support disabled.")
+endif()
+
if ( WITHOUT_GIT )
message("* Use GIT revision hash : No")
message("")