View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0015321 | CMake | CMake | public | 2014-12-20 19:12 | 2016-06-10 14:31 | ||||
Reporter | Denis Denisov | ||||||||
Assigned To | Kitware Robot | ||||||||
Priority | normal | Severity | minor | Reproducibility | always | ||||
Status | closed | Resolution | moved | ||||||
Platform | Darwin | OS | Mac OS X | OS Version | 10.10.1 | ||||
Product Version | CMake 3.0.2 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0015321: Ninja: Custom command lines do not escape "$" | ||||||||
Description | `ninja: error: build.ninja:3194: bad $-escape (literal $ must be written as $$)`` | ||||||||
Additional Information | before code: ``` # Xcode/Ninja generators undefined MAKE if(NOT MAKE) set(MAKE make) endif() add_custom_target( hack ALL COMMAND env OPTBIN="${OCAMLC_OPT_SUFFIX}" $(MAKE) EXTRA_INCLUDE_PATHS="${extra_include_paths}" EXTRA_LIB_PATHS="${extra_lib_paths}" EXTRA_CC_FLAGS="${extra_cc_flags}" EXTRA_NATIVE_LIBRARIES="${extra_native_libraries}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" ) ``` code build.ninja:3194: ``` ############################################# # Custom command for hphp/hack/CMakeFiles/hack build hphp/hack/CMakeFiles/hack: CUSTOM_COMMAND || third-party/lz4/liblz4.a COMMAND = cd /home/denji/Desktop/hhvm/hphp/hack/src && env OPTBIN=".opt" $(MAKE) EXTRA_INCLUDE_PATHS="/usr/include /home/denji/Desktop/hhvm/third-party/lz4" EXTRA_LIB_PATHS="/usr/lib/x86_64-linux-gnu /home/denji/Desktop/hhvm/third-party/lz4" EXTRA_CC_FLAGS="-DHAVE_ELF_GETSHDRSTRNDX -pthread" EXTRA_NATIVE_LIBRARIES="lz4" `` | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0037504) Denis Denisov (reporter) 2014-12-20 19:12 edited on: 2014-12-20 19:15 |
https://github.com/facebook/hhvm/blob/c63a8efb/hphp/hack/CMakeLists.txt#L34-L49 [^] |
(0037505) Brad King (manager) 2014-12-22 09:10 |
For your particular example, the "$(MAKE)" reference is not evaluated by CMake but simply passed through. I think you want something more like:# Xcode/Ninja generators undefined MAKE if(CMAKE_GENERATOR MATCHES "Make") set(MAKE "$(MAKE)") else() set(MAKE make) endif() add_custom_target( hack ALL COMMAND env OPTBIN="${OCAMLC_OPT_SUFFIX}" "${MAKE}" EXTRA_INCLUDE_PATHS="${extra_include_paths}" EXTRA_LIB_PATHS="${extra_lib_paths}" EXTRA_CC_FLAGS="${extra_cc_flags}" EXTRA_NATIVE_LIBRARIES="${extra_native_libraries}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" ) However, the Ninja generator may still need to be corrected to escape "$" as "$$" inside command lines. |
(0037506) Denis Denisov (reporter) 2014-12-22 09:18 edited on: 2014-12-22 09:19 |
Please note, there are 2 types of builds using cmake and pure GNU make (CMAKE_GENERATOR - not support the Makefile) cmake can be self-contained or collected directly by using the Makefile |
(0039014) Denis Denisov (reporter) 2015-07-02 15:27 edited on: 2015-07-02 15:54 |
Problem when using ninja generation in cmake is that it is not enough screens to a $MAKE variable diff: - $(MAKE) + $$(MAKE) or + $MAKE #debian:/home/denji/kitchen_sync/build# ninja ninja: error: build.ninja:338: bad $-escape (literal $ must be written as $$) COMMAND = cd /home/denji/kitchen_sync/build/src/yaml-cpp && $(MAKE) cl... ^ near here # cmake --version cmake version 3.0.2 # ninja --version 1.3.4 # lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 8.1 (jessie) Release: 8.1 Codename: jessie # git clone https://github.com/willbryant/kitchen_sync.git [^] #debian:/home/denji/kitchen_sync/build# cmake -G Ninja .. -- The CXX compiler identification is GNU 4.9.2 -- Check for working CXX compiler using: Ninja -- Check for working CXX compiler using: Ninja -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Performing Test COMPILER_SUPPORTS_CXX11 -- Performing Test COMPILER_SUPPORTS_CXX11 - Success -- Performing Test COMPILER_SUPPORTS_CXX0X -- Performing Test COMPILER_SUPPORTS_CXX0X - Success -- Performing Test COMPILER_SUPPORTS_STDLIB -- Performing Test COMPILER_SUPPORTS_STDLIB - Failed -- Boost version: 1.55.0 -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) -- The C compiler identification is GNU 4.9.2 -- Check for working C compiler using: Ninja -- Check for working C compiler using: Ninja -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Boost version: 1.55.0 -- Performing Test FLAG_WEXTRA -- Performing Test FLAG_WEXTRA - Success -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libssl.so;/usr/lib/x86_64-linux-gnu/libcrypto.so (found version "1.0.1k") -- Found MySQL: /usr/lib/libmysqlclient.so -- Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR) (found version "9.4.3") -- Configuring done -- Generating done -- Build files have been written to: /home/denji/kitchen_sync/build #debian:/home/denji/kitchen_sync/build# ninja ninja: error: build.ninja:338: bad $-escape (literal $ must be written as $$) COMMAND = cd /home/denji/kitchen_sync/build/src/yaml-cpp && $(MAKE) cl... ^ near here |
(0039019) Brad King (manager) 2015-07-06 14:31 |
With the VERBATIM option to add_custom_command, CMake does correctly escape "$" in custom commands. The test suite covers it here: http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/CustomCommand/CMakeLists.txt;hb=v3.3.0-rc3#l271 [^] The problem here is that there is a special case in the escaping rules to allow Makefile variable references like "$(VAR)" to work without escaping the "$" sign. See the SetEscapeAllowMakeVars call here: http://www.cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmMakefile.cxx;hb=v3.3.0-rc3#l960 [^] |
(0039020) Brad King (manager) 2015-07-06 14:34 |
In your use case, when Ninja launches the command line containing a literal "$$(MAKE)" (thus properly escaped), what do you expect to happen? Ninja won't replace that with anything. Then the shell will see "$(MAKE)" and treat it as a recursive shell call looking for a command line tool called "MAKE" to run with no arguments. |
(0039021) Denis Denisov (reporter) 2015-07-06 14:37 |
I don't want to manually edit ninja file, clearly understood that the escape problem caused in cmake. We will wait for your proposed solutions around the problem. Thanks. |
(0039022) Brad King (manager) 2015-07-06 14:56 |
Re 0015321:0039021: What I'm asking in 0015321:0039020 is what you expect to happen if CMake were to properly escape the "$" in this case. Consider this session:$ cat test.ninja rule R command = echo $$(MAKE) build all: R $ ninja -f test.ninja [1/1] echo $(MAKE) /bin/sh: 1: MAKE: not found |
(0039023) Denis Denisov (reporter) 2015-07-06 15:17 edited on: 2015-07-06 15:18 |
$$(MAKE) work fine $ ninja -f test.ninja [1/1] echo $(MAKE) /bin/sh: 1: MAKE: not found ------------- $MAKE work fine, no error signal $ ninja -f test.ninja [1/1] echo |
(0039025) Brad King (manager) 2015-07-06 15:35 |
Re 0015321:0039023: Right, so I'm saying that having "$$(MAKE)" in the build.ninja file is incorrect for this use case. It won't actually run "make". The CMake code # Xcode/Ninja generators undefined MAKE if(NOT MAKE) set(MAKE make) endif() does not set anything meaningful to Ninja at build time. Have you tried the code I posted in 0015321:0037505? AFAICT it will achieve your goals. |
(0042694) 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. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2014-12-20 19:12 | Denis Denisov | New Issue | |
2014-12-20 19:12 | Denis Denisov | Note Added: 0037504 | |
2014-12-20 19:15 | Denis Denisov | Note Edited: 0037504 | |
2014-12-22 09:10 | Brad King | Note Added: 0037505 | |
2014-12-22 09:11 | Brad King | Status | new => backlog |
2014-12-22 09:11 | Brad King | Summary | Generation of the ninja, ignore escape => Ninja: Custom command lines do not escape "$" |
2014-12-22 09:18 | Denis Denisov | Note Added: 0037506 | |
2014-12-22 09:19 | Denis Denisov | Note Edited: 0037506 | |
2015-07-02 15:27 | Denis Denisov | Note Added: 0039014 | |
2015-07-02 15:29 | Denis Denisov | Note Added: 0039015 | |
2015-07-02 15:29 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:29 | Denis Denisov | Note Deleted: 0039015 | |
2015-07-02 15:31 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:31 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:31 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:31 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:32 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:32 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:32 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:33 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:33 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:41 | Denis Denisov | Note Edited: 0039014 | |
2015-07-02 15:54 | Denis Denisov | Note Edited: 0039014 | |
2015-07-06 14:31 | Brad King | Note Added: 0039019 | |
2015-07-06 14:34 | Brad King | Note Added: 0039020 | |
2015-07-06 14:37 | Denis Denisov | Note Added: 0039021 | |
2015-07-06 14:56 | Brad King | Note Added: 0039022 | |
2015-07-06 15:17 | Denis Denisov | Note Added: 0039023 | |
2015-07-06 15:17 | Denis Denisov | Note Added: 0039024 | |
2015-07-06 15:17 | Denis Denisov | Note Edited: 0039023 | |
2015-07-06 15:17 | Denis Denisov | Note Deleted: 0039024 | |
2015-07-06 15:17 | Denis Denisov | Note Edited: 0039023 | |
2015-07-06 15:18 | Denis Denisov | Note Edited: 0039023 | |
2015-07-06 15:35 | Brad King | Note Added: 0039025 | |
2016-06-06 13:37 | Brad King | View Status | private => public |
2016-06-10 14:29 | Kitware Robot | Note Added: 0042694 | |
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 |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |