aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/compiler/icc/settings.cmake2
-rw-r--r--cmake/compiler/mingw/settings.cmake27
-rw-r--r--cmake/genrev.cmake110
-rw-r--r--cmake/macros/FindGit.cmake46
-rw-r--r--cmake/options.cmake3
-rw-r--r--cmake/platform/win/settings.cmake6
-rw-r--r--cmake/showoptions.cmake28
-rw-r--r--cmake/stack_direction.c31
8 files changed, 189 insertions, 64 deletions
diff --git a/cmake/compiler/icc/settings.cmake b/cmake/compiler/icc/settings.cmake
index 58eb63b081d..133bc15e59e 100644
--- a/cmake/compiler/icc/settings.cmake
+++ b/cmake/compiler/icc/settings.cmake
@@ -1,5 +1,5 @@
# Set build-directive (used in core to tell which buildtype we used)
-add_definitions(-D_BUILD_DIRECTIVE="${CMAKE_BUILD_TYPE}")
+add_definitions(-D_BUILD_DIRECTIVE="'${CMAKE_BUILD_TYPE}'")
if(PLATFORM EQUAL 32)
add_definitions(-axSSE2)
diff --git a/cmake/compiler/mingw/settings.cmake b/cmake/compiler/mingw/settings.cmake
new file mode 100644
index 00000000000..68156bd0b6b
--- /dev/null
+++ b/cmake/compiler/mingw/settings.cmake
@@ -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()
diff --git a/cmake/genrev.cmake b/cmake/genrev.cmake
index c7a188d1993..b39a0780b1c 100644
--- a/cmake/genrev.cmake
+++ b/cmake/genrev.cmake
@@ -8,75 +8,73 @@
# 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)
+# User has manually chosen to ignore the git-tests, so throw them a warning.
+# This is done EACH compile so they can be alerted about the consequences.
-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)
+if(NOT BUILDDIR)
+ # Workaround for funny MSVC behaviour - this segment only run during compile
+ set(NO_GIT ${WITHOUT_GIT})
+ set(GIT_EXEC ${GIT_EXECUTABLE})
+ set(BUILDDIR ${CMAKE_BINARY_DIR})
endif()
-if(_GIT_VERSION_OK)
- execute_process(
- COMMAND "${_GIT_EXEC}" describe --match init --dirty=+ --abbrev=12
- 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
- )
+if(NO_GIT)
+ set(rev_date "1970-01-01 00:00:00 +0000")
+ set(rev_hash "unknown")
+ set(rev_branch "Archived")
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()
+ if(GIT_EXEC)
+ # Create a revision-string that we can use
+ execute_process(
+ COMMAND "${GIT_EXEC}" describe --match init --dirty=+ --abbrev=12
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ OUTPUT_VARIABLE rev_info
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
-# 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()
+ # And grab the commits timestamp
+ execute_process(
+ COMMAND "${GIT_EXEC}" show -s --format=%ci
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ OUTPUT_VARIABLE rev_date
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+
+ # Also retrieve branch name
+ execute_process(
+ COMMAND "${GIT_EXEC}" rev-parse --abbrev-ref HEAD
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ OUTPUT_VARIABLE rev_branch
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+ endif()
-# Its not set during initial run
-if(NOT BUILDDIR)
- set(BUILDDIR ${CMAKE_BINARY_DIR})
+ # 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 "
+ Could not find a proper repository signature (hash) - you may need to pull tags with git fetch -t
+ Continuing anyway - note that the versionstring will be set to \"unknown 1970-01-01 00:00:00 (Archived)"\")
+ set(rev_date "1970-01-01 00:00:00 +0000")
+ set(rev_hash "unknown")
+ set(rev_branch "Archived")
+ else()
+ # Extract information required to build a proper versionstring
+ string(REGEX REPLACE init-|[0-9]+-g "" rev_hash ${rev_info})
+ endif()
endif()
# Create the actual revision.h file from the above params
-if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}")
+if(NOT "${rev_hash_cached}" MATCHES "${rev_hash}" OR NOT "${rev_branch_cached}" MATCHES "${rev_branch}")
configure_file(
"${CMAKE_SOURCE_DIR}/revision.h.in.cmake"
"${BUILDDIR}/revision.h"
@ONLY
)
set(rev_hash_cached "${rev_hash}" CACHE INTERNAL "Cached commit-hash")
+ set(rev_branch_cached "${rev_branch}" CACHE INTERNAL "Cached branch name")
endif()
diff --git a/cmake/macros/FindGit.cmake b/cmake/macros/FindGit.cmake
new file mode 100644
index 00000000000..c23601dbcd8
--- /dev/null
+++ b/cmake/macros/FindGit.cmake
@@ -0,0 +1,46 @@
+# Copyright (C) 2008-2013 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_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()
diff --git a/cmake/options.cmake b/cmake/options.cmake
index 5fefbe34350..ecd58019905 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -10,8 +10,9 @@
option(SERVERS "Build worldserver and authserver" 1)
option(SCRIPTS "Build core with scripts included" 1)
-option(TOOLS "Build map/vmap extraction/assembler tools" 0)
+option(TOOLS "Build map/vmap/mmap extraction/assembler tools" 0)
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)
+option(WITHOUT_GIT "Disable the GIT testing routines" 0)
diff --git a/cmake/platform/win/settings.cmake b/cmake/platform/win/settings.cmake
index b66eb2da7bb..c0f724922e3 100644
--- a/cmake/platform/win/settings.cmake
+++ b/cmake/platform/win/settings.cmake
@@ -25,4 +25,8 @@ endif()
# endif()
#endif()
-include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
+if ( MSVC )
+ include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake)
+elseif ( MINGW )
+ include(${CMAKE_SOURCE_DIR}/cmake/compiler/mingw/settings.cmake)
+endif()
diff --git a/cmake/showoptions.cmake b/cmake/showoptions.cmake
index 47ad7b0889b..08dc2a0cfcb 100644
--- a/cmake/showoptions.cmake
+++ b/cmake/showoptions.cmake
@@ -1,7 +1,6 @@
# output generic information about the core and buildtype chosen
message("")
-message("* TrinityCore rev. hash : ${rev_hash}")
-message("* TrinityCore rev. date : ${rev_date}")
+message("* TrinityCore revision : ${rev_hash} ${rev_date} (${rev_branch} branch)")
if( UNIX )
message("* TrinityCore buildtype : ${CMAKE_BUILD_TYPE}")
endif()
@@ -34,6 +33,7 @@ endif()
if( TOOLS )
message("* Build map/vmap tools : Yes")
+ add_definitions(-DNO_CORE_FUNCS)
else()
message("* Build map/vmap tools : No (default)")
endif()
@@ -71,10 +71,28 @@ if( WIN32 )
endif()
endif( WIN32 )
+if ( WITHOUT_GIT )
+ message("* Use GIT revision hash : No")
+ message("")
+ message(" *** WITHOUT_GIT - WARNING!")
+ message(" *** By choosing the WITHOUT_GIT option you have waived all rights for support,")
+ message(" *** and accept that or all requests for support or assistance sent to the core")
+ message(" *** developers will be rejected. This due to that we will be unable to detect")
+ message(" *** what revision of the codebase you are using in a proper way.")
+ message(" *** We remind you that you need to use the repository codebase and a supported")
+ message(" *** version of git for the revision-hash to work, and be allowede to ask for")
+ message(" *** support if needed.")
+else()
+ message("* Use GIT revision hash : Yes")
+endif()
+
if ( NOJEM )
message("")
- message("*** WARNING: jemalloc linking has been disabled!")
- message("*** Please note that this is for DEBUGGING WITH VALGRIND only!")
- message("*** DO NOT DISABLE IT UNLESS YOU KNOW WHAT YOU'RE DOING!")
+ message(" *** NOJEM - WARNING!")
+ message(" *** jemalloc linking has been disabled!")
+ message(" *** Please note that this is for DEBUGGING WITH VALGRIND only!")
+ message(" *** DO NOT DISABLE IT UNLESS YOU KNOW WHAT YOU'RE DOING!")
endif()
+
message("")
+
diff --git a/cmake/stack_direction.c b/cmake/stack_direction.c
new file mode 100644
index 00000000000..11bcf803bfa
--- /dev/null
+++ b/cmake/stack_direction.c
@@ -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);
+} \ No newline at end of file