View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015935CMakeCMakepublic2016-01-26 05:322016-06-10 14:31
ReporterKiron 
Assigned ToKitware Robot 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0015935: Custom command post-genex ;-list expansion
DescriptionWhen an $<0:...> generator expression in a COMMAND argument of add_custom_command (and add_custom_target) the Visual Studio generator generates an invalid command "".

When using a normal variable which is empty or not set, the COMMAND argument is just ignored.
Steps To ReproduceCreate a file called CMakeLists.txt with the following content in an empty directory:

cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
cmake_policy(VERSION 3.0)

project(EmptyGenExCommand LANGUAGES CXX VERSION 0.0.1.0)

set(_stamp ${CMAKE_BINARY_DIR}/foo.stamp)
add_custom_command(OUTPUT ${_stamp}
    COMMAND $<$<BOOL:$<TARGET_PROPERTY:foo,FOOCMD>>:$<TARGET_PROPERTY:foo,FOOCMD>>
    COMMAND ${CMAKE_COMMAND} -E echo foo is done
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
)
add_custom_target(foo ALL DEPENDS ${_stamp})
#set_property(TARGET foo PROPERTY FOOCMD ${CMAKE_COMMAND} -E sleep 1)
Additional InformationTested with cmake version 3.4.3 under Windows 7 64 bit.

When using the Visual Studio generator the vcxproj contains:

  <ItemGroup>
    <CustomBuild Include="...">
      [...]
      <Command ...>setlocal
cd S:\abc
if %errorlevel% neq 0 goto :cmEnd
S:
if %errorlevel% neq 0 goto :cmEnd
""
if %errorlevel% neq 0 goto :cmEnd

When trying to execute "" the following error from cmd.exe is generated:

'""' is not recognized as an internal or external command,
operable program or batch file.

Also when setting the FOOCMD property to an actual command (e.g.: set_property(TARGET foo PROPERTY FOOCMD ${CMAKE_COMMAND} -E sleep 1)) it will not work, since it evaluates to "C:\Program Files (x86)\CMake\bin\cmake.exe";"-E";"sleep";"1" or with quotes in the set_property command it evaluates to "C:\Program Files (x86)\CMake\bin\cmake.exe -E sleep 1".
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0040328)
Brad King (manager)
2016-01-26 10:15

This is expected. The elimination of unquoted empty arguments is done by the CMake language during configuration. At that stage the generator expression is not evaluated. The command and number of arguments becomes fixed. Generator expressions can be used within each argument but no ;-list splitting is done on the results. A new feature/genex/syntax would be needed to enable post-evaluation argument expansion.

Side note:

> cmake_policy(VERSION 3.0)

This is implied by the cmake_minimum_required call and so does not need to be called explicitly.
(0042922)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2016-01-26 05:32 Kiron New Issue
2016-01-26 10:15 Brad King Note Added: 0040328
2016-01-26 10:16 Brad King Severity minor => feature
2016-01-26 10:16 Brad King Status new => backlog
2016-01-26 10:16 Brad King Summary Empty generator expression in COMMAND leads to "" => Custom command post-genex ;-list expansion
2016-06-10 14:29 Kitware Robot Note Added: 0042922
2016-06-10 14:29 Kitware Robot Status backlog => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team