PixarAnimationStudios / OpenSubdiv

An Open-Source subdivision surface library.
graphics.pixar.com/opensubdiv
Other
2.88k stars 558 forks source link

Corrections to allow for LLVM Clang builds on Windows. #1289

Closed thomthom closed 1 year ago

thomthom commented 1 year ago

I ran into some issues while getting OSD building on Windows with LLVM Clang.

My test configuration:

mkdir build
cmake ^
  -B build ^
  -S . ^
  -A x64 ^
  -T ClangCL ^
  -D CMAKE_TOOLCHAIN_FILE=C:/Users/Thomas/SourceTree/vcpkg/scripts/buildsystems/vcpkg.cmake ^
  -D CMAKE_CXX_FLAGS="-w" ^
  -D CMAKE_C_FLAGS="-w" ^
  -D NO_PTEX=1 ^
  -D NO_DOC=1 ^
  -D NO_OMP=1 ^
  -D NO_TBB=1 ^
  -D NO_CUDA=1 ^
  -D NO_OPENCL=1 ^
  -D NO_CLEW=1 ^
  -D NO_METAL=1 ^
  -D NO_GLFW_X11=1 ^
  -D NO_MACOS_FRAMEWORK=1
cmake --build build

Sample of errors this PR fixes:

C:\Users\Thomas\SourceTree\OpenSubdiv\opensubdiv\far\catmarkPatchBuilder.cpp(767,43): error : use of undeclared identifier 'M_PI' [C:\Users\Thomas\SourceTree\OpenSubdiv\build\opensubdiv\far\far_obj.vcxproj]
C:\Users\Thomas\SourceTree\OpenSubdiv\opensubdiv\far\catmarkPatchBuilder.cpp(767,64): error : use of undeclared identifier 'M_PI' [C:\Users\Thomas\SourceTree\OpenSubdiv\build\opensubdiv\far\far_obj.vcxproj]
C:\Users\Thomas\SourceTree\OpenSubdiv\opensubdiv\far\catmarkPatchBuilder.cpp(145,30): error : use of undeclared identifier 'M_PI' [C:\Users\Thomas\SourceTree\OpenSubdiv\build\opensubdiv\far\far_obj.vcxproj]
 osd_static_gpu.vcxproj -> C:\Users\Thomas\SourceTree\OpenSubdiv\build\lib\Debug\osdGPU.lib
  Generating shader.gen.h
  In file included from C:\Users\Thomas\SourceTree\OpenSubdiv\examples\dxViewer\dxviewer.cpp:66:
C:\Users\Thomas\SourceTree\OpenSubdiv\examples\dxViewer/../common/stopwatch.h(45,9): error : use of undeclared identifier 'gettimeofday' [C:\Users\Thomas\SourceTree\OpenSubdiv\build\examples\dxViewer\dxViewer.vcxproj]
C:\Users\Thomas\SourceTree\OpenSubdiv\examples\dxViewer/../common/stopwatch.h(52,9): error : use of undeclared identifier 'gettimeofday' [C:\Users\Thomas\SourceTree\OpenSubdiv\build\examples\dxViewer\dxViewer.vcxproj]
  In file included from C:\Users\Thomas\SourceTree\OpenSubdiv\regression\far_perf\far_perf.cpp:39:
C:\Users\Thomas\SourceTree\OpenSubdiv\regression\far_perf/../../examples/common/stopwatch.h(45,9): error : use of undeclared identifier 'gettimeofday' [C:\Users\Thomas\SourceTree\OpenSubdiv\build\regression\far_perf\far_perf.vcxproj]
C:\Users\Thomas\SourceTree\OpenSubdiv\regression\far_perf/../../examples/common/stopwatch.h(52,9): error : use of undeclared identifier 'gettimeofday' [C:\Users\Thomas\SourceTree\OpenSubdiv\build\regression\far_perf\far_perf.vcxproj]
  far_regression.vcxproj -> C:\Users\Thomas\SourceTree\OpenSubdiv\build\bin\Debug\far_regression.exe
C:\Users\Thomas\SourceTree\OpenSubdiv\opensubdiv\osd/../osd/types.h(79,21): error : expected unqualified-id [C:\Users\Thomas\SourceTree\OpenSubdiv\build\opensubdiv\osd\osd_gpu_obj.vcxproj]
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared\minwindef.h(193,29): message : expanded from macro 'max' [C:\Users\Thomas\SourceTree\OpenSubdiv\build\opensubdiv\osd\osd_gpu_obj.vcxproj]
  In file included from C:\Users\Thomas\SourceTree\OpenSubdiv\opensubdiv\osd\glPatchTable.cpp:27:

Note, I muted all warnings using -w because there was a lot of them. What is this project's policy/goal towards compiler warnings?

davidgyu commented 1 year ago

Filed as internal issue #OSD-401

davidgyu commented 1 year ago

Thanks @thomthom!