Skip to content

Commit

Permalink
Applied a few cmake updates from TC. Should fix the blank version has…
Browse files Browse the repository at this point in the history
…h inside the core.

Signed-off-by: SkyFire <[email protected]>
  • Loading branch information
SkyFire committed Aug 24, 2013
1 parent d5d7cd6 commit 8fb0541
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 22 deletions.
26 changes: 26 additions & 0 deletions cmake/compiler/clang/settings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright (C) 2011-2013 Project SkyFire <http://www.projectskyfire.org/>
# Copyright (C) 2008-2013 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.

# Set build-directive (used in core to tell which buildtype we used)
add_definitions(-D_BUILD_DIRECTIVE='"$(CONFIGURATION)"')

if(WITH_WARNINGS)
set(WARNING_FLAGS "-W -Wall -Wextra -Winit-self -Wfatal-errors")
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()
20 changes: 10 additions & 10 deletions cmake/compiler/gcc/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@
# 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)

if(PLATFORM EQUAL 32)
# Required on 32-bit systems to enable SSE2 (standard on x64)
add_definitions(-msse2 -mfpmath=sse)
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: SSE2 flags forced")
message(STATUS "GCC: SFMT enabled, SSE2 flags forced")

if( WITH_WARNINGS )
add_definitions(-Wall -Wfatal-errors -Wextra)
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")
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)")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3")
message(STATUS "GCC: Debug-flags set (-g3)")
endif()
7 changes: 2 additions & 5 deletions cmake/compiler/icc/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# 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)
Expand All @@ -20,10 +20,7 @@ endif()

if( WITH_WARNINGS )
add_definitions(-w1)
message(STATUS "ICC All warnings enabled")
else()
add_definitions(-w)
message(STATUS "ICC: All warnings disabled")
message(STATUS "ICC: All warnings enabled")
endif()

if( WITH_COREDEBUG )
Expand Down
38 changes: 38 additions & 0 deletions cmake/compiler/mingw/settings.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (C) 2011-2013 Project SkyFire <http://www.projectskyfire.org/>
# Copyright (C) 2008-2013 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.

# 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()
1 change: 1 addition & 0 deletions cmake/compiler/xcode/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

# Set build-directive (used in core to tell which buildtype we used)

add_definitions(-D_BUILD_DIRECTIVE='"$(CONFIGURATION)"')
3 changes: 2 additions & 1 deletion cmake/genrev.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# 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.

if(NOT BUILDDIR)
# Workaround for funny MSVC behaviour - this segment only run during compile
Expand Down
48 changes: 48 additions & 0 deletions cmake/macros/FindGit.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright (C) 2011-2013 Project SkyFire <http://www.projectskyfire.org/>
# Copyright (C) 2008-2013 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.

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()
1 change: 1 addition & 0 deletions cmake/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ 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)
option(WITHOUT_GIT "Disable the GIT testing routines" 0)
9 changes: 7 additions & 2 deletions cmake/platform/unix/settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@

# Package overloads - Linux
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(JEMALLOC_LIBRARY "jemalloc")
if (NOT NOJEM)
set(JEMALLOC_LIBRARY "jemalloc")
message(STATUS "UNIX: Using jemalloc")
endif()
endif()

# set default configuration directory
Expand Down Expand Up @@ -45,6 +48,8 @@ if(CMAKE_C_COMPILER MATCHES "gcc")
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")
include(${CMAKE_SOURCE_DIR}/cmake/compiler/clang/settings.cmake)
else()
add_definitions(-D_BUILD_DIRECTIVE='"${CMAKE_BUILD_TYPE}"')
add_definitions(-D_BUILD_DIRECTIVE='"${CMAKE_BUILD_TYPE}"')
endif()
5 changes: 2 additions & 3 deletions cmake/showoptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

# output generic information about the core and buildtype chosen
message("")
message("* SkyFireEMU revision: ${rev_hash} ${rev_date} (${rev_branch} branch)")

message("* SkyFireEMU revision : ${rev_hash} ${rev_date} (${rev_branch} branch)")
if( UNIX )
message("* SkyFireEMU buildtype : ${CMAKE_BUILD_TYPE}")
endif()
Expand Down Expand Up @@ -89,7 +88,6 @@ if( WIN32 )
endif()
endif( WIN32 )


if ( WITHOUT_GIT )
message("* Use GIT revision hash : No")
message("")
Expand All @@ -114,3 +112,4 @@ if ( NOJEM )
endif()

message("")

31 changes: 31 additions & 0 deletions cmake/stack_direction.c
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion src/genrev/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@

# Need to pass old ${CMAKE_BINARY_DIR} as param because its different at build stage
add_custom_target(revision.h ALL
COMMAND ${CMAKE_COMMAND} -DBUILDDIR=${CMAKE_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/genrev.cmake
COMMAND ${CMAKE_COMMAND} -DNO_GIT=${WITHOUT_GIT} -DGIT_EXEC=${GIT_EXECUTABLE} -DBUILDDIR=${CMAKE_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/genrev.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

0 comments on commit 8fb0541

Please sign in to comment.