From b1cafabb017083fc9fd74dbc134b82c4396cf575 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Thu, 6 Feb 2014 19:14:14 -0800 Subject: [PATCH] - added cmake compile warning when users uses clang as clang currently does NOT support some critical GCC settings we require. --- CMakeLists.txt | 33 +++++++++++++++++++++++++--- mk/cmake/Modules/SpecialMacros.cmake | 26 +++++++++++++++++----- source/glest_game/world/world.h | 3 +++ 3 files changed, 53 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1756b047c..48e4beaad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,8 @@ MESSAGE(STATUS "Build type for this compile will be: ${CMAKE_BUILD_TYPE}") IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") SET(CMAKE_COMPILER_IS_GNUCXX "YES") - ADD_DEFINITIONS("-Qunused-arguments -Wno-switch") +# ADD_DEFINITIONS("-Qunused-arguments -Wno-switch") + ADD_DEFINITIONS("-Wno-switch") ENDIF() OPTION(BUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS "Build model import/export tools" ON) @@ -98,15 +99,34 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW) # Default compiler flags #SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s") ## Strip binary + # Common generic GNU type compiler options that work with all generic GCC compatible compilers + ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing") + # For gcc warning options see: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html IF(NOT MINGW) # For tons of verbose warnings add: -Wall # ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -rdynamic") - ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -rdynamic") +# ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -rdynamic") ELSE() # ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -DUNICODE") - ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -DUNICODE") +# ADD_DEFINITIONS("-Wuninitialized -Wsign-compare -Wunused-function -Wunused-variable -Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -DUNICODE") + ADD_DEFINITIONS("-DUNICODE") + ENDIF() + + # CLang specific Compiler Options + IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + + # GCC specific Compiler Options + ELSE() + ADD_DEFINITIONS("-frounding-math -fsignaling-nans") + +# IF(NOT MINGW) +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -rdynamic") +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -rdynamic") +# ENDIF() + ENDIF() + #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") #MESSAGE(STATUS "*TEST: Checking for max SSE LEVEL [${MAX_SSE_LEVEL_DESIRED}]") @@ -346,6 +366,13 @@ IF(EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/CMakeLists.txt") ADD_SUBDIRECTORY( ${PROJECT_SOURCE_DIR}/data/glest_game ) ENDIF() +#get_directory_property( DirDefs COMPILE_DEFINITIONS ) +#MESSAGE(STATUS ">>>> NOTICE Compiler definitions used: ${DirDefs}") +#MESSAGE(STATUS "END of compile defs...") +IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + MESSAGE(WARNING ">> CLANG is NOT currently compatible as it does not support the following essential GCC compiler settings: -frounding-math -fsignaling-nans") +ENDIF() + SET(CPACK_GENERATOR "DEB") SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Mark Vejvoda") #required SET(CPACK_DEBIAN_PACKAGE_DEPENDS " diff --git a/mk/cmake/Modules/SpecialMacros.cmake b/mk/cmake/Modules/SpecialMacros.cmake index 410dc9378..61b3eacb5 100644 --- a/mk/cmake/Modules/SpecialMacros.cmake +++ b/mk/cmake/Modules/SpecialMacros.cmake @@ -75,14 +75,28 @@ macro(special_check_for_sse _max_sse_level_desired) set(CMAKE_REQUIRED_FLAGS) if(HAS_SSE3_EXTENSIONS AND (${_max_sse_level_desired} MATCHES "3")) - set(SSE_FLAGS "-msse3 -mfpmath=sse") - message(STATUS "Found SSE3 extensions, using flags: ${SSE_FLAGS}") + set(SSE_FLAGS "-msse3") + IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + ELSE() + set(SSE_FLAGS "${SSE_FLAGS} -mfpmath=sse") + ENDIF() + message(STATUS "Found SSE3 extensions, using flags: ${SSE_FLAGS}") elseif(HAS_SSE2_EXTENSIONS AND (${_max_sse_level_desired} MATCHES "2" OR ${_max_sse_level_desired} MATCHES "3")) - set(SSE_FLAGS "-msse2 -mfpmath=sse") - message(STATUS "Found SSE2 extensions, using flags: ${SSE_FLAGS}") + set(SSE_FLAGS "-msse2") + IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + ELSE() + set(SSE_FLAGS "${SSE_FLAGS} -mfpmath=sse") + ENDIF() + + message(STATUS "Found SSE2 extensions, using flags: ${SSE_FLAGS}") elseif(HAS_SSE_EXTENSIONS AND (${_max_sse_level_desired} MATCHES "1" OR ${_max_sse_level_desired} MATCHES "2" OR ${_max_sse_level_desired} MATCHES "3")) - set(SSE_FLAGS "-msse -mfpmath=sse") - message(STATUS "Found SSE extensions, using flags: ${SSE_FLAGS}") + set(SSE_FLAGS "-msse") + IF ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + ELSE() + set(SSE_FLAGS "${SSE_FLAGS} -mfpmath=sse") + ENDIF() + + message(STATUS "Found SSE extensions, using flags: ${SSE_FLAGS}") endif() add_definitions(${SSE_FLAGS}) diff --git a/source/glest_game/world/world.h b/source/glest_game/world/world.h index 101188d02..268fe0c27 100644 --- a/source/glest_game/world/world.h +++ b/source/glest_game/world/world.h @@ -147,6 +147,9 @@ private: public: World(); ~World(); +// World & World(World &obj) { +// throw runtime_error("class World is NOT safe to assign!"); +// } void cleanup(); void end(); //to die before selection does void endScenario(); //to die before selection does