summaryrefslogtreecommitdiff
path: root/Modules/CMakeCInformation.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/CMakeCInformation.cmake')
-rw-r--r--Modules/CMakeCInformation.cmake53
1 files changed, 27 insertions, 26 deletions
diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake
index ce5ce4409..71aadb474 100644
--- a/Modules/CMakeCInformation.cmake
+++ b/Modules/CMakeCInformation.cmake
@@ -1,16 +1,6 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
-#=============================================================================
-# Copyright 2004-2011 Kitware, Inc.
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
# This file sets the basic flags for the C language in CMake.
# It also loads the available platform file for the system-compiler
@@ -18,6 +8,8 @@
# It also loads a system - compiler - processor (or target hardware)
# specific file, which is mainly useful for crosscompiling and embedded systems.
+include(CMakeLanguageInformation)
+
# some compilers use different extensions (e.g. sdcc uses .rel)
# so set the extension here first so it can be overridden by the compiler specific file
if(UNIX)
@@ -34,7 +26,7 @@ if(CMAKE_C_COMPILER_ID)
endif()
set(CMAKE_BASE_NAME)
-get_filename_component(CMAKE_BASE_NAME ${CMAKE_C_COMPILER} NAME_WE)
+get_filename_component(CMAKE_BASE_NAME "${CMAKE_C_COMPILER}" NAME_WE)
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_BASE_NAME gcc)
endif()
@@ -60,6 +52,12 @@ if (NOT _INCLUDED_FILE)
include(Platform/${CMAKE_SYSTEM_NAME}-${CMAKE_BASE_NAME}
OPTIONAL RESULT_VARIABLE _INCLUDED_FILE)
endif ()
+
+# load any compiler-wrapper specific information
+if (CMAKE_C_COMPILER_WRAPPER)
+ __cmake_include_compiler_wrapper(C)
+endif ()
+
# We specify the compiler information in the system file for some
# platforms, but this language may not have been enabled when the file
# was first included. Include it again to get the language info.
@@ -103,32 +101,35 @@ if(NOT CMAKE_MODULE_EXISTS)
endif()
set(CMAKE_C_FLAGS_INIT "$ENV{CFLAGS} ${CMAKE_C_FLAGS_INIT}")
-# avoid just having a space as the initial value for the cache
-if(CMAKE_C_FLAGS_INIT STREQUAL " ")
- set(CMAKE_C_FLAGS_INIT)
-endif()
+
+foreach(c "" _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO)
+ string(STRIP "${CMAKE_C_FLAGS${c}_INIT}" CMAKE_C_FLAGS${c}_INIT)
+endforeach()
+
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_INIT}" CACHE STRING
"Flags used by the compiler during all build types.")
if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
-# default build type is none
- if(NOT CMAKE_NO_BUILD_TYPE)
+ get_property(_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ # default build type is none
+ if(NOT _GENERATOR_IS_MULTI_CONFIG AND NOT CMAKE_NO_BUILD_TYPE)
set (CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE_INIT} CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.")
endif()
+ unset(_GENERATOR_IS_MULTI_CONFIG)
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG_INIT}" CACHE STRING
"Flags used by the compiler during debug builds.")
set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL_INIT}" CACHE STRING
- "Flags used by the compiler during release minsize builds.")
+ "Flags used by the compiler during release builds for minimum size.")
set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE_INIT}" CACHE STRING
- "Flags used by the compiler during release builds (/MD /Ob1 /Oi /Ot /Oy /Gs will produce slightly less optimized but smaller files).")
+ "Flags used by the compiler during release builds.")
set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO_INIT}" CACHE STRING
- "Flags used by the compiler during Release with Debug Info builds.")
+ "Flags used by the compiler during release builds with debug info.")
endif()
if(CMAKE_C_STANDARD_LIBRARIES_INIT)
set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES_INIT}"
- CACHE STRING "Libraries linked by defalut with all C applications.")
+ CACHE STRING "Libraries linked by default with all C applications.")
mark_as_advanced(CMAKE_C_STANDARD_LIBRARIES)
endif()
@@ -175,10 +176,10 @@ endif()
# Create a static archive incrementally for large object file counts.
# If CMAKE_C_CREATE_STATIC_LIBRARY is set it will override these.
if(NOT DEFINED CMAKE_C_ARCHIVE_CREATE)
- set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qc <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_C_ARCHIVE_APPEND)
- set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_C_ARCHIVE_FINISH)
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
@@ -187,7 +188,7 @@ endif()
# compile a C file into an object file
if(NOT CMAKE_C_COMPILE_OBJECT)
set(CMAKE_C_COMPILE_OBJECT
- "<CMAKE_C_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
+ "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
endif()
if(NOT CMAKE_C_LINK_EXECUTABLE)