2014-09-05 22:07:46 +00:00
|
|
|
..
|
2013-09-26 19:04:57 +00:00
|
|
|
Copyright 2013 Pixar
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
with the following modification; you may not use this file except in
|
|
|
|
compliance with the Apache License and the following modification to it:
|
|
|
|
Section 6. Trademarks. is deleted and replaced with:
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
6. Trademarks. This License does not grant permission to use the trade
|
|
|
|
names, trademarks, service marks, or product names of the Licensor
|
|
|
|
and its affiliates, except as required to comply with Section 4(c) of
|
|
|
|
the License and to reproduce the content of the NOTICE file.
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
You may obtain a copy of the Apache License at
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-09-26 19:04:57 +00:00
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the Apache License with the above modification is
|
|
|
|
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
KIND, either express or implied. See the Apache License for the specific
|
|
|
|
language governing permissions and limitations under the Apache License.
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-07-04 17:47:56 +00:00
|
|
|
|
2015-06-18 05:04:16 +00:00
|
|
|
Building with CMake
|
2013-07-04 17:47:56 +00:00
|
|
|
-------------------
|
|
|
|
|
|
|
|
.. contents::
|
|
|
|
:local:
|
|
|
|
:backlinks: none
|
|
|
|
|
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
Overview
|
|
|
|
========
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
Assuming that you have `cloned <getting_started.html>`__ the source repository
|
2013-07-04 17:47:56 +00:00
|
|
|
and selected an appropriate release branch, the following instructions will
|
2015-06-21 05:31:03 +00:00
|
|
|
walk you through the CMake and configuration and build process.
|
2013-07-04 17:47:56 +00:00
|
|
|
|
2015-06-21 05:31:03 +00:00
|
|
|
CMake is a cross-platform, open-source build system. CMake controls the compilation
|
2014-09-05 22:07:46 +00:00
|
|
|
process using platform independent configuration files in order to generate
|
2015-06-21 05:31:03 +00:00
|
|
|
Makefiles and workspaces that are native to the platform of choice.
|
2013-07-04 17:47:56 +00:00
|
|
|
|
|
|
|
The process involves the following steps:
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
#. Locate & build the requisite dependencies
|
|
|
|
#. Configure & run CMake to generate Makefiles / MSVC solution / XCode project
|
|
|
|
#. Run the build from make / MSVC / XCode
|
2013-07-04 17:47:56 +00:00
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
Step 1: Dependencies
|
|
|
|
====================
|
|
|
|
|
2015-06-21 05:31:03 +00:00
|
|
|
CMake will adapt the build based on which dependencies have been successfully
|
2013-07-04 17:47:56 +00:00
|
|
|
discovered and will disable certain features and code examples accordingly.
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
Please refer to the documentation of each of the dependency packages for specific
|
2013-07-04 17:47:56 +00:00
|
|
|
build and installation instructions.
|
|
|
|
|
|
|
|
Required
|
|
|
|
________
|
2015-06-23 05:56:07 +00:00
|
|
|
- `CMake <http://www.cmake.org/>`__ version 2.8
|
2013-07-04 17:47:56 +00:00
|
|
|
|
|
|
|
Optional
|
|
|
|
________
|
|
|
|
|
2013-07-30 02:14:19 +00:00
|
|
|
- `Ptex <http://ptex.us/>`__ (support features for ptex textures and the
|
|
|
|
ptexViewer example)
|
|
|
|
- `Zlib <http://www.zlib.net/>`__ (required for Ptex under Windows)
|
2014-02-20 19:05:09 +00:00
|
|
|
- `GLEW <http://glew.sourceforge.net/>`__
|
2013-07-04 17:47:56 +00:00
|
|
|
- `CUDA <http://www.nvidia.com/object/cuda_home_new.html>`__
|
2013-08-15 23:11:33 +00:00
|
|
|
- `TBB <http://www.threadingbuildingblocks.org/>`__
|
2013-07-04 17:47:56 +00:00
|
|
|
- `OpenCL <http://www.khronos.org/opencl/>`__
|
2013-07-30 02:14:19 +00:00
|
|
|
- `DX11 SDK <http://www.microsoft.com/>`__
|
2013-07-04 17:47:56 +00:00
|
|
|
- `GLFW <https://github.com/glfw/glfw>`__ (required for standalone examples
|
|
|
|
and some regression tests)
|
2013-07-30 02:14:19 +00:00
|
|
|
- `Docutils <http://docutils.sourceforge.net/>`__ (required for reST-based documentation)
|
2015-04-25 02:16:34 +00:00
|
|
|
- `Python Pygments <http://pygments.org/>`__ (required for Docutils reST styling)
|
|
|
|
- `Doxygen <http://www.doxygen.org/>`__
|
2013-07-04 17:47:56 +00:00
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
Step 2: Configuring CMake
|
|
|
|
=========================
|
|
|
|
|
|
|
|
One way to configure CMake is to use the `CMake GUI <http://www.cmake.org/cmake/help/runningcmake.html>`__.
|
|
|
|
In many cases CMake can fall back on default standard paths in order to find the
|
|
|
|
packages that OpenSubdiv depends on. For non-standard installations however, a
|
|
|
|
complete set of override variables is available. The following sub-section lists
|
|
|
|
some of these variables. For more specific details, please consult the source of
|
|
|
|
the custom CMake modules in the OpenSubdiv/cmake/ folder.
|
|
|
|
|
|
|
|
Useful Build Options
|
|
|
|
____________________
|
|
|
|
|
2015-06-23 05:56:07 +00:00
|
|
|
The following configuration arguments can be passed to the CMake command line.
|
2013-07-04 17:47:56 +00:00
|
|
|
|
|
|
|
.. code:: c++
|
|
|
|
|
|
|
|
-DCMAKE_BUILD_TYPE=[Debug|Release]
|
|
|
|
|
|
|
|
-DCMAKE_INSTALL_PREFIX=[base path to install OpenSubdiv (default: Current directory)]
|
|
|
|
-DCMAKE_LIBDIR_BASE=[library directory basename (default: lib)]
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-07-04 17:47:56 +00:00
|
|
|
-DCUDA_TOOLKIT_ROOT_DIR=[path to CUDA]
|
|
|
|
-DPTEX_LOCATION=[path to Ptex]
|
|
|
|
-DGLEW_LOCATION=[path to GLEW]
|
|
|
|
-DGLFW_LOCATION=[path to GLFW]
|
|
|
|
-DMAYA_LOCATION=[path to Maya]
|
2013-08-15 23:11:33 +00:00
|
|
|
-DTBB_LOCATION=[path to Intel's TBB]
|
2013-08-15 22:21:00 +00:00
|
|
|
-DICC_LOCATION=[path to Intel's C++ Studio XE]
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-07-12 01:55:17 +00:00
|
|
|
-DNO_LIB=1 // disable the opensubdiv libs build (caveat emptor)
|
2013-07-05 22:36:54 +00:00
|
|
|
-DNO_EXAMPLES=1 // disable examples build
|
2014-09-05 22:07:46 +00:00
|
|
|
-DNO_TUTORIALS=1 // disable tutorials build
|
2013-07-05 22:36:54 +00:00
|
|
|
-DNO_REGRESSION=1 // disable regression tests build
|
2014-05-16 12:21:41 +00:00
|
|
|
-DNO_MAYA=1 // disable Maya plugin build
|
2014-05-16 12:27:49 +00:00
|
|
|
-DNO_PTEX=1 // disable PTex support
|
2013-07-05 22:36:54 +00:00
|
|
|
-DNO_DOC=1 // disable documentation build
|
|
|
|
-DNO_OMP=1 // disable OpenMP
|
2013-08-15 23:11:33 +00:00
|
|
|
-DNO_TBB=1 // disable TBB
|
2013-07-12 01:55:17 +00:00
|
|
|
-DNO_CUDA=1 // disable CUDA
|
2014-05-16 12:08:11 +00:00
|
|
|
-DNO_OPENCL=1 // disable OpenCL
|
2014-09-05 22:07:46 +00:00
|
|
|
-DNO_OPENGL=1 // disable OpenGL
|
2014-05-21 08:10:45 +00:00
|
|
|
-DNO_CLEW=1 // disable CLEW wrapper library
|
2013-07-04 17:47:56 +00:00
|
|
|
|
|
|
|
Environment Variables
|
|
|
|
_____________________
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
The paths to Maya, Ptex, GLFW, GLEW and other dependencies can also be specified
|
|
|
|
through the following environment variables:
|
2013-07-04 17:47:56 +00:00
|
|
|
|
|
|
|
.. code:: c++
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
MAYA_LOCATION, PTEX_LOCATION, GLFW_LOCATION, GLEW_LOCATION
|
|
|
|
|
2013-07-04 17:47:56 +00:00
|
|
|
Automated Script
|
|
|
|
________________
|
|
|
|
|
|
|
|
The GUI solution will probably become a burden for active developpers who tend to
|
2013-07-08 01:20:46 +00:00
|
|
|
re-run the configuration step fairly often. A scripted solution can save a lot of
|
|
|
|
time. Here is a typical workflow:
|
|
|
|
|
|
|
|
.. code:: c++
|
|
|
|
|
|
|
|
git clone https://github.com/PixarAnimationStudios/OpenSubdiv.git <folder>
|
|
|
|
cd <folder>
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
source ../../cmake_setup
|
|
|
|
|
|
|
|
|
|
|
|
Where *cmake_setup* is a configuration script.
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
Here is an example CMake configuration script for a full typical windows-based
|
2013-07-08 01:20:46 +00:00
|
|
|
build that can be run in GitShell :
|
2013-07-04 17:47:56 +00:00
|
|
|
|
|
|
|
.. code:: c++
|
|
|
|
|
|
|
|
#/bin/tcsh
|
|
|
|
|
|
|
|
# Replace the ".." with a full path to the root of the OpenSubdiv source tree if necessary
|
|
|
|
"c:/Program Files (x86)/CMake 2.8/bin/cmake.exe" \
|
|
|
|
-G "Visual Studio 10 Win64" \
|
|
|
|
-D "GLEW_LOCATION:string=c:/Program Files/glew-1.9.0" \
|
|
|
|
-D "GLFW_LOCATION:string=c:/Program Files/glfw-2.7.7.bin.WIN64" \
|
|
|
|
-D "OPENCL_INCLUDE_DIRS:string=c:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.2/OpenCL/common/inc" \
|
|
|
|
-D "_OPENCL_CPP_INCLUDE_DIRS:string=c:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.2/OpenCL/common/inc" \
|
|
|
|
-D "OPENCL_LIBRARIES:string=c:/ProgramData/NVIDIA Corporation/NVIDIA GPU Computing SDK 4.2/OpenCL/common/lib/x64/OpenCL.lib" \
|
|
|
|
-D "MAYA_LOCATION:string=c:/Program Files/Autodesk/Maya2013.5" \
|
|
|
|
-D "PTEX_LOCATION:string=c:/Users/opensubdiv/demo/src/ptex/x64" \
|
|
|
|
..
|
|
|
|
|
|
|
|
# copy Ptex dependencies (Windows only)
|
|
|
|
mkdir -p bin/{Debug,Release}
|
|
|
|
\cp -f c:/Users/opensubdiv/demo/src/zlib-1.2.7/contrib/vstudio/vc10/x64/ZlibDllRelease/zlibwapi.dll bin/Debug/
|
|
|
|
\cp -f c:/Users/opensubdiv/demo/src/zlib-1.2.7/contrib/vstudio/vc10/x64/ZlibDllRelease/zlibwapi.dll bin/Release/
|
|
|
|
\cp -f c:/Users/opensubdiv/demo/src/ptex/x64/lib/Ptex.dll bin/Debug/
|
|
|
|
\cp -f c:/Users/opensubdiv/demo/src/ptex/x64/lib/Ptex.dll bin/Release/
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-02-20 19:05:09 +00:00
|
|
|
.. container:: impnotip
|
|
|
|
|
2015-06-23 02:53:52 +00:00
|
|
|
**Important**
|
2014-02-20 19:05:09 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
Notice that the following scripts start by **recursively removing** the *../build/* and
|
2014-02-20 19:05:09 +00:00
|
|
|
*../inst/* directories. Make sure you modify them to suit your build workflow.
|
2013-07-08 01:20:46 +00:00
|
|
|
|
|
|
|
Here is a similar script for \*Nix-based platforms:
|
|
|
|
|
|
|
|
.. code:: c++
|
|
|
|
|
|
|
|
echo "*** Removing build"
|
|
|
|
cd ..; rm -rf build/ inst/; mkdir build; cd build;
|
|
|
|
echo "*** Running cmake"
|
|
|
|
cmake -DPTEX_LOCATION=/home/opensubdiv/dev/opensource/ptex/install \
|
|
|
|
-DGLEW_LOCATION=/home/opensubdiv/dev/opensource/glew/glew-1.9.0 \
|
|
|
|
-DGLFW_LOCATION=/home/opensubdiv/dev/opensource/glfw/build \
|
|
|
|
-DDOXYGEN_EXECUTABLE=/home/opensubdiv/dev/opensource/doxygen/inst/bin/doxygen \
|
|
|
|
-DCMAKE_INSTALL_PREFIX=../inst \
|
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
..
|
|
|
|
|
2014-02-20 19:05:09 +00:00
|
|
|
Here is a similar script for OSX:
|
2013-07-08 01:20:46 +00:00
|
|
|
|
2014-02-20 19:05:09 +00:00
|
|
|
.. code:: c++
|
2013-07-08 01:20:46 +00:00
|
|
|
|
2014-02-20 19:05:09 +00:00
|
|
|
echo "*** Removing build"
|
|
|
|
cd ..; rm -rf build/ inst/; mkdir build; cd build;
|
|
|
|
echo "*** Running cmake"
|
|
|
|
cmake -DOPENGL_INCLUDE_DIR=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/OpenGL.framework/Headers \
|
|
|
|
-DGLFW_LOCATION=/Users/opensubdiv/dev/opensource/glfw/inst \
|
|
|
|
-DNO_OMP=1 -DNO_REGRESSION=0 \
|
|
|
|
-DCMAKE_INSTALL_PREFIX=../inst \
|
|
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
|
|
.."
|
2013-07-04 17:47:56 +00:00
|
|
|
|
2013-08-15 22:21:00 +00:00
|
|
|
Using Intel's C++ Studio XE
|
|
|
|
___________________________
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
OpenSubdiv can be also be built with `Intel's C++ compiler <http://software.intel.com/en-us/intel-compilers>`__
|
2013-08-15 22:21:00 +00:00
|
|
|
(icc). The default compiler can be overriden in CMake with the following configuration options:
|
|
|
|
|
|
|
|
.. code:: c++
|
|
|
|
|
|
|
|
-DCMAKE_CXX_COMPILER=[path to icc executable]
|
|
|
|
-DCMAKE_C_COMPILER=[path to icc executable]
|
|
|
|
|
|
|
|
The installation location of the C++ Studio XE can be overriden with:
|
|
|
|
|
|
|
|
.. code:: c++
|
|
|
|
|
|
|
|
-DICC_LOCATION=[path to Intel's C++ Studio XE]
|
|
|
|
|
|
|
|
|
2014-02-20 19:05:09 +00:00
|
|
|
Using Clang
|
|
|
|
___________
|
|
|
|
|
|
|
|
CMake can also be overriden to use the `clang <http://clang.llvm.org/>`__ compilers by configuring the following options:
|
|
|
|
|
|
|
|
.. code:: c++
|
|
|
|
|
|
|
|
-DCMAKE_CXX_COMPILER=clang++ \
|
|
|
|
-DCMAKE_C_COMPILER=clang \
|
|
|
|
|
|
|
|
|
2013-07-04 17:47:56 +00:00
|
|
|
----
|
|
|
|
|
|
|
|
Step 3: Building
|
|
|
|
================
|
|
|
|
|
2014-02-20 19:05:09 +00:00
|
|
|
CMake provides a cross-platform command-line build:
|
|
|
|
|
|
|
|
.. code:: c++
|
|
|
|
|
|
|
|
cmake --build . --target install --config Release
|
|
|
|
|
2015-06-23 02:53:52 +00:00
|
|
|
Alternatively, you can use native toolkits to launch the build. The steps differ for each OS:
|
2013-07-04 17:47:56 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
* *Windows* :
|
2015-06-23 05:56:07 +00:00
|
|
|
launch VC++ with the solution generated by CMake in your build directory.
|
2013-07-04 17:47:56 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
* *OSX* :
|
2014-02-20 19:05:09 +00:00
|
|
|
run *make* in the build directory
|
2013-07-06 01:41:04 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
* *\*Nix* :
|
|
|
|
| run *make* in your build directory
|
2013-07-08 01:20:46 +00:00
|
|
|
| - use the *clean* target to remove previous build results
|
|
|
|
| - use *VERBOSE=1* for verbose build output
|
2014-02-20 19:05:09 +00:00
|
|
|
|
|
|
|
.. container:: notebox
|
|
|
|
|
|
|
|
**Note**
|
|
|
|
We recommend against using CMake's Xcode project generator (-G "Xcode") on OSX, as it seems to
|
|
|
|
generate some dependencies incorrectly. We recommend instead reverting to Makefiles on OSX, and
|
2014-09-05 22:07:46 +00:00
|
|
|
launching *make*, instead of *xcodebuild* to execute the build (make sure to install the command
|
2014-02-20 19:05:09 +00:00
|
|
|
line tools in Xcode)
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-07-06 01:41:04 +00:00
|
|
|
----
|
|
|
|
|
|
|
|
Build Targets
|
|
|
|
_____________
|
|
|
|
|
|
|
|
Makefile-based builds allow the use of named target. Here are some of the more
|
|
|
|
useful target names:
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-07-08 01:20:46 +00:00
|
|
|
*osd_\<static\|dynamic\>_\<CPU\|GPU\>*
|
|
|
|
| The core components of the OpenSubdiv libraries
|
|
|
|
|
|
|
|
|
|
|
|
|
*\<example_name\>*
|
|
|
|
| Builds specific code examples by name (glViewer, ptexViewer...)
|
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-07-08 01:20:46 +00:00
|
|
|
*doc*
|
|
|
|
| Builds ReST and doxygen documentation
|
|
|
|
|
|
|
|
|
|
|
|
|
*doc_html*
|
|
|
|
| Builds ReST documentation
|
|
|
|
|
|
|
|
|
|
|
|
|
*doc_doxy*
|
|
|
|
| Builds Doxygen documentation
|
|
|
|
|
|
2013-07-04 17:47:56 +00:00
|
|
|
|
2015-06-18 05:04:16 +00:00
|
|
|
|
|
|
|
----
|
|
|
|
|
|
|
|
Compiling & Linking an OpenSubdiv Application
|
|
|
|
=============================================
|
|
|
|
|
|
|
|
Here are example commands for building an OpenSubdiv application on several architectures:
|
|
|
|
|
|
|
|
**Linux**
|
|
|
|
::
|
|
|
|
|
|
|
|
g++ -I$OPENSUBDIV/include -c myapp.cpp
|
|
|
|
g++ myapp.o -L$OPENSUBDIV/lib -losdCPU -losdGPU -o myapp
|
|
|
|
|
|
|
|
**Mac OS-X**
|
|
|
|
::
|
|
|
|
|
|
|
|
g++ -I$OPENSUBDIV/include -c myapp.cpp
|
|
|
|
g++ myapp.o -L$OPENSUBDIV/lib -losdCPU -losdGPU -o myapp
|
|
|
|
install_name_tool -add_rpath $OPENSUBDIV/lib myapp
|
|
|
|
|
|
|
|
(On 64-bit OS-X: add ``-m64`` after each ``g++``.)
|
|
|
|
|
|
|
|
**Windows**
|
|
|
|
::
|
|
|
|
|
|
|
|
cl /nologo /MT /TP /DWIN32 /I"%OPENSUBDIV%\include" -c myapp.cpp
|
|
|
|
link /nologo /out:myapp.exe /LIBPATH:"%OPENSUBDIV%\lib" libosdCPU.lib libosdGPU.lib myapp.obj
|
|
|
|
|
|
|
|
|
|
|
|
.. container:: impnotip
|
|
|
|
|
|
|
|
**Note:**
|
|
|
|
|
|
|
|
HBR uses the offsetof macro on a templated struct, which appears to spurriously set off a
|
|
|
|
warning in both gcc and Clang. It is recommended to turn the warning off with the
|
|
|
|
*-Wno-invalid-offsetof* flag.
|