Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
6aabb6a6
Commit
6aabb6a6
authored
Dec 26, 2013
by
Stephen Kelly
Browse files
Genex: Use case-sensitive comparison for COMPILER_ID.
parent
5bb53f6b
Changes
13
Hide whitespace changes
Inline
Side-by-side
Help/manual/cmake-policies.7.rst
View file @
6aabb6a6
...
...
@@ -93,3 +93,4 @@ All Policies
/policy/CMP0041
/policy/CMP0042
/policy/CMP0043
/policy/CMP0044
Help/policy/CMP0044.rst
0 → 100644
View file @
6aabb6a6
CMP0044
-------
Case sensitive ``<LANG>_COMPILER_ID`` generator expressions
CMake 2.8.12 introduced the ``<LANG>_COMPILER_ID``
:manual:`generator expressions <cmake-generator-expressions(7)>` to allow
comparison of the :variable:`CMAKE_<LANG>_COMPILER_ID` with a test value. The
possible valid values are lowercase, but the comparison with the test value
was performed case-insensitively.
The OLD behavior for this policy is to perform a case-insensitive comparison
with the value in the ``<LANG>_COMPILER_ID`` expression. The NEW behavior
for this policy is to perform a case-sensitive comparison with the value in
the ``<LANG>_COMPILER_ID`` expression.
This policy was introduced in CMake version 3.0.0. CMake version
|release| warns when the policy is not set and uses OLD behavior. Use
the cmake_policy command to set it to OLD or NEW explicitly.
Source/cmGeneratorExpressionEvaluator.cxx
View file @
6aabb6a6
...
...
@@ -412,10 +412,32 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
return
parameters
.
front
().
empty
()
?
"1"
:
"0"
;
}
if
(
cmsysString_strcase
cmp
(
parameters
.
begin
()
->
c_str
(),
compilerId
)
==
0
)
if
(
str
cmp
(
parameters
.
begin
()
->
c_str
(),
compilerId
)
==
0
)
{
return
"1"
;
}
if
(
cmsysString_strcasecmp
(
parameters
.
begin
()
->
c_str
(),
compilerId
)
==
0
)
{
switch
(
context
->
Makefile
->
GetPolicyStatus
(
cmPolicies
::
CMP0044
))
{
case
cmPolicies
::
WARN
:
{
cmOStringStream
e
;
e
<<
context
->
Makefile
->
GetPolicies
()
->
GetPolicyWarning
(
cmPolicies
::
CMP0044
);
context
->
Makefile
->
GetCMakeInstance
()
->
IssueMessage
(
cmake
::
AUTHOR_WARNING
,
e
.
str
().
c_str
(),
context
->
Backtrace
);
}
case
cmPolicies
::
OLD
:
return
"1"
;
case
cmPolicies
::
NEW
:
case
cmPolicies
::
REQUIRED_ALWAYS
:
case
cmPolicies
::
REQUIRED_IF_USED
:
break
;
}
}
return
"0"
;
}
};
...
...
Source/cmPolicies.cxx
View file @
6aabb6a6
...
...
@@ -321,6 +321,11 @@ cmPolicies::cmPolicies()
CMP0043
,
"CMP0043"
,
"Ignore COMPILE_DEFINITIONS_<Config> properties."
,
3
,
0
,
0
,
0
,
cmPolicies
::
WARN
);
this
->
DefinePolicy
(
CMP0044
,
"CMP0044"
,
"Case sensitive <LANG>_COMPILER_ID generator expressions."
,
3
,
0
,
0
,
0
,
cmPolicies
::
WARN
);
}
cmPolicies
::~
cmPolicies
()
...
...
Source/cmPolicies.h
View file @
6aabb6a6
...
...
@@ -97,6 +97,7 @@ public:
CMP0041
,
///< Error on relative include with generator expression
CMP0042
,
///< Enable MACOSX_RPATH by default
CMP0043
,
///< Ignore COMPILE_DEFINITIONS_<Config> properties
CMP0044
,
///< Case sensitive <LANG>_COMPILER_ID generator expressions
/** \brief Always the last entry.
*
...
...
Tests/GeneratorExpression/CMP0044/CMakeLists.txt
0 → 100644
View file @
6aabb6a6
string
(
TOLOWER
${
CMAKE_C_COMPILER_ID
}
lc_test
)
if
(
lc_test STREQUAL CMAKE_C_COMPILER_ID
)
string
(
TOUPPER
${
CMAKE_C_COMPILER_ID
}
lc_test
)
if
(
lc_test STREQUAL CMAKE_C_COMPILER_ID
)
message
(
SEND_ERROR
"Try harder."
)
endif
()
endif
()
if
(
CMP0044_TYPE
)
cmake_policy
(
SET CMP0044
${
CMP0044_TYPE
}
)
endif
()
add_library
(
cmp0044-check-
${
CMP0044_TYPE
}
cmp0044-check.cpp
)
target_compile_definitions
(
cmp0044-check-
${
CMP0044_TYPE
}
PRIVATE
Result=$<C_COMPILER_ID:
${
lc_test
}
>
Type_Is_
${
CMP0044_TYPE
}
)
Tests/GeneratorExpression/CMP0044/cmp0044-check.cpp
0 → 100644
View file @
6aabb6a6
#ifdef Type_Is_
# if !Result
# error Result should be 1 in WARN mode
# endif
#endif
#ifdef Type_Is_NEW
# if Result
# error Result should be 0 in NEW mode
# endif
#endif
#ifdef Type_Is_OLD
# if !Result
# error Result should be 1 in OLD mode
# endif
#endif
#if !defined(Type_Is_) && !defined(Type_Is_OLD) && !defined(Type_Is_NEW)
#error No expected definition present
#endif
void
foo
(
void
)
{
}
Tests/GeneratorExpression/CMakeLists.txt
View file @
6aabb6a6
...
...
@@ -252,3 +252,9 @@ endforeach()
add_test
(
echo-old-style echo
"
\$
<CONFIGURATION>"
)
set_property
(
TEST echo-old-style PROPERTY
PASS_REGULAR_EXPRESSION
"^
\\
$<CONFIGURATION>
\n
$"
)
add_subdirectory
(
CMP0044
${
CMAKE_BINARY_DIR
}
/CMP0044-WARN
)
set
(
CMP0044_TYPE NEW
)
add_subdirectory
(
CMP0044
${
CMAKE_BINARY_DIR
}
/CMP0044-NEW
)
set
(
CMP0044_TYPE OLD
)
add_subdirectory
(
CMP0044
${
CMAKE_BINARY_DIR
}
/CMP0044-OLD
)
Tests/RunCMake/CMP0043/CMakeLists.txt
View file @
6aabb6a6
cmake_minimum_required
(
VERSION 2.8
)
project
(
${
RunCMake_TEST
}
CXX
)
include
(
${
RunCMake_TEST
}
.cmake NO_POLICY_SCOPE
)
if
(
CMAKE_BUILD_TYPE
)
# Dummy variable use
endif
()
Tests/RunCMake/GeneratorExpression/CMP0044-WARN-result.txt
0 → 100644
View file @
6aabb6a6
0
Tests/RunCMake/GeneratorExpression/CMP0044-WARN-stderr.txt
0 → 100644
View file @
6aabb6a6
CMake Warning \(dev\) at CMP0044-WARN.cmake:13 \(target_compile_definitions\):
Policy CMP0044 is not set: Case sensitive <LANG>_COMPILER_ID generator
expressions. Run "cmake --help-policy CMP0044" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
Tests/RunCMake/GeneratorExpression/CMP0044-WARN.cmake
0 → 100644
View file @
6aabb6a6
project
(
CMP0044-WARN
)
string
(
TOLOWER
${
CMAKE_C_COMPILER_ID
}
lc_test
)
if
(
lc_test STREQUAL CMAKE_C_COMPILER_ID
)
string
(
TOUPPER
${
CMAKE_C_COMPILER_ID
}
lc_test
)
if
(
lc_test STREQUAL CMAKE_C_COMPILER_ID
)
message
(
SEND_ERROR
"Try harder."
)
endif
()
endif
()
add_library
(
cmp0044-check empty.c
)
target_compile_definitions
(
cmp0044-check
PRIVATE
Result=$<C_COMPILER_ID:
${
lc_test
}
>
Type_Is_
${
CMP0044_TYPE
}
)
Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake
View file @
6aabb6a6
...
...
@@ -9,3 +9,4 @@ run_cmake(BadZero)
run_cmake
(
BadTargetName
)
run_cmake
(
BadTargetTypeObject
)
run_cmake
(
BadInstallPrefix
)
run_cmake
(
CMP0044-WARN
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment