diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 4d76f89d1..c641f1970 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -120,6 +120,21 @@ SET(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will # default build type is none SET (CMAKE_BUILD_TYPE "" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") + +# Add these settings to the cache. +SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING + "Flags used by the compiler during all build types.") +SET (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING + "Flags used by the compiler during debug builds.") +SET (CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}" CACHE STRING + "Flags used by the compiler during release minsize builds.") +SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING + "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" CACHE STRING + "Flags used by the compiler during Release with Debug Info builds.") +SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING + "Flags for C compiler.") + MARK_AS_ADVANCED( CMAKE_VERBOSE_MAKEFILE CMAKE_CXX_FLAGS diff --git a/Modules/Platform/HP-UX.cmake b/Modules/Platform/HP-UX.cmake index 0f123b0e0..ebc370a84 100644 --- a/Modules/Platform/HP-UX.cmake +++ b/Modules/Platform/HP-UX.cmake @@ -41,17 +41,11 @@ ELSE(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,+b") # -rpath SET(CMAKE_SHARED_LIBRARY_CXX_FLAGS "-fPIC") # -pic - SET (CMAKE_CXX_FLAGS "" CACHE STRING - "Flags used by the compiler during all build types.") - SET (CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING - "Flags used by the compiler during debug builds.") - SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3" CACHE STRING - "Flags used by the compiler during release minsize builds.") - SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING - "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") - SET (CMAKE_C_FLAGS "" CACHE STRING - "Flags for C compiler.") + SET (CMAKE_CXX_FLAGS "") + SET (CMAKE_CXX_FLAGS_DEBUG "-g") + SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3") + SET (CMAKE_CXX_FLAGS_RELEASE "-O2") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-g") + SET (CMAKE_C_FLAGS "") ENDIF(CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/Platform/IRIX.cmake b/Modules/Platform/IRIX.cmake index 62c374c30..8c720ab7c 100644 --- a/Modules/Platform/IRIX.cmake +++ b/Modules/Platform/IRIX.cmake @@ -6,23 +6,12 @@ SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP "") # : or empty IF(NOT CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_CREATE_STATIC_LIBRARY " -ar -o ") - SET (CMAKE_CXX_FLAGS "" CACHE STRING - "Flags used by the compiler during all build types.") - - SET (CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING - "Flags used by the compiler during debug builds.") - - SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3" CACHE STRING - "Flags used by the compiler during release minsize builds.") - - SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING - "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") - - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") - - SET (CMAKE_C_FLAGS "" CACHE STRING - "Flags for C compiler.") + SET (CMAKE_CXX_FLAGS "") + SET (CMAKE_CXX_FLAGS_DEBUG "-g") + SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3") + SET (CMAKE_CXX_FLAGS_RELEASE "-O2") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2") + SET (CMAKE_C_FLAGS "") ELSE(NOT CMAKE_COMPILER_IS_GNUCXX) INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake) ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/Platform/IRIX64.cmake b/Modules/Platform/IRIX64.cmake index 5ff106584..eed0e2a28 100644 --- a/Modules/Platform/IRIX64.cmake +++ b/Modules/Platform/IRIX64.cmake @@ -7,24 +7,12 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_CREATE_STATIC_LIBRARY " -ar -o ") SET(CMAKE_ANSI_CXXFLAGS -LANG:std) - SET (CMAKE_CXX_FLAGS "" CACHE STRING - "Flags used by the compiler during all build types.") - - SET (CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING - "Flags used by the compiler during debug builds.") - - SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3" CACHE STRING - "Flags used by the compiler during release minsize builds.") - - SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING - "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") - - SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") - - - SET (CMAKE_C_FLAGS "" CACHE STRING - "Flags for C compiler.") + SET (CMAKE_CXX_FLAGS "") + SET (CMAKE_CXX_FLAGS_DEBUG "-g") + SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3") + SET (CMAKE_CXX_FLAGS_RELEASE "-O2") + SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2") + SET (CMAKE_C_FLAGS "") ELSE(NOT CMAKE_COMPILER_IS_GNUCXX) INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake) ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX) diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index b3091b71b..2085c93d7 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -1,7 +1,9 @@ +# GCC is the default compiler on Linux. +INCLUDE(${CMAKE_ROOT}/Modules/Platform/gcc.cmake) + SET(CMAKE_DL_LIBS "-ldl") SET(CMAKE_SHARED_LIBRARY_C_FLAGS "-fPIC") SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared") SET(CMAKE_SHARED_LIBRARY_LINK_FLAGS "-rdynamic") SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG "-Wl,-rpath,") SET(CMAKE_SHARED_LIBRARY_RUNTIME_FLAG_SEP ":") - diff --git a/Modules/Platform/Windows-bcc32.cmake b/Modules/Platform/Windows-bcc32.cmake index 744e44c96..4b2028f80 100644 --- a/Modules/Platform/Windows-bcc32.cmake +++ b/Modules/Platform/Windows-bcc32.cmake @@ -49,24 +49,12 @@ SET(CMAKE_CREATE_WIN32_EXE -tW -tWM ) # extra flags for a console app SET(CMAKE_CREATE_CONSOLE_EXE -tWC ) -SET (CMAKE_CXX_FLAGS "-w- -whid -waus -wpar -tWM -P" CACHE STRING - "Flags used to compile c++ files.") - -SET (CMAKE_CXX_FLAGS_DEBUG "-Od -v" CACHE STRING - "Flags used by the compiler during debug builds.") - -SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O1" CACHE STRING - "Flags used by the compiler during release minsize builds.") - -SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING - "Release flags.") - -SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Od" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") - - -SET (CMAKE_C_FLAGS "-w- -whid -waus -tWM" CACHE STRING - "Flags for C compiler.") +SET (CMAKE_CXX_FLAGS "-w- -whid -waus -wpar -tWM -P") +SET (CMAKE_CXX_FLAGS_DEBUG "-Od -v") +SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O1") +SET (CMAKE_CXX_FLAGS_RELEASE "-O2") +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Od") +SET (CMAKE_C_FLAGS "-w- -whid -waus -tWM") SET (CMAKE_STANDARD_LIBRARIES "import32.lib" CACHE STRING "Libraries linked by defalut with all applications.") diff --git a/Modules/Platform/Windows-cl.cmake b/Modules/Platform/Windows-cl.cmake index bf274fa88..0881bf485 100644 --- a/Modules/Platform/Windows-cl.cmake +++ b/Modules/Platform/Windows-cl.cmake @@ -42,24 +42,12 @@ SET (CMAKE_BUILD_TYPE Debug CACHE STRING SET(CMAKE_CREATE_WIN32_EXE /subsystem:windows) -SET (CMAKE_CXX_FLAGS "/nologo /W3 /Zm1000 /GX /GR" CACHE STRING - "Flags used by the compiler during all build types, /GX /GR are for exceptions and rtti in VC++, /Zm1000 increases the compiler's memory allocation to support ANSI C++/stdlib.") - -SET (CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Od /GZ" CACHE STRING - "Flags used by the compiler during debug builds.") - -SET (CMAKE_CXX_FLAGS_MINSIZEREL "/MD /O1" CACHE STRING - "Flags used by the compiler during release minsize builds.") - -SET (CMAKE_CXX_FLAGS_RELEASE "/MD /O2" CACHE STRING - "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") - -SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /O2" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") - - -SET (CMAKE_C_FLAGS "/nologo /W3 /Zm1000" CACHE STRING - "Flags for C compiler.") +SET (CMAKE_CXX_FLAGS "/nologo /W3 /Zm1000 /GX /GR") +SET (CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Od /GZ") +SET (CMAKE_CXX_FLAGS_MINSIZEREL "/MD /O1") +SET (CMAKE_CXX_FLAGS_RELEASE "/MD /O2") +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MD /Zi /O2") +SET (CMAKE_C_FLAGS "/nologo /W3 /Zm1000") SET (CMAKE_STANDARD_LIBRARIES "kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib" CACHE STRING "Libraries linked by defalut with all applications.") diff --git a/Modules/Platform/gcc.cmake b/Modules/Platform/gcc.cmake index 55612bdf0..62b3c2e37 100644 --- a/Modules/Platform/gcc.cmake +++ b/Modules/Platform/gcc.cmake @@ -1,18 +1,6 @@ -SET (CMAKE_CXX_FLAGS "" CACHE STRING - "Flags used by the compiler during all build types.") - -SET (CMAKE_CXX_FLAGS_DEBUG "-g" CACHE STRING - "Flags used by the compiler during debug builds.") - -SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3" CACHE STRING - "Flags used by the compiler during release minsize builds.") - -SET (CMAKE_CXX_FLAGS_RELEASE "-O2" CACHE STRING - "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).") - -SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds.") - - -SET (CMAKE_C_FLAGS "" CACHE STRING - "Flags for C compiler.") +SET (CMAKE_CXX_FLAGS "") +SET (CMAKE_CXX_FLAGS_DEBUG "-g") +SET (CMAKE_CXX_FLAGS_MINSIZEREL "-O3") +SET (CMAKE_CXX_FLAGS_RELEASE "-O2") +SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") +SET (CMAKE_C_FLAGS "")