The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=15935
======================================================================
Reported By: Kiron
Assigned To:
======================================================================
Project: CMake
Issue ID: 15935
Category: CMake
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2016-01-26 05:32 EST
Last Modified: 2016-01-26 05:32 EST
======================================================================
Summary: Empty generator expression in COMMAND leads to ""
Description:
When 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 Reproduce:
Create 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 Information:
Tested 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".
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2016-01-26 05:32 Kiron New Issue
======================================================================
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers