Merge topic 'features-cleanups'

f0a0f3dc WCDH: Fix compiler id test for compatibility macros.
627ad96b Project: Detect other compilers before detecting Clang.
bc950169 WCDH: Remove noise from generated defines.
eecd93fc Features: Escape the COMPILE_OPTIONS for dialects.
This commit is contained in:
Brad King 2014-06-16 08:54:48 -04:00 committed by CMake Topic Stage
commit e2789429aa
4 changed files with 23 additions and 20 deletions

View File

@ -166,11 +166,11 @@ symbol, and compiler support determines what it is expanded to:
virtual void Execute() = 0;
};
struct Concrete Foo_CXX_FINAL {
void Execute() Foo_CXX_OVERRIDE;
struct Concrete Foo_FINAL {
void Execute() Foo_OVERRIDE;
};
In this case, ``Foo_CXX_FINAL`` will expand to ``final`` if the
In this case, ``Foo_FINAL`` will expand to ``final`` if the
compiler supports the keyword, or to empty otherwise.
In this use-case, the CMake code will wish to enable a particular language
@ -189,13 +189,13 @@ set to influence all following targets:
cxx_final cxx_override
)
# Includes foo_compiler_detection.h and uses the Foo_DECL_CXX_FINAL symbol
# Includes foo_compiler_detection.h and uses the Foo_FINAL symbol
# which will expand to 'final' if the compiler supports the requested
# CXX_STANDARD.
add_library(foo foo.cpp)
set_property(TARGET foo PROPERTY CXX_STANDARD 11)
# Includes foo_compiler_detection.h and uses the Foo_DECL_CXX_FINAL symbol
# Includes foo_compiler_detection.h and uses the Foo_FINAL symbol
# which will expand to 'final' if the compiler supports the feature,
# even though CXX_STANDARD is not set explicitly. The requirement of
# cxx_constexpr causes CMake to set CXX_STANDARD internally, which

View File

@ -61,8 +61,6 @@ function(compiler_id_detection outvar lang)
list(APPEND ordered_compilers
Intel
PathScale
AppleClang
Clang
Embarcadero
Borland
Watcom
@ -84,6 +82,8 @@ function(compiler_id_detection outvar lang)
endif()
list(APPEND ordered_compilers
SCO
AppleClang
Clang
GNU
MSVC
ADSP

View File

@ -99,14 +99,14 @@
#
# .. code-block:: c++
#
# class MyClass ClimbingStats_DECL_CXX_FINAL
# class MyClass ClimbingStats_FINAL
# {
# ClimbingStats_DECL_CXX_CONSTEXPR int someInterface() { return 42; }
# ClimbingStats_CONSTEXPR int someInterface() { return 42; }
# };
#
# The ``ClimbingStats_DECL_CXX_FINAL`` macro will expand to ``final`` if the
# The ``ClimbingStats_FINAL`` macro will expand to ``final`` if the
# compiler (and its flags) support the ``cxx_final`` feature, and the
# ``ClimbingStats_DECL_CXX_CONSTEXPR`` macro will expand to ``constexpr``
# ``ClimbingStats_CONSTEXPR`` macro will expand to ``constexpr``
# if ``cxx_constexpr`` is supported.
#
# The following features generate corresponding symbol defines:
@ -386,7 +386,7 @@ function(write_compiler_detection_header
\n")
endif()
if (feature STREQUAL cxx_constexpr)
set(def_value "${prefix_arg}_DECL_${feature_upper}")
set(def_value "${prefix_arg}_CONSTEXPR")
set(file_content "${file_content}
# if ${def_name}
# define ${def_value} constexpr
@ -396,7 +396,7 @@ function(write_compiler_detection_header
\n")
endif()
if (feature STREQUAL cxx_final)
set(def_value "${prefix_arg}_DECL_${feature_upper}")
set(def_value "${prefix_arg}_FINAL")
set(file_content "${file_content}
# if ${def_name}
# define ${def_value} final
@ -406,7 +406,7 @@ function(write_compiler_detection_header
\n")
endif()
if (feature STREQUAL cxx_override)
set(def_value "${prefix_arg}_DECL_${feature_upper}")
set(def_value "${prefix_arg}_OVERRIDE")
set(file_content "${file_content}
# if ${def_name}
# define ${def_value} override
@ -428,7 +428,7 @@ function(write_compiler_detection_header
set(file_content "${file_content}
# if ${def_name}
# define ${def_value} alignas(X)
# elif ${prefix_arg}_COMPILER_IS_GNU
# elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang
# define ${def_value} __attribute__ ((__aligned__(X)))
# else
# define ${def_value}
@ -440,7 +440,7 @@ function(write_compiler_detection_header
set(file_content "${file_content}
# if ${def_name}
# define ${def_value} alignof(X)
# elif ${prefix_arg}_COMPILER_IS_GNU
# elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang
# define ${def_value} __alignof__(X)
# endif
\n")
@ -495,10 +495,10 @@ function(write_compiler_detection_header
# if ${def_name}
# define ${def_value} [[deprecated]]
# define ${def_value}_MSG(MSG) [[deprecated(MSG)]]
# elif defined(__GNUC__) || defined(__clang__)
# elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang
# define ${def_value} __attribute__((__deprecated__))
# define ${def_value}_MSG(MSG) __attribute__((__deprecated__(MSG)))
# elif defined(_MSC_VER)
# elif ${prefix_arg}_COMPILER_IS_MSVC
# define ${def_value} __declspec(deprecated)
# define ${def_value}_MSG(MSG) __declspec(deprecated(MSG))
# else

View File

@ -2229,7 +2229,10 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
"does not know the compile flags to use to enable it.";
this->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str());
}
this->AppendFlags(flags, opt);
else
{
this->AppendFlagEscape(flags, opt);
}
return;
}
@ -2275,7 +2278,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
if (const char *opt = target->GetMakefile()->GetDefinition(option_flag))
{
this->AppendFlags(flags, opt);
this->AppendFlagEscape(flags, opt);
return;
}
}