[cmake-developers] [CMake 0015112]: Incorrect commands generated on bustom build step for Visual Studio
Mantis Bug Tracker
mantis at public.kitware.com
Tue Aug 26 17:35:58 EDT 2014
The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=15112
======================================================================
Reported By: Javier Martinez
Assigned To:
======================================================================
Project: CMake
Issue ID: 15112
Category: CMake
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2014-08-26 17:35 EDT
Last Modified: 2014-08-26 17:35 EDT
======================================================================
Summary: Incorrect commands generated on bustom build step
for Visual Studio
Description:
CMake generates incorrect commands in a custom build step causing builds to
fail. The attached example exposes two issues:
- CMake inserts spaces around the statement in parenthesis which changes the
variable value. In the attached example the CONF variable value is "Release "
instead of "Release"
Expected: if '$(Configuration)'=='Release-Internal' set (CONF=Release)
Actual: if '$(Configuration)'=='Release-Internal' set ( CONF=Release )
Workaround: if there's no else clause the w/a is to not use parenthesis
- If the content of a variable is used at the beginning of a command CMake will
wrap it in additional percent (%) characters making the command invalid.
Expected: %CMDLINE%
Actual: %%CMDLINE%%
Workaround: use conditional expressions to avoid the variable be at the
beginning, for example ECHO "Running command" && %CMDLINE%
Steps to Reproduce:
cmake_minimum_required(VERSION 3.0)
add_custom_target(Test
)
add_custom_command(
TARGET Test
PRE_BUILD
COMMAND set CONF=$(Configuration)
COMMAND if '$(Configuration)'=='Release-Internal' set (CONF=Release)
COMMAND set BUNDLE_FOLDER=Prebuilt/Windows/%CONF%/$(PlatformArchitecture)
COMMAND set CMDLINE=7z.exe x -y %BUNDLE_FOLDER%/bundle.7z -o%BUNDLE_FOLDER%
COMMAND echo %CMDLINE%
COMMAND %CMDLINE%
COMMENT "Extracting Bundle (failed)"
)
add_custom_command(
TARGET Test
POST_BUILD
COMMAND set CONF=$(Configuration)
COMMAND if '$(Configuration)'=='Release-Internal' set CONF=Release
COMMAND set BUNDLE_FOLDER=Prebuilt/Windows/%CONF%/$(PlatformArchitecture)
COMMAND set CMDLINE=7z.exe x -y %BUNDLE_FOLDER%/bundle.7z -o%BUNDLE_FOLDER%
COMMAND echo %CMDLINE% && %CMDLINE%
COMMENT "Extracting Bundle (succeed)"
)
Additional Information:
Command line to reproduce: cmake.exe CMakeLists.txt -G"Visual Studio 12"
-B"CMakeOutput"
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2014-08-26 17:35 Javier MartinezNew Issue
2014-08-26 17:35 Javier MartinezFile Added: CMakeLists.txt
======================================================================
More information about the cmake-developers
mailing list