diff --git a/CMakeLists.txt b/CMakeLists.txt index a5833d0684..31d612bd5b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -247,14 +247,6 @@ if(UNIX) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} --no-warnings") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -Wfatal-errors -Wextra") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wfatal-errors -Wextra") -elseif(WIN32) - # Disable warnings in Visual Studio 8 and above and add /MP - if(MSVC AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267 /MP") - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996 /wd4355 /wd4244 /wd4267 /MP") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267 /MP") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267 /MP") - endif() endif() # if(SQL) @@ -269,14 +261,6 @@ endif() # message(STATUS "Build map/vmap tools : No (default)") # endif() -# Some small tweaks for Visual Studio 7 and above. -if(MSVC) - # Mark 32 bit executables large address aware so they can use > 2GB address space - if(PLATFORM MATCHES X86) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE") - endif() -endif() - # Generate revision-extractor set(GENREV_SRC src/tools/genrevision/genrevision.cpp @@ -355,7 +339,6 @@ set(DEFINITIONS_DEBUG _DEBUG MANGOS_DEBUG) if(WIN32) set(DEFINITIONS ${DEFINITIONS} WIN32 _WIN32) - set(DEFINITIONS_RELEASE ${DEFINITIONS_RELEASE} _CRT_SECURE_NO_WARNINGS) endif() if(USE_STD_MALLOC) diff --git a/cmake/compiler/msvc/settings.cmake b/cmake/compiler/msvc/settings.cmake new file mode 100644 index 0000000000..a1b7014bb5 --- /dev/null +++ b/cmake/compiler/msvc/settings.cmake @@ -0,0 +1,44 @@ +if(PLATFORM EQUAL X64) + # 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") + + #Enable extended object support for debug compiles on X64 (not required on X86) + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj") + message(STATUS "MSVC: Enabled extended object-support for debug-compiles") +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") +endif() + +# multithreaded compiling on VS +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + +# 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") + +# disable warnings in Visual Studio 8 and above if not wanted +if(NOT WARNINGS) + if(MSVC AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267 /wd4619") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4996 /wd4355 /wd4244 /wd4985 /wd4267 /wd4619") + message(STATUS "MSVC: Disabled generic compiletime warnings") + endif() +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) diff --git a/cmake/macros/CheckPlatform.cmake b/cmake/macros/CheckPlatform.cmake index 7001d4caf8..1b2289581f 100644 --- a/cmake/macros/CheckPlatform.cmake +++ b/cmake/macros/CheckPlatform.cmake @@ -1,18 +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 X64) - # 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. - if(WIN32) - add_definitions("-D_WIN64") - endif() message(STATUS "Detected 64-bit platform") else() set(PLATFORM X86) message(STATUS "Detected 32-bit platform") endif() -if(UNIX) +if(WIN32) + include("${CMAKE_SOURCE_DIR}/cmake/platform/win/settings.cmake") +elseif(UNIX) include("${CMAKE_SOURCE_DIR}/cmake/platform/unix/settings.cmake") endif() diff --git a/cmake/options.cmake b/cmake/options.cmake index cda32ce7ee..dbefa3ed47 100644 --- a/cmake/options.cmake +++ b/cmake/options.cmake @@ -1,4 +1,5 @@ -option(DEBUG "Debug mode" OFF) +option(DEBUG "Include additional debug-code in core" OFF) +option(WARNINGS "Show all warnings during compile" OFF) option(TBB_USE_EXTERNAL "Use external TBB" OFF) option(USE_STD_MALLOC "Use standard malloc instead of TBB" OFF) option(ACE_USE_EXTERNAL "Use external ACE" OFF) @@ -22,7 +23,8 @@ message( Options that can be used in order to configure the process: CMAKE_INSTALL_PREFIX Path where the server should be installed to PCH Use precompiled headers - DEBUG Debug mode + DEBUG Include additional debug-code in core + WARNINGS Show all warnings during compile INCLUDE_BINDINGS_DIR Include a script library in src/bindings/ with the defined name. the name must corespond to the name of the folder and the folder must contain a valid diff --git a/cmake/platform/win/settings.cmake b/cmake/platform/win/settings.cmake new file mode 100644 index 0000000000..89c36a6f39 --- /dev/null +++ b/cmake/platform/win/settings.cmake @@ -0,0 +1,3 @@ +if ( MSVC ) + include(${CMAKE_SOURCE_DIR}/cmake/compiler/msvc/settings.cmake) +endif()