Merge topic 'CONFIG-LOCATION-CMP0026'

ea17a03b cmTarget: Port <CONFIG>_LOCATION support to updated string APIs
6e466c6f Merge branch 'master' into CONFIG-LOCATION-CMP0026
c903b531 cmTarget: Restore <CONFIG>_LOCATION to CMP0026 OLD behavior (#14808)
This commit is contained in:
Brad King 2014-03-17 09:49:56 -04:00 committed by CMake Topic Stage
commit 6aaaa6d0bd
21 changed files with 117 additions and 3 deletions

View File

@ -3,7 +3,8 @@ CMP0026
Disallow use of the LOCATION target property.
CMake 2.8.12 and lower allowed reading the LOCATION target property to
CMake 2.8.12 and lower allowed reading the LOCATION target
property (and configuration-specific variants) to
determine the eventual location of build targets. This relies on the
assumption that all necessary information is available at
configure-time to determine the final location and filename of the
@ -17,8 +18,8 @@ $<TARGET_FILE> generator expression together with the file(GENERATE)
subcommand to generate a file containing the target location.
The OLD behavior for this policy is to allow reading the LOCATION
property from build-targets. The NEW behavior for this policy is to
not to allow reading the LOCATION property from build-targets.
properties from build-targets. The NEW behavior for this policy is to
not to allow reading the LOCATION properties from build-targets.
This policy was introduced in CMake version 3.0. CMake version
|release| warns when the policy is not set and uses OLD behavior. Use

View File

@ -2670,6 +2670,21 @@ const char *cmTarget::GetProperty(const std::string& prop,
this->GetLocation(configName),
cmProperty::TARGET);
}
// Support "<CONFIG>_LOCATION".
if(cmHasLiteralSuffix(prop, "_LOCATION"))
{
std::string configName(prop.c_str(), prop.size() - 9);
if(configName != "IMPORTED")
{
if (!this->HandleLocationPropertyPolicy())
{
return 0;
}
this->Properties.SetProperty(prop,
this->GetLocation(configName),
cmProperty::TARGET);
}
}
}
if(prop == "INCLUDE_DIRECTORIES")
{

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,11 @@
CMake Error at CMP0026-CONFIG-LOCATION-NEW.cmake:7 \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property may not be read from target "somelib". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,7 @@
enable_language(CXX)
cmake_policy(SET CMP0026 NEW)
add_library(somelib empty.cpp)
get_target_property(_loc somelib Debug_LOCATION)

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1 @@
^$

View File

@ -0,0 +1,7 @@
enable_language(CXX)
cmake_policy(SET CMP0026 OLD)
add_library(somelib empty.cpp)
get_target_property(_loc somelib Debug_LOCATION)

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,12 @@
CMake Warning \(dev\) at CMP0026-CONFIG-LOCATION-WARN.cmake:5 \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "somelib". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -0,0 +1,5 @@
enable_language(CXX)
add_library(somelib empty.cpp)
get_target_property(_loc somelib Debug_LOCATION)

View File

@ -0,0 +1 @@
1

View File

@ -0,0 +1,11 @@
CMake Error at CMP0026-LOCATION-CONFIG-NEW.cmake:7 \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property may not be read from target "somelib". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)

View File

@ -0,0 +1,7 @@
enable_language(CXX)
cmake_policy(SET CMP0026 NEW)
add_library(somelib empty.cpp)
get_target_property(_loc somelib LOCATION_Debug)

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1 @@
^$

View File

@ -0,0 +1,7 @@
enable_language(CXX)
cmake_policy(SET CMP0026 OLD)
add_library(somelib empty.cpp)
get_target_property(_loc somelib LOCATION_Debug)

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,12 @@
CMake Warning \(dev\) at CMP0026-LOCATION-CONFIG-WARN.cmake:5 \(get_target_property\):
Policy CMP0026 is not set: Disallow use of the LOCATION target property.
Run "cmake --help-policy CMP0026" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
The LOCATION property should not be read from target "somelib". Use the
target name directly with add_custom_command, or use the generator
expression \$<TARGET_FILE>, as appropriate.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.

View File

@ -0,0 +1,5 @@
enable_language(CXX)
add_library(somelib empty.cpp)
get_target_property(_loc somelib LOCATION_Debug)

View File

@ -3,3 +3,9 @@ include(RunCMake)
run_cmake(CMP0026-WARN)
run_cmake(CMP0026-NEW)
run_cmake(CMP0026-IMPORTED)
run_cmake(CMP0026-CONFIG-LOCATION-NEW)
run_cmake(CMP0026-CONFIG-LOCATION-OLD)
run_cmake(CMP0026-CONFIG-LOCATION-WARN)
run_cmake(CMP0026-LOCATION-CONFIG-NEW)
run_cmake(CMP0026-LOCATION-CONFIG-OLD)
run_cmake(CMP0026-LOCATION-CONFIG-WARN)