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
|
|
|
#
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
if (NOT NO_LIB)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
include_directories(
|
|
|
|
"${PROJECT_SOURCE_DIR}/opensubdiv"
|
|
|
|
)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
# platform dependent tweaks
|
|
|
|
if(APPLE OR UNIX)
|
|
|
|
set(PLATFORM_COMPILE_FLAGS -fPIC)
|
|
|
|
elseif(WIN32)
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_definitions(
|
|
|
|
${PLATFORM_COMPILE_FLAGS}
|
|
|
|
)
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
if( OPENMP_FOUND )
|
|
|
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
list(APPEND PLATFORM_CPU_LIBRARIES gomp)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if( TBB_FOUND )
|
|
|
|
include_directories("${TBB_INCLUDE_DIR}")
|
|
|
|
list(APPEND PLATFORM_CPU_LIBRARIES
|
|
|
|
${TBB_LIBRARIES}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2016-07-26 19:41:18 +00:00
|
|
|
if(OPENGL_FOUND OR OPENCL_FOUND OR DXSDK_FOUND OR METAL_FOUND)
|
2014-09-05 22:07:46 +00:00
|
|
|
add_subdirectory(tools/stringify)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if( OPENGL_FOUND )
|
2020-03-03 23:05:41 +00:00
|
|
|
include_directories(${OPENGL_LOADER_INCLUDE_DIRS})
|
2014-09-05 22:07:46 +00:00
|
|
|
list(APPEND PLATFORM_GPU_LIBRARIES
|
2020-03-03 23:05:41 +00:00
|
|
|
${OPENGL_LOADER_LIBRARIES}
|
2014-09-05 22:07:46 +00:00
|
|
|
)
|
2020-04-01 04:43:26 +00:00
|
|
|
set(OPENGL_LOADER_OBJS $<TARGET_OBJECTS:glLoader_obj>)
|
2014-09-05 22:07:46 +00:00
|
|
|
elseif( OPENGLES_FOUND )
|
|
|
|
include_directories("${OPENGLES_INCLUDE_DIR}")
|
|
|
|
list(APPEND PLATFORM_GPU_LIBRARIES
|
|
|
|
${OPENGLES_LIBRARIES}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if( DXSDK_FOUND )
|
|
|
|
include_directories( "${DXSDK_INCLUDE_DIR}" )
|
|
|
|
list(APPEND PLATFORM_GPU_LIBRARIES
|
|
|
|
${DXSDK_LIBRARIES}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2016-07-26 19:41:18 +00:00
|
|
|
if( METAL_FOUND )
|
|
|
|
include_directories( "${METAL_INCLUDE_DIR}" )
|
|
|
|
list(APPEND PLATFORM_GPU_LIBRARIES
|
|
|
|
${METAL_LIBRARIES}
|
|
|
|
)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
|
|
|
endif()
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
if ( OPENCL_FOUND )
|
|
|
|
include_directories( "${OPENCL_INCLUDE_DIRS}" )
|
|
|
|
list(APPEND PLATFORM_GPU_LIBRARIES
|
|
|
|
${OPENCL_LIBRARIES}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if( CUDA_FOUND )
|
|
|
|
include_directories( "${CUDA_INCLUDE_DIRS}" )
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
add_subdirectory(hbr)
|
|
|
|
|
|
|
|
add_subdirectory(sdc)
|
|
|
|
|
|
|
|
add_subdirectory(vtr)
|
|
|
|
|
|
|
|
add_subdirectory(far)
|
2012-06-09 20:40:48 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
add_subdirectory(osd)
|
2012-06-21 01:20:41 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
#---------------------------------------------------------------------------
|
2012-06-08 18:18:20 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
install( FILES version.h
|
|
|
|
DESTINATION
|
|
|
|
"${CMAKE_INCDIR_BASE}"
|
|
|
|
PERMISSIONS
|
|
|
|
OWNER_READ
|
|
|
|
GROUP_READ
|
|
|
|
WORLD_READ )
|
2012-06-09 20:40:48 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
#---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Build static libs ------------------------------------
|
|
|
|
add_library(osd_static_cpu
|
|
|
|
STATIC
|
2014-11-25 20:37:03 +00:00
|
|
|
version.cpp
|
2014-09-05 22:07:46 +00:00
|
|
|
$<TARGET_OBJECTS:sdc_obj>
|
|
|
|
$<TARGET_OBJECTS:vtr_obj>
|
|
|
|
$<TARGET_OBJECTS:far_obj>
|
|
|
|
$<TARGET_OBJECTS:osd_cpu_obj>
|
|
|
|
)
|
2016-07-26 19:41:18 +00:00
|
|
|
|
2020-03-09 20:14:26 +00:00
|
|
|
set_target_properties(osd_static_cpu
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME osdCPU
|
2016-06-10 00:04:26 +00:00
|
|
|
CLEAN_DIRECT_OUTPUT 1
|
|
|
|
FOLDER "opensubdiv"
|
|
|
|
)
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
target_link_libraries(osd_static_cpu
|
|
|
|
${PLATFORM_CPU_LIBRARIES}
|
|
|
|
)
|
|
|
|
|
|
|
|
install( TARGETS osd_static_cpu DESTINATION "${CMAKE_LIBDIR_BASE}" )
|
|
|
|
|
2015-07-16 05:55:14 +00:00
|
|
|
if( OSD_GPU )
|
|
|
|
# this macro uses FindCUDA.cmake to compile .cu kernel files
|
|
|
|
# the target then adds the other obj dependencies and include files
|
2019-08-17 23:44:30 +00:00
|
|
|
osd_add_possibly_cuda_library(osd_static_gpu "opensubdiv"
|
2016-07-26 19:41:18 +00:00
|
|
|
STATIC
|
2015-07-16 05:55:14 +00:00
|
|
|
version.cpp
|
|
|
|
$<TARGET_OBJECTS:osd_gpu_obj>
|
2020-04-01 04:43:26 +00:00
|
|
|
${OPENGL_LOADER_OBJS}
|
2015-07-16 05:55:14 +00:00
|
|
|
${CUDA_KERNEL_FILES}
|
|
|
|
)
|
|
|
|
set_target_properties(osd_static_gpu PROPERTIES OUTPUT_NAME osdGPU CLEAN_DIRECT_OUTPUT 1)
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-07-16 05:55:14 +00:00
|
|
|
target_link_libraries(osd_static_gpu
|
|
|
|
${PLATFORM_CPU_LIBRARIES} ${PLATFORM_GPU_LIBRARIES}
|
|
|
|
)
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-07-16 05:55:14 +00:00
|
|
|
install( TARGETS osd_static_gpu DESTINATION "${CMAKE_LIBDIR_BASE}" )
|
|
|
|
endif()
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Build dynamic libs ----------------------------------
|
2020-03-09 20:14:26 +00:00
|
|
|
if (BUILD_SHARED_LIBS AND NOT WIN32 AND NOT IOS)
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
# generate dynamic-link targets
|
|
|
|
|
|
|
|
#---------------------------------------------------
|
|
|
|
add_library(osd_dynamic_cpu
|
|
|
|
SHARED
|
2014-11-25 20:37:03 +00:00
|
|
|
version.cpp
|
2014-09-05 22:07:46 +00:00
|
|
|
$<TARGET_OBJECTS:sdc_obj>
|
|
|
|
$<TARGET_OBJECTS:vtr_obj>
|
|
|
|
$<TARGET_OBJECTS:far_obj>
|
|
|
|
$<TARGET_OBJECTS:osd_cpu_obj>
|
|
|
|
)
|
|
|
|
|
2014-09-11 06:21:23 +00:00
|
|
|
if (NOT ANDROID)
|
|
|
|
set_target_properties(osd_dynamic_cpu
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME osdCPU
|
|
|
|
CLEAN_DIRECT_OUTPUT 1
|
|
|
|
SOVERSION ${OSD_SONAME}
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set_target_properties(osd_dynamic_cpu
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME osdCPU
|
|
|
|
CLEAN_DIRECT_OUTPUT 1
|
|
|
|
)
|
|
|
|
endif()
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
target_link_libraries(osd_dynamic_cpu
|
|
|
|
${PLATFORM_CPU_LIBRARIES}
|
|
|
|
)
|
|
|
|
|
|
|
|
install( TARGETS osd_dynamic_cpu LIBRARY DESTINATION "${CMAKE_LIBDIR_BASE}" )
|
|
|
|
|
|
|
|
#---------------------------------------------------
|
2015-07-16 05:55:14 +00:00
|
|
|
if( OSD_GPU )
|
2019-08-17 23:44:30 +00:00
|
|
|
osd_add_possibly_cuda_library(osd_dynamic_gpu "opensubdiv"
|
2015-07-16 05:55:14 +00:00
|
|
|
SHARED
|
|
|
|
version.cpp
|
|
|
|
$<TARGET_OBJECTS:osd_gpu_obj>
|
|
|
|
${CUDA_KERNEL_FILES}
|
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT ANDROID)
|
|
|
|
set_target_properties(osd_dynamic_gpu
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME osdGPU
|
|
|
|
CLEAN_DIRECT_OUTPUT 1
|
|
|
|
SOVERSION ${OSD_SONAME}
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set_target_properties(osd_dynamic_gpu
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME osdGPU
|
|
|
|
CLEAN_DIRECT_OUTPUT 1
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
target_link_libraries(osd_dynamic_gpu
|
|
|
|
osd_dynamic_cpu
|
|
|
|
${PLATFORM_CPU_LIBRARIES} ${PLATFORM_GPU_LIBRARIES}
|
|
|
|
)
|
|
|
|
|
|
|
|
install( TARGETS osd_dynamic_gpu LIBRARY DESTINATION "${CMAKE_LIBDIR_BASE}" )
|
2014-09-11 06:21:23 +00:00
|
|
|
endif()
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
endif()
|
|
|
|
|
2016-07-26 19:41:18 +00:00
|
|
|
# Build frameworks ----------------------------------
|
|
|
|
if(APPLE)
|
|
|
|
get_directory_property(OSD_HEADER_FILES DIRECTORY ${CMAKE_SOURCE_DIR}/opensubdiv/osd DEFINITION PUBLIC_HEADER_FILES)
|
|
|
|
get_directory_property(FAR_HEADER_FILES DIRECTORY ${CMAKE_SOURCE_DIR}/opensubdiv/far DEFINITION PUBLIC_HEADER_FILES)
|
|
|
|
get_directory_property(SDC_HEADER_FILES DIRECTORY ${CMAKE_SOURCE_DIR}/opensubdiv/sdc DEFINITION PUBLIC_HEADER_FILES)
|
|
|
|
get_directory_property(HBR_HEADER_FILES DIRECTORY ${CMAKE_SOURCE_DIR}/opensubdiv/hbr DEFINITION PUBLIC_HEADER_FILES)
|
|
|
|
get_directory_property(VTR_HEADER_FILES DIRECTORY ${CMAKE_SOURCE_DIR}/opensubdiv/vtr DEFINITION PUBLIC_HEADER_FILES)
|
|
|
|
|
|
|
|
|
|
|
|
foreach(file ${OSD_HEADER_FILES})
|
|
|
|
list(APPEND PUBLIC_HEADER_FILES "osd/${file}")
|
|
|
|
endforeach(file)
|
|
|
|
|
|
|
|
foreach(file ${FAR_HEADER_FILES})
|
|
|
|
list(APPEND PUBLIC_HEADER_FILES "far/${file}")
|
|
|
|
endforeach(file)
|
|
|
|
|
|
|
|
foreach(file ${SDC_HEADER_FILES})
|
|
|
|
list(APPEND PUBLIC_HEADER_FILES "sdc/${file}")
|
|
|
|
endforeach(file)
|
|
|
|
|
|
|
|
foreach(file ${HBR_HEADER_FILES})
|
|
|
|
list(APPEND PUBLIC_HEADER_FILES "hbr/${file}")
|
|
|
|
endforeach(file)
|
|
|
|
|
|
|
|
foreach(file ${VTR_HEADER_FILES})
|
|
|
|
list(APPEND PUBLIC_HEADER_FILES "vtr/${file}")
|
|
|
|
endforeach(file)
|
|
|
|
|
|
|
|
list(APPEND PUBLIC_HEADER_FILES "version.h")
|
|
|
|
|
|
|
|
#static framework
|
|
|
|
add_library(osd_static_framework
|
|
|
|
STATIC
|
|
|
|
version.cpp
|
|
|
|
$<TARGET_OBJECTS:sdc_obj>
|
|
|
|
$<TARGET_OBJECTS:vtr_obj>
|
|
|
|
$<TARGET_OBJECTS:far_obj>
|
|
|
|
$<TARGET_OBJECTS:osd_cpu_obj>
|
|
|
|
$<TARGET_OBJECTS:osd_gpu_obj>
|
|
|
|
)
|
|
|
|
|
|
|
|
set_target_properties(
|
|
|
|
osd_static_framework
|
|
|
|
PROPERTIES
|
|
|
|
FRAMEWORK true
|
|
|
|
INSTALL_NAME_DIR "@rpath/OpenSubdiv.framework/OpenSubdiv"
|
|
|
|
INSTALL_RPATH "@executable_path/Frameworks;@loader_path/Frameworks"
|
|
|
|
OUTPUT_NAME OpenSubdiv
|
|
|
|
CLEAN_DIRECT_OUTPUT true
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(osd_static_framework
|
|
|
|
${PLATFORM_CPU_LIBRARIES} ${PLATFORM_GPU_LIBRARIES}
|
|
|
|
)
|
|
|
|
|
|
|
|
install( TARGETS osd_static_framework
|
|
|
|
LIBRARY DESTINATION "${CMAKE_LIBDIR_BASE}"
|
|
|
|
FRAMEWORK DESTINATION "${CMAKE_LIBDIR_BASE}"
|
|
|
|
PUBLIC_HEADER DESTINATION "${CMAKE_INCDIR_BASE}"
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_LIBDIR_BASE}")
|
|
|
|
|
|
|
|
|
2020-03-09 20:14:26 +00:00
|
|
|
#shared framework
|
|
|
|
if (BUILD_SHARED_LIBS)
|
|
|
|
add_library(osd_dynamic_framework
|
|
|
|
SHARED
|
|
|
|
version.cpp
|
|
|
|
$<TARGET_OBJECTS:sdc_obj>
|
|
|
|
$<TARGET_OBJECTS:vtr_obj>
|
|
|
|
$<TARGET_OBJECTS:far_obj>
|
|
|
|
$<TARGET_OBJECTS:osd_cpu_obj>
|
|
|
|
$<TARGET_OBJECTS:osd_gpu_obj>
|
|
|
|
)
|
2016-07-26 19:41:18 +00:00
|
|
|
|
2020-03-09 20:14:26 +00:00
|
|
|
set_target_properties(
|
|
|
|
osd_dynamic_framework
|
|
|
|
PROPERTIES
|
|
|
|
RPATH true
|
|
|
|
FRAMEWORK true
|
|
|
|
INSTALL_NAME_DIR "@rpath/OpenSubdiv.framework/OpenSubdiv"
|
|
|
|
INSTALL_RPATH "@executable_path/Frameworks;@loader_path/Frameworks"
|
|
|
|
OUTPUT_NAME OpenSubdiv
|
|
|
|
CLEAN_DIRECT_OUTPUT true
|
|
|
|
)
|
2016-07-26 19:41:18 +00:00
|
|
|
|
2020-03-09 20:14:26 +00:00
|
|
|
target_link_libraries(osd_dynamic_framework
|
|
|
|
${PLATFORM_CPU_LIBRARIES} ${PLATFORM_GPU_LIBRARIES}
|
|
|
|
)
|
2016-07-26 19:41:18 +00:00
|
|
|
|
2020-03-09 20:14:26 +00:00
|
|
|
install( TARGETS osd_dynamic_framework
|
|
|
|
FRAMEWORK DESTINATION "${CMAKE_LIBDIR_BASE}"
|
|
|
|
LIBRARY DESTINATION "${CMAKE_LIBDIR_BASE}"
|
|
|
|
PUBLIC_HEADER DESTINATION "${CMAKE_INCDIR_BASE}"
|
|
|
|
PRIVATE_HEADER DESTINATION "${CMAKE_INCDIR_BASE}"
|
|
|
|
)
|
|
|
|
|
|
|
|
foreach(file ${PUBLIC_HEADER_FILES})
|
|
|
|
add_custom_command(TARGET osd_dynamic_framework POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy
|
|
|
|
"${CMAKE_SOURCE_DIR}/opensubdiv/${file}"
|
|
|
|
"$<TARGET_FILE_DIR:osd_dynamic_framework>/Headers/${file}"
|
|
|
|
)
|
|
|
|
endforeach(file)
|
2016-07-26 19:41:18 +00:00
|
|
|
|
|
|
|
add_custom_command(TARGET osd_dynamic_framework POST_BUILD
|
2020-03-09 20:14:26 +00:00
|
|
|
COMMAND ln -sf
|
|
|
|
"Versions/Current/Headers"
|
|
|
|
"$<TARGET_FILE_DIR:osd_dynamic_framework>/../../Headers"
|
2016-07-26 19:41:18 +00:00
|
|
|
)
|
2020-03-09 20:14:26 +00:00
|
|
|
endif()
|
2016-07-26 19:41:18 +00:00
|
|
|
|
|
|
|
endif()
|
2014-09-05 22:07:46 +00:00
|
|
|
endif()
|
2013-05-10 02:18:05 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
#-------------------------------------------------------------------------------
|