Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: nmake adds space before 1st / in 1st arg to a command invoked with quotes #84

Open
derekbruening opened this issue Nov 27, 2014 · 5 comments

Comments

@derekbruening
Copy link
Contributor

From derek.br...@gmail.com on March 09, 2009 14:27:25

when invoked through nmake with a path to cmake that is quoted, if the
1st parameter to cmake is -Dvar=val and val contains a /, all chars
from the / onward are deleted from val: tracked it down to an nmake bug.
workaround is to have 1st parameter not contain any forward slashes, or,
alternatively, to put a space after -D.

for me, from clean slate if I invoke as
e:/PROGRA2/CMAKE21.6/bin/cmake.exe then 1st build.make runs fine b/c no
quotes around cmake.exe command:
% grep -r proj_src api/
api/docs/CMakeFiles/htmldocs.dir/build.make:
e:\PROGRA2\CMAKE21.6\bin\cmake.exe
-Dsrcdir=D:/derek/opensource/dynamorio/api/docs
-Doutfile=D:/derek/opensource/bb/api/docs/Doxyfile
-Dproj_srcdir=D:/derek/opensource/dynamorio -Dversion_number=1.3.2
-Dheader_dir=D:/derek/opensource/bb/include
-DDOXYGEN_EXECUTABLE=E:/cygwin/bin/doxygen.exe -P
D:/derek/opensource/dynamorio/api/docs/CMake_doxyfile.cmake

but if I touch a cmake file and it re-gens on "nmake" it now uses:
api/docs/CMakeFiles/htmldocs.dir/build.make: "E:\Program Files
(x86)\CMake 2.6\bin\cmake.exe"
-Dsrcdir=D:/derek/opensource/dynamorio/api/docs
-Doutfile=D:/derek/opensource/bb/api/docs/Doxyfile
-Dproj_srcdir=D:/derek/opensource/dynamorio -Dversion_number=1.3.2
-Dheader_dir=D:/derek/opensource/bb/include
-DDOXYGEN_EXECUTABLE=E:/cygwin/bin/doxygen.exe -P
D:/derek/opensource/dynamorio/api/docs/CMake_doxyfile.cmake
=> we get error on 1st arg:
[ 80%] Generating Doxyfile
CMake Error at
D:/derek/opensource/dynamorio/api/docs/CMake_doxyfile.cmake:41 (file):
file Internal CMake error when trying to open file: D:/API.doxy for
reading.

if I invoke from clean slate w/ backslashes then get error right away.
cd D:\derek\opensource\bb\api\docs
"E:\Program Files (x86)\CMake 2.6\bin\cmake.exe"
-Dsrcdir=D:/derek/opens

have script print out args:
srcdir="D:" outfile="D:/derek/opensource/bb/api/docs/Doxyfile"
proj_srcdir="D:/d
but if I directly invoke in same way, from cmd, works fine:
D:\derek\opensource\bb\api\docs>"E:\Program Files (x86)\CMake
2.6\bin\cmake.exe" -Dsrcdir=D:/derek/opensource/dynamorio/api/docs
-Doutfile=D:/derek/opensource/bb/api/docs/Doxyfile
-Dproj_srcdir=D:/derek/opensource/dynamorio -Dversion_number=1.3.2
-Dheader_dir=D:/derek/opensource/bb/include
-DDOXYGEN_EXECUTABLE=E:/cygwin/bin/doxygen.exe -P
D:/derek/opensource/dynamorio/api/docs/CMake_doxyfile.cmake
srcdir="D:/derek/opensource/dynamorio/api/docs"
outfile="D:/derek/opensource/bb/api/docs/Doxyfile"
proj_srcdir="D:/derek/opensource/dynamorio"

add bogus 1st arg => 2nd arg is fine:
"E:\Program Files (x86)\CMake 2.6\bin\cmake.exe" -Dfoo=x
-Dsrcdir=D:/derek/opensource/dynamorio/api/docs
-Doutfile=D:/derek/opensource/bb/api/docs/Doxyfile
-Dproj_srcdir=D:/derek/opensource/dynamorio -Dversion_number=1.3.2
-Dheader_dir=D:/derek/opensource/bb/include
-DDOXYGEN_EXECUTABLE=E:/cygwin/bin/doxygen.exe -P
D:/derek/opensource/dynamorio/api/docs/CMake_doxyfile.cmake

tweak 1st arg => it's deleting everything after the 1st forward slash
backward slash works fine: only forward slash
add :PATH => no difference
if put space after -D => works fine

have cmake pause (ran "cat") and attach to debugger so I can see real
cmdline (here I had replaced 1st / with \ on srcdir):
% /trees/64bit/tools/DRview.exe -cmdline -pid 3496
PID 3496, Process cmake.exe, running native
Cmdline: e:\PROGRA
2\CMAKE2~1.6\bin\cmake.exe -Dsrcdir=D:\derek
/opensource/dynamorio/api/docs
-Doutfile=D:/derek/opensource/bb/api/docs/Doxyfile
-Dproj_srcdir=D:/derek/opensource/dynamorio -Dversion_number=1.3.2
-Dheader_dir=D:/derek/opensource/bb/include
-DDOXYGEN_EXECUTABLE=E:/cygwin/bin/doxygen.exe -P
D:/derek/opensource/dynamorio/api/docs/CMake_doxyfile.cmake
=> it's an nmake bug

Original issue: http://code.google.com/p/dynamorio/issues/detail?id=84

@derekbruening
Copy link
Contributor Author

From derek.br...@gmail.com on March 09, 2009 11:44:50

I fixed in r81 with -Dfoo => -D foo for 1st arg.

but what about these:

./core/CMakeLists.txt:      ARGS ${CMAKE_CURRENT_SOURCE_DIR}/lib/genapi.pl
./CMakeLists.txt:    ARGS ${PROJECT_SOURCE_DIR}/core/lib/genapi.pl
./make/CMake_events.cmake:  ARGS ${PROJECT_SOURCE_DIR}/core/gen_event_strings.pl

will hit the issue if someone uses perl installed on path with a space in
it, since cmake will then use quotes

Labels: -Priority-Critical Priority-Medium

@derekbruening
Copy link
Contributor Author

From derek.br...@gmail.com on March 09, 2009 12:33:08

Summary: build: nmake adds space before 1st / in 1st arg to a command invoked with quotes

@derekbruening
Copy link
Contributor Author

From derek.br...@gmail.com on March 09, 2009 12:43:42

here is a simple Makefile that shows the bug (you may have to update for your cygwin
installation):

Test case for issue #84 # This is a bug in nmake.exe where nmake adds space before 1st / in

1st arg to a command, if that command is invoked with quotes.

Observe: (this is with nmake.exe 8.00.50727.762)

% nmake /nologo noquotes

back\forward/slash second/arg

% nmake /nologo quotes

back\forward /slash second/arg

.PHONY : noquotes quotes
noquotes:
@e:\cygwin\bin\echo back\forward/slash second/arg
quotes:
@"e:\cygwin\bin\echo" back\forward/slash second/arg

@derekbruening
Copy link
Contributor Author

From derek.br...@gmail.com on March 09, 2009 17:58:00

bug is present in older versions of nmake as well:

Microsoft (R) Program Maintenance Utility Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.
back\forward /slash second/arg

Microsoft (R) Program Maintenance Utility Version 6.00.8168.0
Copyright (C) Microsoft Corp 1988-1998. All rights reserved.
back\forward /slash second/arg

@derekbruening
Copy link
Contributor Author

From derek.br...@gmail.com on March 12, 2009 09:42:02

filed CMake request to not use quotes: http://www.cmake.org/Bug/view.php?id=8727

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant