MantisBT - CMake
View Issue Details
0015478CMakeCMakepublic2015-03-26 15:252015-11-02 09:13
Walter Gray 
 
normalminoralways
closedduplicate 
All
CMake 3.2.1 
 
0015478: As of CMake 3.1 Properties cannot be set to ""
As of CMake 3.0.2, it was completely legal to set a target property to "". This was in fact a very helpful feature for me in some cases since it meant that if I knew I'd set a property to a list (even an empty one), when I read it back later and passed it into a foreach I didn't have to also use an if to check if it existed. This functionality was broken in 3.1, and there is neither a policy setting about it, nor any documentation I can find that indicates this was an intended change.
Run the following cmake script. In CMake <= 3.0.2, prop1 will be an empty string. In CMake >= 3.1, it will be prop1-NOTFOUND

cmake_minimum_required(VERSION 3.0)
cmake_policy(VERSION 3.0.2)

project(cmaketestproject)

add_executable(testexe test.cpp)

set(emptylist "")

set_target_properties(testexe PROPERTIES INTERFACE_PROP_1 "${emptylist}" INTERFACE_PROP_2 "thing")
get_target_property(prop1 testexe INTERFACE_PROP_1)
get_target_property(prop2 testexe INTERFACE_PROP_2)
get_target_property(prop3 testexe INTERFACE_PROP_3)

message(prop1=${prop1})
message(prop2=${prop2})
message(prop3=${prop3})
No tags attached.
duplicate of 0015333closed Ben Boeckel Behaviour change with 3.1 - target properies set to empty string returned as -NOTFOUND 
Issue History
2015-03-26 15:25Walter GrayNew Issue
2015-03-26 15:29Walter GrayNote Added: 0038334
2015-03-26 15:30Walter GrayNote Edited: 0038334bug_revision_view_page.php?bugnote_id=38334#r1735
2015-03-26 15:36Brad KingRelationship addedduplicate of 0015333
2015-03-26 15:37Brad KingNote Added: 0038335
2015-03-26 15:40Brad KingNote Added: 0038336
2015-03-26 15:41Brad KingStatusnew => resolved
2015-03-26 15:41Brad KingResolutionopen => duplicate
2015-03-26 15:41Brad KingNote Added: 0038337
2015-11-02 09:13Robert MaynardNote Added: 0039747
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038334)
Walter Gray   
2015-03-26 15:29   
(edited on: 2015-03-26 15:30)
When I say "", I mean an empty string, not the literal ""

(0038335)
Brad King   
2015-03-26 15:37   
This was broken in 3.1.0 only. It was fixed in 3.1.1 and later.

From your example:

cmake 3.0.0:

 prop1=
 prop2=thing
 prop3=prop3-NOTFOUND

cmake 3.1.0:

 prop1=prop1-NOTFOUND
 prop2=thing
 prop3=prop3-NOTFOUND

cmake 3.1.3:

 prop1=
 prop2=thing
 prop3=prop3-NOTFOUND

cmake 3.2.1:

 prop1=
 prop2=thing
 prop3=prop3-NOTFOUND
(0038336)
Brad King   
2015-03-26 15:40   
You could also use the get_property command instead:

 http://www.cmake.org/cmake/help/v3.2/command/get_property.html [^]

It returns the empty string for properties that are set to "" or not set at all, and has separate options to query whether the property is SET.
(0038337)
Brad King   
2015-03-26 15:41   
See 0015333:0037662 for information about what was fixed in 3.1.1.
(0039747)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.