OpenSubdiv/opensubdiv/CMakeLists.txt

224 lines
6.4 KiB
CMake
Raw Normal View History

2012-06-08 18:18:20 +00:00
#
# Copyright 2013 Pixar
2012-06-08 18:18:20 +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
#
# 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
#
# You may obtain a copy of the Apache License at
2012-06-08 18:18:20 +00:00
#
# http://www.apache.org/licenses/LICENSE-2.0
2013-07-18 21:19:50 +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
#
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( PTEX_FOUND )
include_directories( "${PTEX_INCLUDE_DIR}" )
list(APPEND PLATFORM_CPU_LIBRARIES
${PTEX_LIBRARY}
)
endif()
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()
if(OPENGL_FOUND OR OPENCL_FOUND OR DXSDK_FOUND)
add_subdirectory(tools/stringify)
endif()
if( OPENGL_FOUND )
if (NOT "${OPENGL_INCLUDE_DIR}" STREQUAL "")
include_directories("${OPENGL_INCLUDE_DIR}")
endif()
if (GLEW_FOUND)
include_directories("${GLEW_INCLUDE_DIR}")
endif()
list(APPEND PLATFORM_GPU_LIBRARIES
${OPENGL_LIBRARY}
)
elseif( OPENGLES_FOUND )
include_directories("${OPENGLES_INCLUDE_DIR}")
list(APPEND PLATFORM_GPU_LIBRARIES
${OPENGLES_LIBRARIES}
)
endif()
if( OPENGL_4_2_FOUND OR OPENGL_4_3_FOUND)
list(APPEND PLATFORM_GPU_LIBRARIES
${GLEW_LIBRARY}
)
endif()
if( DXSDK_FOUND )
include_directories( "${DXSDK_INCLUDE_DIR}" )
list(APPEND PLATFORM_GPU_LIBRARIES
${DXSDK_LIBRARIES}
)
endif()
if ( OPENCL_FOUND )
include_directories( "${OPENCL_INCLUDE_DIRS}" )
list(APPEND PLATFORM_GPU_LIBRARIES
${OPENCL_LIBRARIES}
)
endif()
if( CUDA_FOUND )
include_directories( "${CUDA_INCLUDE_DIRS}" )
if (UNIX)
list( APPEND CUDA_NVCC_FLAGS -Xcompiler -fPIC --gpu-architecture compute_11 )
endif()
endif()
#---------------------------------------------------------------------------
add_subdirectory(hbr)
add_subdirectory(sdc)
add_subdirectory(vtr)
add_subdirectory(far)
add_subdirectory(osd)
#---------------------------------------------------------------------------
2012-06-08 18:18:20 +00:00
install( FILES version.h
DESTINATION
"${CMAKE_INCDIR_BASE}"
PERMISSIONS
OWNER_READ
GROUP_READ
WORLD_READ )
#---------------------------------------------------------------------------
# Build static libs ------------------------------------
add_library(osd_static_cpu
STATIC
$<TARGET_OBJECTS:sdc_obj>
$<TARGET_OBJECTS:vtr_obj>
$<TARGET_OBJECTS:far_obj>
$<TARGET_OBJECTS:osd_cpu_obj>
)
set_target_properties(osd_static_cpu PROPERTIES OUTPUT_NAME osdCPU CLEAN_DIRECT_OUTPUT 1)
target_link_libraries(osd_static_cpu
${PLATFORM_CPU_LIBRARIES}
)
install( TARGETS osd_static_cpu DESTINATION "${CMAKE_LIBDIR_BASE}" )
# this macro uses FindCUDA.cmake to compile .cu kernel files
# the target then adds the other obj dependencies and include files
_add_possibly_cuda_library(osd_static_gpu
STATIC
$<TARGET_OBJECTS:osd_gpu_obj>
${CUDA_KERNEL_FILES}
)
set_target_properties(osd_static_gpu PROPERTIES OUTPUT_NAME osdGPU CLEAN_DIRECT_OUTPUT 1)
target_link_libraries(osd_static_gpu
${PLATFORM_CPU_LIBRARIES} ${PLATFORM_GPU_LIBRARIES}
)
install( TARGETS osd_static_gpu DESTINATION "${CMAKE_LIBDIR_BASE}" )
# Build dynamic libs ----------------------------------
if (NOT WIN32 AND NOT IOS)
# generate dynamic-link targets
#---------------------------------------------------
add_library(osd_dynamic_cpu
SHARED
$<TARGET_OBJECTS:sdc_obj>
$<TARGET_OBJECTS:vtr_obj>
$<TARGET_OBJECTS:far_obj>
$<TARGET_OBJECTS:osd_cpu_obj>
)
set_target_properties(osd_dynamic_cpu
PROPERTIES
OUTPUT_NAME osdCPU
CLEAN_DIRECT_OUTPUT 1
SOVERSION ${OSD_SONAME}
)
target_link_libraries(osd_dynamic_cpu
${PLATFORM_CPU_LIBRARIES}
)
install( TARGETS osd_dynamic_cpu LIBRARY DESTINATION "${CMAKE_LIBDIR_BASE}" )
#---------------------------------------------------
_add_possibly_cuda_library(osd_dynamic_gpu
SHARED
$<TARGET_OBJECTS:osd_gpu_obj>
${CUDA_KERNEL_FILES}
)
set_target_properties(osd_dynamic_gpu
PROPERTIES
OUTPUT_NAME osdGPU
CLEAN_DIRECT_OUTPUT 1
SOVERSION ${OSD_SONAME}
)
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}" )
endif()
endif()
2013-05-10 02:18:05 +00:00
#-------------------------------------------------------------------------------