Permalink
Browse files

Enabled compiler warnings in GCC

  • Loading branch information...
1 parent 2e8b3dd commit 3e4128ed5a12c0b46c67301da63d2daab959892d @andrewfenn committed Apr 27, 2012
Showing with 48 additions and 50 deletions.
  1. +37 −5 CMakeLists.txt
  2. +0 −32 cmake/scripts/addLibraryHelper.cmake
  3. +11 −13 code/client/CMakeLists.txt
View
@@ -18,11 +18,6 @@ set(abi_version ${HARDWAR_VERSION_STRING})
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/lib)
-# Set compiler specific build flags
-IF (UNIX)
- add_definitions(-msse -O3)
-ENDIF()
-
if(WIN32)
set(CMAKE_DEBUG_POSTFIX "_d")
endif(WIN32)
@@ -47,6 +42,43 @@ if((NOT "${OGRE_VERSION_NAME}" STREQUAL "Byatis") AND (NOT "${OGRE_VERSION_NAME}
message(SEND_ERROR "You need Ogre 1.8 Byatis or later to build this.")
endif()
+if(CMAKE_BUILD_TYPE STREQUAL "")
+ # CMake defaults to leaving CMAKE_BUILD_TYPE empty. This screws up
+ # differentiation between debug and release builds.
+ set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None (CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
+endif ()
+
+message(STATUS "Build type set to: ${CMAKE_BUILD_TYPE}")
+
+#if(CMAKE_BUILD_TYPE STREQUAL "Debug")
+# if (UNIX)
+# add_definitions(-O1 -g)
+# endif()
+#elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
+# if (UNIX)
+# add_definitions(-msse -O3)
+# endif()
+#endif ()
+
+if(UNIX AND NOT APPLE)
+ # Newer ld versions need this linked explicitly
+ find_package(Threads REQUIRED)
+ add_definitions(${CMAKE_THREAD_LIBS_INIT})
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}-Wl,--no-as-needed ${CMAKE_THREAD_LIBS_INIT}")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}-Wl,--no-as-needed ${CMAKE_THREAD_LIBS_INIT}")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}-Wl,--no-as-needed ${CMAKE_THREAD_LIBS_INIT}")
+endif(UNIX AND NOT APPLE)
+
+if(APPLE)
+ # Newer ld versions need this linked explicitly
+ find_package(Threads REQUIRED)
+ add_definitions(${CMAKE_THREAD_LIBS_INIT})
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}-Wl ${CMAKE_THREAD_LIBS_INIT}")
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}-Wl ${CMAKE_THREAD_LIBS_INIT}")
+ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}-Wl
+${CMAKE_THREAD_LIBS_INIT}")
+endif(APPLE)
+
if(APPLE)
find_package(CG REQUIRED)
endif(APPLE)
@@ -1,32 +0,0 @@
-macro(MACRO_FIND_LIBRARIES _package _components)
- FIND_PACKAGE(${_package} COMPONENTS ${_components} REQUIRED)
- __MACRO_FIND_LIBRARY(${_package})
-endmacro ()
-
-macro(MACRO_FIND_LIBRARY _package)
- FIND_PACKAGE(${_package} REQUIRED)
- __MACRO_FIND_LIBRARY(${_package})
-endmacro ()
-
-macro(__MACRO_FIND_LIBRARY _package)
- if (${_package}_FOUND)
- INCLUDE_DIRECTORIES(${${_package}_INCLUDE_DIR})
- INCLUDE_DIRECTORIES(${${_package}_INCLUDE_DIRS})
- LINK_DIRECTORIES(${${_package}_LIBRARY_DIRS})
-
- message(STATUS "${_package} Found")
- if (${_package}_LIBRARY)
- message(STATUS " library : ${${_package}_LIBRARY}")
- endif ()
- message(STATUS " includes : ${${_package}_INCLUDE_DIR}")
- else ()
- message(ERROR "\t${_package} not found.\n")
- endif ()
-endmacro ()
-
-macro(MACRO_ADD_LIBRARY _package _binary)
- if (${_package}_FOUND)
- TARGET_LINK_LIBRARIES(${_binary} ${${_package}_LIBRARIES})
- TARGET_LINK_LIBRARIES(${_binary} ${${_package}_LIBRARY})
- endif ()
-endmacro ()
View
@@ -29,19 +29,13 @@ include_directories(
${HARDWAR_SOURCE_DIR}/code/shared/include
)
-include_directories(${OGRE_INCLUDE_DIRS})
-include_directories(${DEPENDENCIES_INCLUDES})
-include_directories(${OIS_INCLUDE_DIRS})
-include_directories(${MYGUI_INCLUDE_DIRS})
-include_directories(${OGRE_Terrain_INCLUDE_DIR})
-include_directories(${OGRE_Paging_INCLUDE_DIR})
-include_directories(${Boost_INCLUDE_DIR})
-
-
-#INCLUDE(addLibraryHelper)
-
-#MACRO_FIND_LIBRARY(OIS)
-#MACRO_FIND_LIBRARY(MYGUI)
+include_directories(SYSTEM ${OGRE_INCLUDE_DIRS})
+include_directories(SYSTEM ${DEPENDENCIES_INCLUDES})
+include_directories(SYSTEM ${OIS_INCLUDE_DIRS})
+include_directories(SYSTEM ${MYGUI_INCLUDE_DIRS})
+include_directories(SYSTEM ${OGRE_Terrain_INCLUDE_DIR})
+include_directories(SYSTEM ${OGRE_Paging_INCLUDE_DIR})
+include_directories(SYSTEM ${Boost_INCLUDE_DIR})
if (MSVC)
MESSAGE(STATUS "Using GetText in dependencies")
@@ -75,3 +69,7 @@ target_link_libraries(client
${Boost_LIBRARIES}
)
+if (UNIX)
+ add_definitions(-Wall -pedantic -Wextra -Wwrite-strings)
+endif()
+

0 comments on commit 3e4128e

Please sign in to comment.