2012-06-08 18:18:20 +00:00
|
|
|
#
|
2013-09-26 19:04:57 +00:00
|
|
|
# Copyright 2013 Pixar
|
2012-06-08 18:18:20 +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:
|
2012-06-08 18:18:20 +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.
|
2012-06-08 18:18:20 +00:00
|
|
|
#
|
2013-09-26 19:04:57 +00:00
|
|
|
# You may obtain a copy of the Apache License at
|
2012-06-08 18:18:20 +00:00
|
|
|
#
|
2013-09-26 19:04:57 +00:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +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.
|
2012-06-08 18:18:20 +00:00
|
|
|
#
|
|
|
|
|
2022-09-09 16:11:37 +00:00
|
|
|
cmake_minimum_required(VERSION 3.12)
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2021-10-09 07:27:52 +00:00
|
|
|
project(OpenSubdiv)
|
|
|
|
|
2016-06-10 00:04:26 +00:00
|
|
|
# Turn on folder support
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
2013-02-01 18:09:55 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Obtain OpenSubdiv API version from version.h file
|
2016-07-09 05:45:33 +00:00
|
|
|
if(EXISTS "${OpenSubdiv_SOURCE_DIR}/opensubdiv/version.h")
|
|
|
|
file(STRINGS "${OpenSubdiv_SOURCE_DIR}/opensubdiv/version.h"
|
2013-02-01 18:09:55 +00:00
|
|
|
OpenSubdiv_VERSION REGEX "^#define OPENSUBDIV_VERSION .*$")
|
|
|
|
string(REPLACE "#define OPENSUBDIV_VERSION " "" OpenSubdiv_VERSION ${OpenSubdiv_VERSION})
|
2013-11-19 00:02:27 +00:00
|
|
|
else()
|
2016-07-09 05:45:33 +00:00
|
|
|
message(FATAL_ERROR, "Cannot locate opensubdiv/version.h in ${OpenSubdiv_SOURCE_DIR}")
|
2013-02-01 18:09:55 +00:00
|
|
|
endif()
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
# Evaluate 'soname' from OSD version
|
|
|
|
|
|
|
|
# replace '_' with '.'
|
|
|
|
string(REGEX REPLACE "(_)" "." OSD_SONAME ${OpenSubdiv_VERSION})
|
|
|
|
|
|
|
|
# remove starting 'v' character
|
|
|
|
string(REGEX REPLACE "^v" "" OSD_SONAME ${OSD_SONAME})
|
|
|
|
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_VERSION_STRING="${OSD_SONAME}"
|
|
|
|
)
|
|
|
|
|
2013-02-01 18:09:55 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2020-10-28 20:40:18 +00:00
|
|
|
message(STATUS "Compiling ${PROJECT_NAME} version ${OpenSubdiv_VERSION}")
|
2012-06-08 18:18:20 +00:00
|
|
|
message(STATUS "Using cmake version ${CMAKE_VERSION}")
|
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2020-10-28 20:40:18 +00:00
|
|
|
# Determine if the project is built as a subproject (using add_subdirectory)
|
2021-02-04 18:08:43 +00:00
|
|
|
# or if it is the main project.
|
|
|
|
set(MAIN_PROJECT OFF)
|
2020-10-28 20:40:18 +00:00
|
|
|
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
|
2021-02-04 18:08:43 +00:00
|
|
|
set(MAIN_PROJECT ON)
|
2020-10-28 20:40:18 +00:00
|
|
|
endif()
|
|
|
|
|
2012-06-08 18:18:20 +00:00
|
|
|
# Specify the default install path
|
2013-04-23 02:35:41 +00:00
|
|
|
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
|
2014-04-09 20:43:38 +00:00
|
|
|
SET( CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/" )
|
2013-04-23 02:35:41 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT DEFINED CMAKE_INCDIR_BASE)
|
2013-08-01 20:27:27 +00:00
|
|
|
set( CMAKE_INCDIR_BASE include/opensubdiv )
|
2013-04-23 02:35:41 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT DEFINED CMAKE_BINDIR_BASE)
|
|
|
|
set( CMAKE_BINDIR_BASE bin )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT DEFINED CMAKE_LIBDIR_BASE)
|
|
|
|
set( CMAKE_LIBDIR_BASE lib )
|
|
|
|
endif()
|
|
|
|
|
2016-07-26 19:41:18 +00:00
|
|
|
if (NOT DEFINED CMAKE_FRAMEWORKDIR_BASE)
|
|
|
|
set( CMAKE_FRAMEWORKDIR_BASE Frameworks )
|
|
|
|
endif()
|
|
|
|
|
2013-04-23 02:35:41 +00:00
|
|
|
if (NOT DEFINED CMAKE_PLUGINDIR_BASE)
|
|
|
|
set( CMAKE_PLUGINDIR_BASE plugin )
|
|
|
|
endif()
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2013-08-07 23:17:46 +00:00
|
|
|
if (NOT DEFINED CMAKE_DOCDIR_BASE)
|
|
|
|
set( CMAKE_DOCDIR_BASE share/doc/opensubdiv )
|
2013-09-17 01:56:40 +00:00
|
|
|
else()
|
|
|
|
if (IS_ABSOLUTE ${CMAKE_DOCDIR_BASE})
|
2014-04-09 20:43:38 +00:00
|
|
|
set( CMAKE_DOCDIR_BASE "${CMAKE_DOCDIR_BASE}" )
|
2013-09-17 01:56:40 +00:00
|
|
|
else()
|
2014-04-09 20:43:38 +00:00
|
|
|
set( CMAKE_DOCDIR_BASE "${CMAKE_INSTALL_PREFIX}/${CMAKE_DOCDIR_BASE}" )
|
2013-09-17 01:56:40 +00:00
|
|
|
endif()
|
2013-08-07 23:17:46 +00:00
|
|
|
endif()
|
|
|
|
|
2012-12-21 02:34:18 +00:00
|
|
|
# Allow install path to be overridden for cross-compile builds
|
|
|
|
if(LIBRARY_OUTPUT_PATH_ROOT)
|
2014-04-09 20:43:38 +00:00
|
|
|
SET( CMAKE_INSTALL_PREFIX "${LIBRARY_OUTPUT_PATH_ROOT}/" )
|
2012-12-21 02:34:18 +00:00
|
|
|
endif()
|
|
|
|
|
2021-02-04 22:49:38 +00:00
|
|
|
if (MAIN_PROJECT)
|
2020-10-28 20:40:18 +00:00
|
|
|
# Set the directory where the executables will be stored.
|
|
|
|
set(EXECUTABLE_OUTPUT_PATH
|
|
|
|
"${PROJECT_BINARY_DIR}/bin"
|
|
|
|
CACHE PATH
|
|
|
|
"Directory where executables will be stored"
|
|
|
|
)
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2020-10-28 20:40:18 +00:00
|
|
|
# Set the directory where the libraries will be stored.
|
|
|
|
set(LIBRARY_OUTPUT_PATH
|
|
|
|
"${PROJECT_BINARY_DIR}/lib"
|
|
|
|
CACHE PATH
|
|
|
|
"Directory where all libraries will be stored"
|
|
|
|
)
|
|
|
|
endif()
|
2012-06-08 18:18:20 +00:00
|
|
|
|
|
|
|
# Specify the list of directories to search for cmake modules.
|
|
|
|
set(CMAKE_MODULE_PATH
|
2014-04-09 20:43:38 +00:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
2012-06-08 18:18:20 +00:00
|
|
|
)
|
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
2014-09-24 21:47:57 +00:00
|
|
|
# OpenSubdiv trips bugs in some older gcc versions
|
|
|
|
if (CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
|
2015-07-30 17:24:25 +00:00
|
|
|
message(WARNING "g++ 4.8 or newer recommended")
|
2014-09-24 21:47:57 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
# Detect Clang (until a cmake version provides built-in variables)
|
2020-02-20 22:41:04 +00:00
|
|
|
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
2013-01-24 21:40:43 +00:00
|
|
|
set(CMAKE_COMPILER_IS_CLANGCC 1)
|
2020-02-20 22:41:04 +00:00
|
|
|
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "Intel")
|
2013-08-15 22:21:00 +00:00
|
|
|
set(CMAKE_COMPILER_IS_ICC 1)
|
2013-01-24 21:40:43 +00:00
|
|
|
endif()
|
|
|
|
|
2013-01-22 22:47:46 +00:00
|
|
|
|
2014-05-17 01:26:00 +00:00
|
|
|
if (NOT CMAKE_COMPILER_IS_ICC)
|
|
|
|
# Currently icc has a bug that asserts when linking rpaths containing long
|
|
|
|
# sequences of ':' that this command causes. The consequence is that examples
|
|
|
|
# built and installed using icc will not have an rpath pointing to the built
|
|
|
|
# OSD library which they depend on and will have to set LD_LIBRARY_PATH instead.
|
|
|
|
list(APPEND CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# add the automatically determined parts of the RPATH
|
|
|
|
# which point to directories outside the build tree to the install RPATH
|
|
|
|
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
2016-07-26 19:41:18 +00:00
|
|
|
# ensure that ARC is shown as enabled in the Xcode UI
|
|
|
|
if(CMAKE_GENERATOR STREQUAL "Xcode")
|
|
|
|
set (CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC "YES")
|
|
|
|
endif()
|
|
|
|
|
2014-05-17 01:26:00 +00:00
|
|
|
|
2013-02-08 21:51:11 +00:00
|
|
|
set(OSD_COMPILER_FLAGS)
|
|
|
|
|
2015-08-12 18:03:27 +00:00
|
|
|
# Disable spurious warnings in gcc builds and clang
|
2014-09-24 21:47:57 +00:00
|
|
|
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANGCC OR CMAKE_COMPILER_IS_ICC )
|
2013-01-24 21:40:43 +00:00
|
|
|
|
|
|
|
# Turn on all warnings
|
2014-05-15 20:34:32 +00:00
|
|
|
if(CMAKE_COMPILER_IS_ICC)
|
2014-09-05 22:07:46 +00:00
|
|
|
list(APPEND OSD_COMPILER_FLAGS -w2 -wd1572 -wd1418 -wd981 -wd383 -wd193 -wd444)
|
2014-05-15 20:34:32 +00:00
|
|
|
else()
|
|
|
|
list(APPEND OSD_COMPILER_FLAGS -Wall -Wextra)
|
|
|
|
endif()
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
# HBR uses the offsetof macro on a templated struct, which appears
|
2015-08-12 18:03:27 +00:00
|
|
|
# to spuriously set off this warning in both gcc and Clang
|
2013-02-08 21:51:11 +00:00
|
|
|
list(APPEND OSD_COMPILER_FLAGS -Wno-invalid-offsetof)
|
2013-05-17 19:44:30 +00:00
|
|
|
|
|
|
|
# HBR uses unions as an optimization for its memory allocation.
|
|
|
|
# Type casting between union members breaks strict aliasing rules from
|
|
|
|
# gcc 4.4.1 versions onwards. We disable the warning but keep aliasing
|
|
|
|
# optimization.
|
|
|
|
list(APPEND OSD_COMPILER_FLAGS -Wno-strict-aliasing)
|
2013-08-15 23:11:33 +00:00
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
# FAR and OSD have templated virtual function implementations that trigger
|
2015-08-12 18:03:27 +00:00
|
|
|
# a lot of hidden virtual function overloads (some of them spurious).
|
2013-01-24 21:40:43 +00:00
|
|
|
# Disable those for now in Clang.
|
|
|
|
if(CMAKE_COMPILER_IS_CLANGCC)
|
2013-02-08 21:51:11 +00:00
|
|
|
list(APPEND OSD_COMPILER_FLAGS -Wno-overloaded-virtual)
|
2013-01-24 21:40:43 +00:00
|
|
|
endif()
|
|
|
|
|
2013-08-15 22:21:00 +00:00
|
|
|
# Intel's icc compiler requires some libraries linked
|
|
|
|
if(CMAKE_COMPILER_IS_ICC)
|
|
|
|
|
|
|
|
foreach (ICC_LIB iomp5 irng intlc)
|
|
|
|
|
2013-09-05 01:59:46 +00:00
|
|
|
if(CMAKE_SIZEOF_VOID_P MATCHES "8")
|
|
|
|
list(APPEND ICC_LIB_ARCH "intel64")
|
|
|
|
elseif(CMAKE_SIZEOF_VOID_P MATCHES "4")
|
|
|
|
list(APPEND ICC_LIB_ARCH "ia32")
|
|
|
|
endif()
|
|
|
|
|
2013-08-15 22:21:00 +00:00
|
|
|
find_library( ICC_${ICC_LIB}
|
|
|
|
NAMES
|
|
|
|
${ICC_LIB}
|
2015-02-12 18:57:04 +00:00
|
|
|
HINTS
|
|
|
|
${ICC_LOCATION}
|
2013-08-15 22:21:00 +00:00
|
|
|
PATHS
|
|
|
|
/opt/intel/lib/
|
|
|
|
PATH_SUFFIXES
|
2013-09-05 01:59:46 +00:00
|
|
|
${ICC_LIB_ARCH}
|
2015-02-12 18:57:04 +00:00
|
|
|
lib/${ICC_LIB_ARCH}
|
2013-08-15 22:21:00 +00:00
|
|
|
)
|
2013-08-15 23:11:33 +00:00
|
|
|
|
2013-08-15 22:21:00 +00:00
|
|
|
if (ICC_${ICC_LIB})
|
|
|
|
list(APPEND ICC_LIBRARIES ${ICC_${ICC_LIB}})
|
|
|
|
else()
|
|
|
|
message( FATAL_ERROR "${ICC_${ICC_LIB}} library not found - required by icc" )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
elseif(MSVC)
|
|
|
|
|
|
|
|
# Turn on all warnings
|
2013-02-08 21:51:11 +00:00
|
|
|
list(APPEND OSD_COMPILER_FLAGS /Wall)
|
2013-08-15 23:11:33 +00:00
|
|
|
|
2013-02-08 21:51:11 +00:00
|
|
|
list(APPEND OSD_COMPILER_FLAGS
|
2013-01-24 21:40:43 +00:00
|
|
|
/W3 # Use warning level recommended for production purposes.
|
|
|
|
/WX # Treat all compiler warnings as errors.
|
2013-02-10 02:02:49 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
# warning C4005: macro redefinition
|
|
|
|
/wd4005
|
|
|
|
|
2013-02-10 02:02:49 +00:00
|
|
|
# these warnings are being triggered from inside VC's header files
|
|
|
|
# warning C4350: behavior change: 'member1' called instead of 'member2'
|
2013-02-14 17:44:11 +00:00
|
|
|
/wd4350
|
2013-02-10 02:02:49 +00:00
|
|
|
# warning C4548: expression before comma has no effect; expected expression with side-effect
|
2013-02-14 17:44:11 +00:00
|
|
|
/wd4548
|
2013-08-15 23:11:33 +00:00
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
# Make sure WinDef.h does not define min and max macros which
|
|
|
|
# will conflict with std::min() and std::max().
|
|
|
|
/DNOMINMAX
|
2013-08-15 23:11:33 +00:00
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
# Make sure the constants in <math.h> get defined.
|
|
|
|
/D_USE_MATH_DEFINES
|
2013-08-15 23:11:33 +00:00
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
# Do not enforce MSVC's safe CRT replacements.
|
|
|
|
/D_CRT_SECURE_NO_WARNINGS
|
2013-08-15 23:11:33 +00:00
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
# Disable checked iterators and iterator debugging. Visual Studio
|
|
|
|
# 2008 does not implement std::vector::data(), so we need to take the
|
|
|
|
# address of std::vector::operator[](0) to get the memory location of
|
|
|
|
# a vector's underlying data storage. This does not work for an empty
|
|
|
|
# vector if checked iterators or iterator debugging is enabled.
|
2013-08-15 23:11:33 +00:00
|
|
|
|
|
|
|
# XXXX manuelk : we can't force SECURE_SCL to 0 or client code has
|
|
|
|
# problems linking against OSD if their build is not also
|
|
|
|
# overriding SSCL to the same value.
|
|
|
|
# See : http://msdn.microsoft.com/en-us/library/vstudio/hh697468.aspx
|
2013-03-07 22:04:29 +00:00
|
|
|
#/D_SECURE_SCL=0
|
|
|
|
#/D_HAS_ITERATOR_DEBUGGING=0
|
|
|
|
)
|
2013-02-08 21:51:11 +00:00
|
|
|
|
2016-02-09 16:36:05 +00:00
|
|
|
option(MSVC_STATIC_CRT "Statically link MSVC CRT" OFF)
|
|
|
|
|
|
|
|
if(MSVC_STATIC_CRT)
|
|
|
|
message(STATUS "Using static MSVC CRT")
|
|
|
|
# http://stackoverflow.com/a/32128977/486990
|
|
|
|
add_compile_options(
|
|
|
|
"$<$<CONFIG:Debug>:/MTd>"
|
|
|
|
"$<$<CONFIG:RelWithDebInfo>:/MT>"
|
|
|
|
"$<$<CONFIG:Release>:/MT>"
|
|
|
|
"$<$<CONFIG:MinSizeRel>:/MT>"
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
# Turn off a duplicate LIBCMT linker warning
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS
|
|
|
|
"${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:libcmt.lib")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS
|
|
|
|
"${CMAKE_SHARED_LINKER_FLAGS} /NODEFAULTLIB:libcmt.lib")
|
|
|
|
endif()
|
2013-02-08 21:51:11 +00:00
|
|
|
|
2013-01-10 18:47:50 +00:00
|
|
|
endif()
|
|
|
|
|
2013-08-14 23:38:13 +00:00
|
|
|
if(${SIMD} MATCHES "AVX")
|
|
|
|
list(APPEND OSD_COMPILER_FLAGS -xAVX)
|
2013-08-15 23:11:33 +00:00
|
|
|
endif()
|
2013-08-14 23:38:13 +00:00
|
|
|
|
2013-02-08 21:51:11 +00:00
|
|
|
add_definitions(${OSD_COMPILER_FLAGS})
|
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2012-06-08 18:18:20 +00:00
|
|
|
# Ignore rules that will re-run cmake (this will avoid constant
|
|
|
|
# reloading of the generated Visual Studio project).
|
|
|
|
set(CMAKE_SUPPRESS_REGENERATION TRUE)
|
|
|
|
|
2014-05-16 12:03:52 +00:00
|
|
|
option(PTEX_LOCATION "Path to Ptex" "")
|
|
|
|
option(GLEW_LOCATION "Path to GLEW" "")
|
|
|
|
option(GLFW_LOCATION "Path to GLFW" "")
|
|
|
|
|
|
|
|
option(NO_LIB "Disable the opensubdiv libs build (caveat emptor)" OFF)
|
|
|
|
option(NO_EXAMPLES "Disable examples build" OFF)
|
2014-09-05 22:07:46 +00:00
|
|
|
option(NO_TUTORIALS "Disable tutorials build" OFF)
|
2014-05-16 12:03:52 +00:00
|
|
|
option(NO_REGRESSION "Disable regression tests build" OFF)
|
2014-05-16 12:27:49 +00:00
|
|
|
option(NO_PTEX "Disable PTex support" OFF)
|
2014-05-16 12:03:52 +00:00
|
|
|
option(NO_DOC "Disable documentation build" OFF)
|
|
|
|
option(NO_OMP "Disable OpenMP backend" OFF)
|
|
|
|
option(NO_TBB "Disable TBB backend" OFF)
|
|
|
|
option(NO_CUDA "Disable CUDA backend" OFF)
|
2014-05-16 12:08:11 +00:00
|
|
|
option(NO_OPENCL "Disable OpenCL backend" OFF)
|
2014-05-21 08:10:45 +00:00
|
|
|
option(NO_CLEW "Disable CLEW wrapper library" OFF)
|
2014-09-05 22:07:46 +00:00
|
|
|
option(NO_OPENGL "Disable OpenGL support")
|
2016-07-26 19:41:18 +00:00
|
|
|
option(NO_METAL "Disable Metal support" OFF)
|
2015-01-25 12:24:38 +00:00
|
|
|
option(NO_DX "Disable DirectX support")
|
2015-04-28 21:44:07 +00:00
|
|
|
option(NO_TESTS "Disable all tests")
|
|
|
|
option(NO_GLTESTS "Disable GL tests")
|
2020-03-04 17:50:51 +00:00
|
|
|
option(NO_GLEW "Disable use of GLEW" ON)
|
2017-07-28 02:18:34 +00:00
|
|
|
option(NO_GLFW "Disable components depending on GLFW" OFF)
|
|
|
|
option(NO_GLFW_X11 "Disable GLFW components depending on X11" OFF)
|
2021-10-20 18:35:19 +00:00
|
|
|
option(NO_MACOS_FRAMEWORK "Disable generation of framework on macOS" OFF)
|
2014-05-16 12:03:52 +00:00
|
|
|
|
2016-10-11 20:45:07 +00:00
|
|
|
option(OPENSUBDIV_GREGORY_EVAL_TRUE_DERIVATIVES "Enable true derivative evaluation for Gregory basis patches" OFF)
|
|
|
|
|
2020-03-09 20:14:26 +00:00
|
|
|
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
|
|
|
|
|
|
|
|
# Save the current value of BUILD_SHARED_LIBS and restore it after
|
|
|
|
# processing Find* modules, since some of the Find* modules invoked
|
|
|
|
# below may wind up stomping over this value.
|
|
|
|
set(build_shared_libs "${BUILD_SHARED_LIBS}")
|
|
|
|
|
2015-07-16 05:55:14 +00:00
|
|
|
set(OSD_GPU FALSE)
|
|
|
|
|
2012-06-14 21:03:30 +00:00
|
|
|
# Check for dependencies
|
2013-01-24 21:40:43 +00:00
|
|
|
if(NOT NO_OMP)
|
|
|
|
find_package(OpenMP)
|
|
|
|
endif()
|
2013-08-15 23:11:33 +00:00
|
|
|
if(NOT NO_TBB)
|
|
|
|
find_package(TBB 4.0)
|
|
|
|
endif()
|
2014-09-05 22:07:46 +00:00
|
|
|
if (NOT NO_OPENGL)
|
|
|
|
find_package(OpenGL)
|
|
|
|
endif()
|
2012-12-20 18:25:41 +00:00
|
|
|
find_package(OpenGLES)
|
2014-05-16 12:08:11 +00:00
|
|
|
if(NOT NO_OPENCL)
|
2014-05-21 08:10:45 +00:00
|
|
|
if(NOT NO_CLEW)
|
|
|
|
find_package(CLEW)
|
|
|
|
endif()
|
2014-09-05 22:07:46 +00:00
|
|
|
if (NOT CLEW_FOUND)
|
2014-05-21 08:10:45 +00:00
|
|
|
find_package(OpenCL 1.1)
|
|
|
|
else()
|
|
|
|
set(OPENCL_FOUND TRUE)
|
|
|
|
endif()
|
2014-05-16 12:08:11 +00:00
|
|
|
endif()
|
2013-07-12 01:55:17 +00:00
|
|
|
if(NOT NO_CUDA)
|
|
|
|
find_package(CUDA 4.0)
|
|
|
|
endif()
|
2017-07-28 02:18:34 +00:00
|
|
|
if(NOT NO_GLFW AND NOT NO_OPENGL AND NOT ANDROID AND NOT IOS)
|
2014-09-05 22:07:46 +00:00
|
|
|
find_package(GLFW 3.0.0)
|
2013-08-07 18:16:00 +00:00
|
|
|
endif()
|
2014-05-16 12:27:49 +00:00
|
|
|
if(NOT NO_PTEX)
|
|
|
|
find_package(PTex 2.0)
|
2016-10-01 19:41:33 +00:00
|
|
|
find_package(ZLIB 1.2)
|
2014-05-16 12:27:49 +00:00
|
|
|
endif()
|
2016-07-26 19:41:18 +00:00
|
|
|
if(APPLE AND NOT NO_METAL)
|
|
|
|
find_package(Metal)
|
|
|
|
endif()
|
2013-12-16 07:39:32 +00:00
|
|
|
if (OPENGL_FOUND AND NOT IOS)
|
2015-04-29 18:51:12 +00:00
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_OPENGL
|
|
|
|
)
|
2020-03-04 17:47:36 +00:00
|
|
|
if (NOT NO_GLEW)
|
|
|
|
if (APPLE)
|
|
|
|
find_package(GLEW)
|
|
|
|
else()
|
|
|
|
find_package(GLEW REQUIRED)
|
|
|
|
endif()
|
2013-08-07 22:50:35 +00:00
|
|
|
endif()
|
2020-03-03 23:05:41 +00:00
|
|
|
if(GLEW_FOUND)
|
|
|
|
add_definitions( -DOSD_USES_GLEW )
|
2020-03-04 17:47:36 +00:00
|
|
|
else()
|
|
|
|
add_definitions( -DOSD_USES_INTERNAL_GLAPILOADER )
|
2020-03-03 23:05:41 +00:00
|
|
|
endif()
|
2012-06-14 21:03:30 +00:00
|
|
|
endif()
|
|
|
|
|
2015-04-30 09:25:04 +00:00
|
|
|
if (WIN32 AND NOT NO_DX)
|
|
|
|
find_package(DXSDK)
|
|
|
|
endif()
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
if (NOT NO_DOC)
|
|
|
|
find_package(Doxygen 1.8.4)
|
2015-04-25 02:16:34 +00:00
|
|
|
find_package(Docutils 0.9)
|
2014-09-05 22:07:46 +00:00
|
|
|
else()
|
|
|
|
set(DOXYGEN_EXECUTABLE )
|
|
|
|
endif()
|
|
|
|
|
2020-03-09 20:14:26 +00:00
|
|
|
set(BUILD_SHARED_LIBS "${build_shared_libs}")
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
# Warn about missing dependencies that will cause parts of OpenSubdiv to be
|
|
|
|
# disabled. Also, add preprocessor defines that can be used in the source
|
|
|
|
# code to determine if a specific dependency is present or not.
|
|
|
|
|
|
|
|
if(OPENMP_FOUND)
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_OPENMP
|
|
|
|
${OpenMP_CXX_FLAGS}
|
|
|
|
)
|
2013-08-15 22:21:00 +00:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}")
|
2012-08-04 02:51:27 +00:00
|
|
|
else()
|
2014-05-17 01:26:00 +00:00
|
|
|
if (NOT NO_OMP)
|
|
|
|
message(WARNING
|
|
|
|
"OpenMP was not found : support for OMP parallel compute kernels "
|
|
|
|
"will be disabled in Osd. If your compiler supports OpenMP "
|
|
|
|
"directives, please refer to the FindOpenMP.cmake shared module "
|
|
|
|
"in your cmake installation.")
|
|
|
|
endif()
|
2012-08-04 02:51:27 +00:00
|
|
|
endif()
|
|
|
|
|
2013-08-15 23:11:33 +00:00
|
|
|
if(TBB_FOUND)
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_TBB
|
|
|
|
${TBB_CXX_FLAGS}
|
|
|
|
)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TBB_CXX_FLAGS}")
|
|
|
|
else()
|
2014-05-17 01:26:00 +00:00
|
|
|
if (NOT NO_TBB)
|
|
|
|
message(WARNING
|
|
|
|
"TBB was not found : support for TBB parallel compute kernels "
|
|
|
|
"will be disabled in Osd. If your compiler supports TBB "
|
|
|
|
"directives, please refer to the FindTBB.cmake shared module "
|
|
|
|
"in your cmake installation.")
|
|
|
|
endif()
|
2013-08-15 23:11:33 +00:00
|
|
|
endif()
|
|
|
|
|
2016-07-26 19:41:18 +00:00
|
|
|
if( METAL_FOUND AND NOT NO_METAL)
|
|
|
|
set(OSD_GPU TRUE)
|
2019-03-09 19:32:18 +00:00
|
|
|
if (CMAKE_COMPILER_IS_CLANGCC)
|
|
|
|
# When building with Metal support enabled, we need to explicitly
|
|
|
|
# request that the C++ code be compiled with C++11 since some example
|
|
|
|
# code for Metal relies on functionality only available in C++11.
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
endif()
|
2016-07-26 19:41:18 +00:00
|
|
|
endif()
|
|
|
|
|
2015-07-16 05:55:14 +00:00
|
|
|
if( OPENGL_FOUND AND NOT NO_OPENGL)
|
|
|
|
set(OSD_GPU TRUE)
|
|
|
|
endif()
|
|
|
|
|
2013-01-31 23:34:35 +00:00
|
|
|
if(GLFW_FOUND AND (GLFW_VERSION VERSION_EQUAL 3.0 OR GLFW_VERSION VERSION_GREATER 3.0))
|
|
|
|
add_definitions( -DGLFW_VERSION_3 )
|
|
|
|
endif()
|
|
|
|
|
2020-03-03 23:04:24 +00:00
|
|
|
macro(osd_detect_gl_version header)
|
|
|
|
|
|
|
|
if (EXISTS "${header}")
|
|
|
|
file(STRINGS "${header}" VERSION_4_2 REGEX "^#define GL_VERSION_4_2.*$")
|
|
|
|
if (VERSION_4_2)
|
|
|
|
set(OPENGL_4_2_FOUND TRUE)
|
|
|
|
else ()
|
|
|
|
message(WARNING "OpenGL 4.2 dependent features not enabled")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
file(STRINGS "${header}" VERSION_4_3 REGEX "^#define GL_VERSION_4_3.*$")
|
|
|
|
if (VERSION_4_3)
|
|
|
|
SET(OPENGL_4_3_FOUND TRUE)
|
|
|
|
else ()
|
|
|
|
message(WARNING "OpenGL 4.3 dependent features not enabled")
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
if(GLEW_FOUND AND GLEW_INCLUDE_DIR)
|
|
|
|
|
|
|
|
osd_detect_gl_version(${GLEW_INCLUDE_DIR}/GL/glew.h)
|
2020-03-03 23:05:41 +00:00
|
|
|
set(OPENGL_LOADER_INCLUDE_DIRS
|
|
|
|
${GLEW_INCLUDE_DIR}
|
|
|
|
${PROJECT_SOURCE_DIR}/glLoader)
|
|
|
|
set(OPENGL_LOADER_LIBRARIES
|
|
|
|
${GLEW_LIBRARY}
|
2021-02-03 18:11:00 +00:00
|
|
|
${OPENGL_gl_LIBRARY}
|
|
|
|
${CMAKE_DL_LIBS})
|
2020-03-03 23:04:24 +00:00
|
|
|
|
2020-03-04 17:47:36 +00:00
|
|
|
elseif(OPENGL_FOUND)
|
2020-03-03 23:04:24 +00:00
|
|
|
|
2020-03-04 17:47:36 +00:00
|
|
|
osd_detect_gl_version(${PROJECT_SOURCE_DIR}/glLoader/glApi.h)
|
2020-03-03 23:05:41 +00:00
|
|
|
set(OPENGL_LOADER_INCLUDE_DIRS
|
|
|
|
${OPENGL_INCLUDE_DIR}
|
|
|
|
${PROJECT_SOURCE_DIR}/glLoader)
|
|
|
|
set(OPENGL_LOADER_LIBRARIES
|
2021-02-03 18:11:00 +00:00
|
|
|
${OPENGL_gl_LIBRARY}
|
|
|
|
${CMAKE_DL_LIBS})
|
2020-03-03 23:04:24 +00:00
|
|
|
|
|
|
|
endif()
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
# note : (GLSL transform feedback kernels require GL 4.2)
|
2020-03-03 23:05:41 +00:00
|
|
|
if(OPENGL_4_2_FOUND)
|
2012-08-04 02:51:27 +00:00
|
|
|
add_definitions(
|
2012-12-11 01:15:13 +00:00
|
|
|
-DOPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
|
2012-08-04 02:51:27 +00:00
|
|
|
)
|
|
|
|
else()
|
2014-09-05 22:07:46 +00:00
|
|
|
if (NOT NO_OPENGL)
|
|
|
|
message(WARNING
|
|
|
|
"OpenGL 4.2 was not found : support for GLSL transform feedback kernels "
|
|
|
|
"will be disabled in Osd. If you have an OpenGL SDK installed "
|
|
|
|
"(version 4.2 or above), please refer to the FindOpenGL.cmake "
|
|
|
|
"shared module in your cmake installation.")
|
|
|
|
endif()
|
2012-08-04 02:51:27 +00:00
|
|
|
endif()
|
|
|
|
|
2012-12-11 01:15:13 +00:00
|
|
|
# note : (GLSL compute shader kernels require GL 4.3)
|
2020-03-03 23:05:41 +00:00
|
|
|
if(OPENGL_4_3_FOUND)
|
2012-12-11 01:15:13 +00:00
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_GLSL_COMPUTE
|
|
|
|
)
|
|
|
|
else()
|
2014-09-05 22:07:46 +00:00
|
|
|
if (NOT NO_OPENGL)
|
|
|
|
message(WARNING
|
|
|
|
"OpenGL 4.3 was not found : support for GLSL compute shader kernels "
|
|
|
|
"will be disabled in Osd. If you have an OpenGL SDK installed "
|
|
|
|
"(version 4.3 or above), please refer to the FindOpenGL.cmake "
|
|
|
|
"shared module in your cmake installation.")
|
|
|
|
endif()
|
2012-12-11 01:15:13 +00:00
|
|
|
endif()
|
|
|
|
|
2012-12-20 18:25:41 +00:00
|
|
|
if(OPENGLES_FOUND)
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_OPENGLES
|
|
|
|
)
|
2015-07-16 05:55:14 +00:00
|
|
|
set(OSD_GPU TRUE)
|
2012-12-20 18:25:41 +00:00
|
|
|
endif()
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
if(OPENCL_FOUND)
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_OPENCL
|
|
|
|
)
|
2014-05-21 08:10:45 +00:00
|
|
|
if(CLEW_FOUND)
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_CLEW
|
|
|
|
)
|
|
|
|
set(OPENCL_INCLUDE_DIRS ${CLEW_INCLUDE_DIR})
|
2014-05-25 02:39:36 +00:00
|
|
|
set(OPENCL_LIBRARIES ${CLEW_LIBRARY} ${CMAKE_DL_LIBS})
|
2014-05-21 08:10:45 +00:00
|
|
|
else()
|
|
|
|
if (NOT NO_CLEW)
|
|
|
|
message(WARNING
|
2014-06-24 05:14:57 +00:00
|
|
|
"OpenCL was found, but CLEW was not. "
|
2014-09-05 22:07:46 +00:00
|
|
|
"Building with OpenCL support enabled, but the built binary "
|
|
|
|
"will not be portable to systems without OpenCL installed.")
|
2014-05-21 08:10:45 +00:00
|
|
|
endif()
|
|
|
|
endif()
|
2015-06-02 23:20:41 +00:00
|
|
|
|
|
|
|
if (DXSDK_FOUND AND NOT NO_DX)
|
|
|
|
if (OPENCL_CL_D3D11_H_FOUND)
|
|
|
|
set(OPENCL_D3D11_INTEROP_FOUND "YES")
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_OPENCL_DX_INTEROP
|
|
|
|
-DOPENSUBDIV_HAS_CL_D3D11_H
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
if (OPENCL_CL_D3D11_EXT_H_FOUND)
|
|
|
|
set(OPENCL_D3D11_INTEROP_FOUND "YES")
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_OPENCL_DX_INTEROP
|
|
|
|
-DOPENSUBDIV_HAS_CL_D3D11_EXT_H
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endif()
|
2015-07-16 05:55:14 +00:00
|
|
|
set(OSD_GPU TRUE)
|
2012-08-04 02:51:27 +00:00
|
|
|
else()
|
2014-05-20 21:36:45 +00:00
|
|
|
if (NOT NO_OPENCL)
|
2014-05-17 19:50:51 +00:00
|
|
|
message(WARNING
|
|
|
|
"OpenCL was not found : support for OpenCL parallel compute kernels "
|
|
|
|
"will be disabled in Osd. If you have the OpenCL SDK installed, "
|
|
|
|
"please refer to the FindOpenCL.cmake in ${PROJECT_SOURCE_DIR}/cmake.")
|
|
|
|
endif()
|
2012-08-04 02:51:27 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(CUDA_FOUND)
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_CUDA
|
2019-03-02 06:40:26 +00:00
|
|
|
-DCUDA_ENABLE_DEPRECATED=0
|
2012-08-04 02:51:27 +00:00
|
|
|
)
|
2015-07-16 05:55:14 +00:00
|
|
|
set(OSD_GPU TRUE)
|
2016-09-30 03:37:36 +00:00
|
|
|
|
|
|
|
if (UNIX)
|
|
|
|
list( APPEND CUDA_NVCC_FLAGS -Xcompiler -fPIC )
|
|
|
|
if (NOT DEFINED OSD_CUDA_NVCC_FLAGS)
|
|
|
|
if (CUDA_VERSION_MAJOR LESS 6)
|
|
|
|
set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_11 )
|
|
|
|
else()
|
|
|
|
set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_20 )
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (DEFINED OSD_CUDA_NVCC_FLAGS)
|
|
|
|
list( APPEND CUDA_NVCC_FLAGS ${OSD_CUDA_NVCC_FLAGS})
|
|
|
|
endif()
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
else()
|
2014-05-17 01:26:00 +00:00
|
|
|
if (NOT NO_CUDA)
|
|
|
|
message(WARNING
|
|
|
|
"CUDA was not found : support for CUDA parallel compute kernels "
|
|
|
|
"will be disabled in Osd. If you have the CUDA SDK installed, please "
|
|
|
|
"refer to the FindCUDA.cmake shared module in your cmake installation.")
|
|
|
|
endif()
|
2012-08-04 02:51:27 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(PTEX_FOUND)
|
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_PTEX
|
2016-02-20 00:58:56 +00:00
|
|
|
-DPTEX_STATIC
|
2012-08-04 02:51:27 +00:00
|
|
|
)
|
|
|
|
else()
|
2014-05-16 12:27:49 +00:00
|
|
|
if(NOT NO_PTEX)
|
|
|
|
message(WARNING
|
|
|
|
"Ptex was not found : the OpenSubdiv Ptex example will not be "
|
|
|
|
"available. If you do have Ptex installed and see this message, "
|
|
|
|
"please add your Ptex path to FindPTex.cmake in "
|
|
|
|
"${PROJECT_SOURCE_DIR}/cmake or set it through the PTEX_LOCATION "
|
|
|
|
"cmake command line argument or environment variable.")
|
|
|
|
endif()
|
2012-08-04 02:51:27 +00:00
|
|
|
endif()
|
|
|
|
|
2016-10-11 20:45:07 +00:00
|
|
|
if( OPENSUBDIV_GREGORY_EVAL_TRUE_DERIVATIVES )
|
|
|
|
add_definitions(-DOPENSUBDIV_GREGORY_EVAL_TRUE_DERIVATIVES)
|
|
|
|
endif()
|
|
|
|
|
2020-03-09 20:14:26 +00:00
|
|
|
# Link examples & regressions against Osd
|
|
|
|
if( BUILD_SHARED_LIBS )
|
|
|
|
if( OSD_GPU )
|
|
|
|
set( OSD_LINK_TARGET osd_dynamic_gpu osd_dynamic_cpu )
|
|
|
|
else()
|
|
|
|
set( OSD_LINK_TARGET osd_dynamic_cpu )
|
|
|
|
endif()
|
2015-07-16 05:55:14 +00:00
|
|
|
else()
|
2020-03-09 20:14:26 +00:00
|
|
|
if( OSD_GPU )
|
|
|
|
set( OSD_LINK_TARGET osd_static_gpu osd_static_cpu )
|
|
|
|
else()
|
|
|
|
set( OSD_LINK_TARGET osd_static_cpu )
|
|
|
|
endif()
|
2015-07-16 05:55:14 +00:00
|
|
|
endif()
|
2012-06-21 01:20:41 +00:00
|
|
|
|
|
|
|
if (WIN32)
|
2016-10-27 21:05:19 +00:00
|
|
|
if ("${GLEW_LIBRARY}" MATCHES "glew32s(d|)")
|
|
|
|
# Link against the static version of GLEW
|
|
|
|
add_definitions(
|
|
|
|
-DGLEW_STATIC
|
|
|
|
)
|
|
|
|
endif()
|
2012-12-11 01:15:13 +00:00
|
|
|
|
2015-01-25 12:24:38 +00:00
|
|
|
if (DXSDK_FOUND AND NOT NO_DX)
|
2012-12-11 01:15:13 +00:00
|
|
|
add_definitions(
|
|
|
|
-DOPENSUBDIV_HAS_DX11SDK
|
|
|
|
)
|
2015-07-16 05:55:14 +00:00
|
|
|
set(OSD_GPU TRUE)
|
2015-01-25 12:24:38 +00:00
|
|
|
elseif(NOT NO_DX)
|
2012-12-11 01:15:13 +00:00
|
|
|
message(WARNING
|
|
|
|
"DirectX11 SDK was not found. "
|
|
|
|
"If you do have DXSDK installed and see this message, "
|
|
|
|
"please add your sdk path to FindDirectX.cmake in "
|
|
|
|
"${PROJECT_SOURCE_DIR}/cmake or set it through the "
|
|
|
|
"DXSDK_LOCATION cmake command line argument or "
|
|
|
|
"environment variable."
|
|
|
|
)
|
|
|
|
endif()
|
2020-10-28 20:40:18 +00:00
|
|
|
|
2015-07-16 05:55:14 +00:00
|
|
|
# Link examples & regressions statically against Osd for
|
|
|
|
# Windows until all the kinks can be worked out.
|
|
|
|
if( OSD_GPU )
|
|
|
|
set( OSD_LINK_TARGET osd_static_cpu osd_static_gpu )
|
|
|
|
else()
|
|
|
|
set( OSD_LINK_TARGET osd_static_cpu )
|
|
|
|
endif()
|
2020-10-28 20:40:18 +00:00
|
|
|
|
2012-06-21 01:20:41 +00:00
|
|
|
endif()
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# General-use macros
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2013-07-05 22:36:54 +00:00
|
|
|
# Macro for processing public headers into the build area for doxygen processing
|
|
|
|
|
|
|
|
add_custom_target( public_headers )
|
|
|
|
|
2019-08-17 23:44:30 +00:00
|
|
|
macro(osd_add_doxy_headers headers)
|
2013-07-12 01:55:17 +00:00
|
|
|
if (NOT NO_DOC AND DOXYGEN_FOUND)
|
2016-07-09 05:45:33 +00:00
|
|
|
file(RELATIVE_PATH path "${OpenSubdiv_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" )
|
2013-07-05 22:36:54 +00:00
|
|
|
|
2013-07-09 17:00:40 +00:00
|
|
|
string(REPLACE "/" "_" targetpath ${path})
|
2013-07-05 22:36:54 +00:00
|
|
|
|
2013-07-09 17:00:40 +00:00
|
|
|
foreach (header ${headers})
|
2013-07-05 22:36:54 +00:00
|
|
|
|
2014-04-09 20:43:38 +00:00
|
|
|
set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${header}")
|
2016-07-09 05:45:33 +00:00
|
|
|
set(outfile "${OpenSubdiv_BINARY_DIR}/public_headers/${path}/${header}")
|
2013-07-09 17:00:40 +00:00
|
|
|
set(targetname "${targetpath}_${header}")
|
2013-07-05 22:36:54 +00:00
|
|
|
|
2013-07-09 17:00:40 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT
|
2014-04-09 20:43:38 +00:00
|
|
|
"${outfile}"
|
2013-07-09 17:00:40 +00:00
|
|
|
COMMAND
|
|
|
|
${CMAKE_COMMAND}
|
|
|
|
ARGS
|
|
|
|
-E copy ${infile} ${outfile}
|
|
|
|
DEPENDS
|
|
|
|
${infile}
|
|
|
|
)
|
2013-07-05 22:36:54 +00:00
|
|
|
|
2014-04-09 20:43:38 +00:00
|
|
|
add_custom_target(${targetname} DEPENDS "${outfile}")
|
2013-08-15 23:11:33 +00:00
|
|
|
|
2013-07-05 22:36:54 +00:00
|
|
|
|
2013-07-09 17:00:40 +00:00
|
|
|
list(APPEND headerfiles ${targetname} )
|
|
|
|
endforeach()
|
2013-07-05 22:36:54 +00:00
|
|
|
|
2013-07-09 17:00:40 +00:00
|
|
|
add_dependencies( public_headers DEPENDS ${headerfiles} )
|
|
|
|
endif()
|
2013-07-05 22:36:54 +00:00
|
|
|
endmacro()
|
|
|
|
|
2014-01-04 00:59:26 +00:00
|
|
|
# Kernel Stringification
|
|
|
|
# We want to use preprocessor include directives to include GLSL and OpenCL
|
|
|
|
# kernel source files in cpp files, but since the sources contain newline
|
|
|
|
# characters we would need raw string literals from C++11 to do this directly.
|
|
|
|
# To avoid depending on C++11 we instead use a small tool called "line_quote"
|
|
|
|
# to generate source files that are suitable for direct inclusion.
|
2019-08-17 23:44:30 +00:00
|
|
|
function(osd_stringify src_files varname)
|
2014-01-04 00:59:26 +00:00
|
|
|
|
|
|
|
set(inc_files "")
|
|
|
|
|
|
|
|
foreach(src_file ${src_files})
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
string(REGEX REPLACE ".*[.](.*)" "\\1" extension "${src_file}")
|
2014-01-04 00:59:26 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
string(REGEX REPLACE "(.*)[.].*" "\\1.gen.h" inc_file "${src_file}")
|
|
|
|
list(APPEND inc_files "${CMAKE_CURRENT_BINARY_DIR}/${inc_file}")
|
2014-01-04 00:59:26 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${inc_file}"
|
|
|
|
COMMAND
|
|
|
|
stringify "${CMAKE_CURRENT_SOURCE_DIR}/${src_file}" "${CMAKE_CURRENT_BINARY_DIR}/${inc_file}"
|
|
|
|
DEPENDS
|
|
|
|
stringify "${CMAKE_CURRENT_SOURCE_DIR}/${src_file}"
|
|
|
|
)
|
2014-01-04 00:59:26 +00:00
|
|
|
|
|
|
|
endforeach()
|
|
|
|
set(${varname} ${inc_files} PARENT_SCOPE)
|
|
|
|
endfunction()
|
2013-07-05 22:36:54 +00:00
|
|
|
|
2013-09-17 01:16:28 +00:00
|
|
|
# Macro wrapper for adding a non-cuda dependent executable
|
2019-08-17 23:44:30 +00:00
|
|
|
macro(osd_add_executable target folder)
|
2013-09-17 01:16:28 +00:00
|
|
|
|
|
|
|
add_executable(${target} ${ARGN})
|
|
|
|
|
2016-06-10 00:04:26 +00:00
|
|
|
set_target_properties(${target} PROPERTIES FOLDER ${folder})
|
|
|
|
|
2013-09-17 01:16:28 +00:00
|
|
|
if(CMAKE_COMPILER_IS_ICC)
|
|
|
|
target_link_libraries(${target} ${ICC_LIBRARIES})
|
|
|
|
endif()
|
2016-07-26 19:41:18 +00:00
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
set_property (TARGET ${target} APPEND_STRING PROPERTY
|
|
|
|
COMPILE_FLAGS " -fobjc-arc ")
|
|
|
|
endif()
|
2013-09-17 01:16:28 +00:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
2012-06-11 02:59:04 +00:00
|
|
|
# Macro for adding a cuda executable if cuda is found and a regular
|
|
|
|
# executable otherwise.
|
2019-08-17 23:44:30 +00:00
|
|
|
macro(osd_add_possibly_cuda_executable target folder)
|
2012-06-11 02:59:04 +00:00
|
|
|
if(CUDA_FOUND)
|
|
|
|
cuda_add_executable(${target} ${ARGN})
|
|
|
|
else()
|
|
|
|
add_executable(${target} ${ARGN})
|
|
|
|
endif()
|
2013-08-15 23:11:33 +00:00
|
|
|
|
2016-06-10 00:04:26 +00:00
|
|
|
set_target_properties(${target} PROPERTIES FOLDER ${folder})
|
|
|
|
|
2013-08-15 22:21:00 +00:00
|
|
|
if(CMAKE_COMPILER_IS_ICC)
|
2014-05-17 01:26:00 +00:00
|
|
|
target_link_libraries(${target} ${ICC_LIBRARIES})
|
2013-08-15 22:21:00 +00:00
|
|
|
endif()
|
2016-07-26 19:41:18 +00:00
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
set_property (TARGET ${target} APPEND_STRING PROPERTY
|
|
|
|
COMPILE_FLAGS " -fobjc-arc ")
|
|
|
|
endif()
|
2012-06-11 02:59:04 +00:00
|
|
|
endmacro()
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2012-06-11 02:59:04 +00:00
|
|
|
# Macro for adding a cuda library if cuda is found and a regular
|
|
|
|
# library otherwise.
|
2019-08-17 23:44:30 +00:00
|
|
|
macro(osd_add_possibly_cuda_library target folder)
|
2012-06-11 02:59:04 +00:00
|
|
|
if(CUDA_FOUND)
|
|
|
|
cuda_add_library(${target} ${ARGN})
|
|
|
|
else()
|
|
|
|
add_library(${target} ${ARGN})
|
|
|
|
endif()
|
2016-06-10 00:04:26 +00:00
|
|
|
set_target_properties(${target} PROPERTIES FOLDER ${folder})
|
2016-07-26 19:41:18 +00:00
|
|
|
|
|
|
|
if(APPLE)
|
|
|
|
set_property (TARGET ${target} APPEND_STRING PROPERTY
|
|
|
|
COMPILE_FLAGS " -fobjc-arc ")
|
|
|
|
endif()
|
2012-06-11 02:59:04 +00:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
|
2013-09-17 01:16:28 +00:00
|
|
|
# Macro for adding a (potentially cuda) GLFW executable.
|
2019-08-17 23:44:30 +00:00
|
|
|
macro(osd_add_glfw_executable target folder)
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2019-08-17 23:44:30 +00:00
|
|
|
osd_add_possibly_cuda_executable(${target} ${folder} ${ARGN})
|
2012-08-04 02:51:27 +00:00
|
|
|
|
2016-07-26 19:41:18 +00:00
|
|
|
if(APPLE)
|
|
|
|
set_property (TARGET ${target} APPEND_STRING PROPERTY
|
|
|
|
COMPILE_FLAGS " -fobjc-arc ")
|
|
|
|
endif()
|
|
|
|
|
2012-08-04 02:51:27 +00:00
|
|
|
endmacro()
|
|
|
|
|
2013-01-24 21:40:43 +00:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Build targets
|
2012-06-11 02:59:04 +00:00
|
|
|
|
2015-05-29 00:32:00 +00:00
|
|
|
|
|
|
|
# if you want to build examples against installed OpenSubdiv header files,
|
|
|
|
# use OPENSUBDIV_INCLUDE_DIR.
|
|
|
|
|
|
|
|
# example: if you have already installed opensubdiv libs in this cmake setup,
|
|
|
|
# set (OPENSUBDIV_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INCDIR_BASE})
|
|
|
|
|
|
|
|
if (NOT OPENSUBDIV_INCLUDE_DIR)
|
2018-10-09 17:51:31 +00:00
|
|
|
set(OPENSUBDIV_INCLUDE_DIR "${PROJECT_SOURCE_DIR}")
|
2015-05-29 00:32:00 +00:00
|
|
|
endif()
|
|
|
|
|
2015-04-28 21:44:07 +00:00
|
|
|
if (NOT NO_TESTS)
|
2015-04-16 17:52:08 +00:00
|
|
|
enable_testing()
|
|
|
|
endif()
|
|
|
|
|
2020-03-03 23:05:41 +00:00
|
|
|
if (NOT NO_OPENGL)
|
|
|
|
add_subdirectory(glLoader)
|
|
|
|
endif()
|
|
|
|
|
2012-06-08 18:18:20 +00:00
|
|
|
add_subdirectory(opensubdiv)
|
|
|
|
|
2016-07-26 19:41:18 +00:00
|
|
|
if (NOT ANDROID) # XXXdyu
|
2012-12-20 18:25:41 +00:00
|
|
|
add_subdirectory(regression)
|
|
|
|
endif()
|
2012-06-09 00:06:35 +00:00
|
|
|
|
2013-07-05 22:36:54 +00:00
|
|
|
if (NOT NO_EXAMPLES)
|
|
|
|
add_subdirectory(examples)
|
|
|
|
endif()
|
2012-10-07 00:53:51 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
if (NOT NO_TUTORIALS)
|
|
|
|
add_subdirectory(tutorials)
|
2013-07-12 01:55:17 +00:00
|
|
|
endif()
|
|
|
|
|
2013-07-09 17:00:40 +00:00
|
|
|
if (NOT NO_DOC)
|
|
|
|
add_subdirectory(documentation)
|
|
|
|
endif()
|