MantisBT - CMake
View Issue Details
0014636CMakeCMakepublic2013-12-07 04:422014-06-02 08:37
Kiron 
Stephen Kelly 
normalminoralways
closedfixed 
CMake 2.8.12 
CMake 3.0 
0014636: Error with whitelisted properties and generator expression in target_link_libraries
When using target_link_libraries to link an INTERFACE IMPORTED library with an EXECUTABLE and the INTERFACE_LINK_LIBRARIES property of the library contains a generator expression, the following FATAL_ERROR is produced:

(See Steps To Reproduce for CMakeLists.txt)

>cmake .
-- Configuring done
CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_LOCATION_RELEASE" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_LOCATION" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_CONFIGURATIONS" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_LOCATION_MINSIZEREL" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_LOCATION" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_CONFIGURATIONS" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_LOCATION_RELWITHDEBINFO" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_LOCATION" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_CONFIGURATIONS" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_LOCATION_NOCONFIG" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_LOCATION" is not allowed.


CMake Error in CMakeLists.txt:
  INTERFACE_LIBRARY targets may only have whitelisted properties. The
  property "IMPORTED_CONFIGURATIONS" is not allowed.


-- Generating done
-- Build files have been written to: ...

When NOT using a generator expression in the INTERFACE_LINK_LIBRARIES property, no error is generated.

Additionally, the error message does not provide detailed information to track down this error.
Create a file CMakeLists.txt file with the following content:

------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.8.12.20131125 FATAL_ERROR)

project(GeneratorExpressionAndWhitelistedProperties C CXX)

set(_main_cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp)
file(WRITE ${_main_cpp}
  "int main(int argc, char** argv) { return 0; }\n"
)

add_library(foo::bar INTERFACE IMPORTED)
set_target_properties(foo::bar
  PROPERTIES
    INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}"
    # When not using a generator expression here, no error is generated
    INTERFACE_LINK_LIBRARIES "$<$<NOT:$<CONFIG:DEBUG>>:foo_bar.lib>"
)

add_executable(main ${_main_cpp})
target_include_directories(main PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}")

target_link_libraries(main foo::bar)
------------------------------------------------------------------------------

Run cmake
cmake version 2.8.12.20131207-g6f6ee
No tags attached.
Issue History
2013-12-07 04:42KironNew Issue
2013-12-07 10:33Stephen KellyAssigned To => Stephen Kelly
2013-12-07 10:33Stephen KellyStatusnew => assigned
2013-12-09 13:36Stephen KellyNote Added: 0034764
2013-12-09 13:36Stephen KellyStatusassigned => resolved
2013-12-09 13:36Stephen KellyFixed in Version => CMake 3.0
2013-12-09 13:36Stephen KellyResolutionopen => fixed
2014-06-02 08:37Robert MaynardNote Added: 0036054
2014-06-02 08:37Robert MaynardStatusresolved => closed

Notes
(0034764)
Stephen Kelly   
2013-12-09 13:36   
Fixed:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=31ca983c5 [^]

Thanks for testing!
(0036054)
Robert Maynard   
2014-06-02 08:37   
Closing resolved issues that have not been updated in more than 4 months.