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 of osd_static_gpu failed (on Windows 10 using Visual Studio 2013 x64) #922

Closed
huybui opened this issue Jan 19, 2017 · 13 comments
Closed

Comments

@huybui
Copy link

huybui commented Jan 19, 2017

There is an error in the CMake-generated file (build\CMakeFiles\osd_static_gpu.dir\osd\osd_static_gpu_generated_cudaKernel.cu.obj.Release.cmake)
at line 81:
set(CUDA_NVCC_COMPILE_DEFINITIONS "**OPENSUBDIV_VERSION_STRING="3.1.1";NOMINMAX;_**USE_MATH_DEFINES;_CRT_SECURE_NO_WARNINGS;OPENSUBDIV_HAS_OPENGL;GLFW_VERSION_3;OSD_USES_GLEW;OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK;OPENSUBDIV_HAS_GLSL_COMPUTE;OPENSUBDIV_HAS_OPENCL;OPENSUBDIV_HAS_CLEW;OPENSUBDIV_HAS_CUDA;OPENSUBDIV_HAS_PTEX;PTEX_STATIC;OPENSUBDIV_HAS_DX11SDK") # list (needs to be in quotes to handle spaces properly).

Below is the output of Visual Studio:

31> Building NVCC (Device) object opensubdiv/CMakeFiles/osd_static_gpu.dir/osd/Release/osd_static_gpu_generated_cudaKernel.cu.obj 31> CMake Warning (dev) at osd_static_gpu_generated_cudaKernel.cu.obj.Release.cmake:81: 31> Syntax Warning in cmake code at column 63 31> 31> Argument not separated from preceding token by whitespace. 31> This warning is for project developers. Use -Wno-dev to suppress it. 31> 31> -- Removing C:/Workspace/OpenSubdiv/build/opensubdiv/CMakeFiles/osd_static_gpu.dir/osd/Release/osd_static_gpu_generated_cudaKernel.cu.obj 31> 31> "C:/Program Files/CMake/bin/cmake.exe" -E remove C:/Workspace/OpenSubdiv/build/opensubdiv/CMakeFiles/osd_static_gpu.dir/osd/Release/osd_static_gpu_generated_cudaKernel.cu.obj 31> 31> -- Generating dependency file: C:/Workspace/OpenSubdiv/build/opensubdiv/CMakeFiles/osd_static_gpu.dir/osd/osd_static_gpu_generated_cudaKernel.cu.obj.NVCC-depend 31> 31> "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/bin/nvcc.exe" -M -D__CUDACC__ C:/Workspace/OpenSubdiv/opensubdiv/osd/cudaKernel.cu -o C:/Workspace/OpenSubdiv/build/opensubdiv/CMakeFiles/osd_static_gpu.dir/osd/osd_static_gpu_generated_cudaKernel.cu.obj.NVCC-depend -ccbin "C:/Program Files (x86)/Microsoft Visual Studio 12.0/VC/bin" -m64 -DOPENSUBDIV_VERSION_STRING= -D3.1.1\" -DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -DOPENSUBDIV_HAS_OPENGL -DGLFW_VERSION_3 -DOSD_USES_GLEW -DOPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK -DOPENSUBDIV_HAS_GLSL_COMPUTE -DOPENSUBDIV_HAS_OPENCL -DOPENSUBDIV_HAS_CLEW -DOPENSUBDIV_HAS_CUDA -DOPENSUBDIV_HAS_PTEX -DPTEX_STATIC -DOPENSUBDIV_HAS_DX11SDK\" -Xcompiler ,\"/DWIN32\",\"/D_WINDOWS\",\"/W3\",\"/GR\",\"/EHsc\",\"/MD\",\"/O2\",\"/Ob2\",\"/DNDEBUG\" -DNVCC "-IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/include" -IC:/Workspace/OpenSubdiv/opensubdiv "-IC:/Program Files/ptex/include" "-IC:/Users/VGI/Documents/Visual Studio 2013/library/glew-1.13.0/include" "-IC:/Program Files (x86)/Windows Kits/8.1/Include/um" "-IC:/Program Files/CLEW/include" 31> 31> nvcc fatal : Stray '"' character 31> 31> CMake Error at osd_static_gpu_generated_cudaKernel.cu.obj.Release.cmake:222 (message): 31> Error generating 31> C:/Workspace/OpenSubdiv/build/opensubdiv/CMakeFiles/osd_static_gpu.dir/osd/Release/osd_static_gpu_generated_cudaKernel.cu.obj 31> 31> 31>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.CppCommon.targets(170,5): error MSB6006: "cmd.exe" exited with code 1.

@jtran56
Copy link

jtran56 commented Jan 19, 2017

Filed as internal issue #142048.

@davidgyu
Copy link
Member

Which version of cmake are you using?

I haven't been able to reproduce this on my Win7 machine with cmake 3.0.0 or 3.5.0 and VS 2013
I've been using VS 2015 Update 2 on Windows 10, but I'll also try with VS 2013.

@huybui
Copy link
Author

huybui commented Jan 20, 2017

I am using CMake 3.7.1.

@huybui
Copy link
Author

huybui commented Jan 23, 2017

I tried with CMake 3.5.0 and there is no problem. So it must be an issue with CMake.

@redchillipadi
Copy link

redchillipadi commented Feb 1, 2017

I am packaging Opensubdiv 3.1.1 for Gentoo linux and have the same issue with CMake >= 3.7.0.

What happens is that CMakeLists.txt sets a variable OPENSUBDIV_VERSION_STRING to "3.1.1" (i.e. the string contains the version number wrapped in double quotes).

Code generated by CMake's Modules/FindCUDA.cmake transforms this into an improperly quoted semicolon separated list:
set(CUDA_NVCC_COMPILE_DEFINITIONS "OPENSUBDIV_VERSION_STRING="3.1.1";OPENSUBDIV ... ")

This is then transformed into a command line to pass to nvcc to compile the osd static and dynamic gpu cuda kernels but the string has dangling quotes. The section shown above converts to:
-DOPENSUBDIV_VERSION_STRING -D3.1.1";-DOPENSUBDIV...

The code to convert the definitions such as OPENSUBDIV_VERSION_STRING into CUDA_NVCC_COMPILE_DEFINITIONS was introduced to Modules/FindCUDA.cmake (commit 6442709b) which was merged into Cmake 3.7.0. Prior versions of FindCUDA set the flags for nvcc differently and are able to compile opensubdiv on my system. CMake 3.6.3 works for me, but 3.7.2 fails.

Ideally the FindCUDA.cmake code could be made more robust to handle definitions containing quotation marks. In any case removing the extra quotes from the OPENSUBDIV_VERSION_STRING (set it to 3.1.1 rather than "3.1.1") resolves the problem and allows opensubdiv to compile successfully with CMake 3.7.2.

diff -Naur a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt	2017-02-01 23:20:22.590219192 +1100
+++ b/CMakeLists.txt	2017-02-01 23:19:59.923600152 +1100
@@ -48,7 +48,7 @@
     string(REGEX REPLACE "^v" "" OSD_SONAME ${OSD_SONAME})
 
     add_definitions(
-        -DOPENSUBDIV_VERSION_STRING="${OSD_SONAME}"
+        -DOPENSUBDIV_VERSION_STRING=${OSD_SONAME}
     )
 
 #-------------------------------------------------------------------------------

@davidgyu
Copy link
Member

davidgyu commented Feb 1, 2017

Ah, that makes sense. Nice debugging. We'll take a look...

@renexdev
Copy link

renexdev commented Mar 16, 2017

Hi there, thanks @redchillipadi for the trick it solved the string issue!
Nevertheless, in my case it gives me another error that may be its related to OPENSUBDIV_VERSION_STRING set variable. In the compilation step I got the following error when trying to build the samples...
I paste the output for glImaging sample...

[ 91%] Building CXX object examples/glImaging/CMakeFiles/glImaging.dir/glImaging.cpp.o
:0:27: error: too many decimal points in number
$HOME/OpenSubdiv-master/examples/glPaintTest/glPaintTest.cpp:1108:65: note: in expansion of macro ‘OPENSUBDIV_VERSION_STRING’
static const char windowTitle[] = "OpenSubdiv glPaintTest " OPENSUBDIV_VERSION_STRING;

The error spreads all over the samples with the same code-line. Any suggestion?
P.S: When I turn off the sample building It could compile successfully
Thanks in advance

@redchillipadi
Copy link

redchillipadi commented Mar 16, 2017

As the code is in a cpp file we need to use token stringification to convert OPENSUBDIV_VERSION_STRING into a string.

In each sample file define a macro
#define STRINGIFY(a) #a
and then alter the lines to read

static const char windowTitle[] = "OpenSubdiv glPaintTest" STRINGIFY(OPENSUBDIV_VERSION_STRING);

In glImaging.cpp there is another line which needs to read

ofs << "OpenSubdiv      : " << STRINGIFY(OPENSUBDIV_VERSION_STRING) << "\n";

redchillipadi added a commit to redchillipadi/OpenSubdiv that referenced this issue Mar 17, 2017
Prior to this commit, what happens is that CMakeLists.txt sets a variable
OPENSUBDIV_VERSION_STRING to "3.1.1" (i.e. the string contains the
version number wrapped in double quotes).

Code generated by CMake's Modules/FindCUDA.cmake transforms this into an
improperly quoted semicolon separated list:
set(CUDA_NVCC_COMPILE_DEFINITIONS
"OPENSUBDIV_VERSION_STRING="3.1.1";OPENSUBDIV ... ")

This is then transformed into a command line to pass to nvcc to compile
the osd static and dynamic gpu cuda kernels but the string has dangling
quotes. The section shown above converts to:
-DOPENSUBDIV_VERSION_STRING -D3.1.1";-DOPENSUBDIV...

The code to convert the definitions such as OPENSUBDIV_VERSION_STRING
into CUDA_NVCC_COMPILE_DEFINITIONS was introduced to
Modules/FindCUDA.cmake (commit 6442709b) which was merged into Cmake
3.7.0. Prior versions of FindCUDA set the flags for nvcc differently and
are able to compile opensubdiv on my system. CMake 3.6.3 works for me,
but 3.7.2 fails.

Ideally the FindCUDA.cmake code could be made more robust to handle
definitions containing quotation marks. In any case removing the extra
quotes from the OPENSUBDIV_VERSION_STRING (set it to 3.1.1 rather than
"3.1.1") resolves the problem and allows opensubdiv to compile
successfully with CMake 3.7.2.

This produces an additional issue that OPENSUBDIV_VERSION_STRING is no longer a
string in the examples files where it is concatenated into the window title.

The fix is creating a macro to stringify the token: #define STRINGIFY(a) #a
Since it will be referenced by 10 example files I have created a new
header file examples/common/stringify.h

Then the example code is changed to use the stringify macro
static const char windowTitle[] = "OpenSubdiv glPaintTest" STRINGIFY(OPENSUBDIV_VERSION_STRING);

glImaging uses the macro in a second place, in the line
ofs << "OpenSubdiv      : " << STRINGIFY(OPENSUBDIV_VERSION_STRING) << "\n";
@renexdev
Copy link

Thanks it works!

@dracwyrm
Copy link

The actual fix to this issue is attached at end of this post. There is no need for stringify or any of that. :) I'll create a PR in a bit so people can grab the patch easily, and hopefully upstream can merge it.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e02ce90c..6d4f5342 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,7 +48,7 @@ endif()
     string(REGEX REPLACE "^v" "" OSD_SONAME ${OSD_SONAME})
 
     add_definitions(
-        -DOPENSUBDIV_VERSION_STRING="${OSD_SONAME}"
+        -DOPENSUBDIV_VERSION_STRING=\\\"${OSD_SONAME}\\\"
     )
 

dracwyrm added a commit to dracwyrm/OpenSubdiv that referenced this issue Sep 30, 2017
Closes issue PixarAnimationStudios#922

Signed-off by: Jonathan Scruggs <j.scruggs@gmail.com>
@dracwyrm
Copy link

@jtran56 Hope this PR works for you. I think I signed the CLA thing for a different PR in a different program?

@jtran56
Copy link

jtran56 commented Oct 6, 2017

@dracwyrm Looks like we don't have a CLA from you yet in our records. If you could fill one out and email us as listed in the guidelines, then we can start to accept your pull requests. Thank you! https://github.com/PixarAnimationStudios/OpenSubdiv/blob/master/documentation/contributing.rst#contributor-license-agreement

@davidgyu
Copy link
Member

davidgyu commented Mar 6, 2020

The underlying problem in FindCUDA.cmake has been fixed for the last several releases of CMake (tested back through CMake v3.9).

We're going to close this as not-fixing based on our recent testing of OpenSubdiv releases across multiple platforms Windows, Linux, macOS, etc, including VS 2013/2015/2017/2019 and CUDA 8, 9, 10 on Windows.

Thanks!

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

No branches or pull requests

6 participants