mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-09-19 22:30:05 +00:00
Remove CMake compiling redundancies
- set OBJECT targets for osd cpu & gpu libs, and use the obj target for static and dynamic linking - add a new examples_common_obj OBJECT target - replace direct source dependencies to obj target in all examples CMakeLists This change makes it possible to not re-compile the same source files multiple times when they are used in multiple targets. Thanks to jcowles for uncovering the CMake functionality. Note: it seems that multi-process build is working again (gmake -j <x>)
This commit is contained in:
parent
e8a25c511a
commit
00b0d95058
@ -23,23 +23,31 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
if( OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND))
|
if( OPENGL_FOUND AND (GLEW_FOUND AND GLFW_FOUND) OR (APPLE AND GLFW_FOUND))
|
||||||
|
|
||||||
|
add_subdirectory(common)
|
||||||
|
|
||||||
add_subdirectory(glViewer)
|
add_subdirectory(glViewer)
|
||||||
add_subdirectory(glBatchViewer)
|
add_subdirectory(glBatchViewer)
|
||||||
add_subdirectory(glStencilViewer)
|
add_subdirectory(glStencilViewer)
|
||||||
add_subdirectory(simpleCpu)
|
add_subdirectory(simpleCpu)
|
||||||
add_subdirectory(limitEval)
|
add_subdirectory(limitEval)
|
||||||
add_subdirectory(tessellateObjFile)
|
add_subdirectory(tessellateObjFile)
|
||||||
|
|
||||||
if (NOT APPLE)
|
if (NOT APPLE)
|
||||||
add_subdirectory(uvViewer)
|
add_subdirectory(uvViewer)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(OPENGL_4_3_FOUND AND (NOT APPLE))
|
if(OPENGL_4_3_FOUND AND (NOT APPLE))
|
||||||
# the paintTest example requires GL functionality not available on OSX
|
# the paintTest example requires GL functionality not available on OSX
|
||||||
add_subdirectory(paintTest)
|
add_subdirectory(paintTest)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PTEX_FOUND)
|
if(PTEX_FOUND)
|
||||||
add_subdirectory(ptexViewer)
|
add_subdirectory(ptexViewer)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
set(MISSING "")
|
set(MISSING "")
|
||||||
|
|
||||||
if (NOT OPENGL_FOUND)
|
if (NOT OPENGL_FOUND)
|
||||||
@ -70,6 +78,7 @@ if(DXSDK_FOUND)
|
|||||||
if(PTEX_FOUND)
|
if(PTEX_FOUND)
|
||||||
add_subdirectory(dxPtexViewer)
|
add_subdirectory(dxPtexViewer)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
@ -79,8 +88,7 @@ if(MAYA_FOUND)
|
|||||||
# manuelk: the following plugins are disabled until further notice
|
# manuelk: the following plugins are disabled until further notice
|
||||||
|
|
||||||
#add_subdirectory(mayaViewer)
|
#add_subdirectory(mayaViewer)
|
||||||
|
#if(PTEX_FOUND)
|
||||||
if(PTEX_FOUND)
|
|
||||||
#add_subdirectory(mayaPtexViewer)
|
#add_subdirectory(mayaPtexViewer)
|
||||||
endif()
|
#endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -42,9 +42,6 @@ include_directories(
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
../common/font_image.cpp
|
|
||||||
../common/hud.cpp
|
|
||||||
../common/d3d11_hud.cpp
|
|
||||||
dxPtexViewer.cpp
|
dxPtexViewer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -74,6 +71,7 @@ _add_possibly_cuda_executable(dxPtexViewer WIN32
|
|||||||
${SOURCE_FILES}
|
${SOURCE_FILES}
|
||||||
${SHADER_FILES}
|
${SHADER_FILES}
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
|
$<TARGET_OBJECTS:examples_common_obj>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(dxPtexViewer
|
target_link_libraries(dxPtexViewer
|
||||||
|
@ -40,9 +40,6 @@ include_directories(
|
|||||||
)
|
)
|
||||||
|
|
||||||
set(SOURCE_FILES
|
set(SOURCE_FILES
|
||||||
../common/font_image.cpp
|
|
||||||
../common/hud.cpp
|
|
||||||
../common/d3d11_hud.cpp
|
|
||||||
dxViewer.cpp
|
dxViewer.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -72,6 +69,7 @@ _add_possibly_cuda_executable(dxViewer WIN32
|
|||||||
${SOURCE_FILES}
|
${SOURCE_FILES}
|
||||||
${SHADER_FILES}
|
${SHADER_FILES}
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
|
$<TARGET_OBJECTS:examples_common_obj>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(dxViewer
|
target_link_libraries(dxViewer
|
||||||
|
@ -73,12 +73,9 @@ _add_glfw_executable(glBatchViewer
|
|||||||
delegate.cpp
|
delegate.cpp
|
||||||
effect.cpp
|
effect.cpp
|
||||||
effectRegistry.cpp
|
effectRegistry.cpp
|
||||||
../common/font_image.cpp
|
|
||||||
../common/hud.cpp
|
|
||||||
../common/patchColors.cpp
|
|
||||||
../common/gl_hud.cpp
|
|
||||||
${SHADER_FILES}
|
${SHADER_FILES}
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
|
$<TARGET_OBJECTS:examples_common_obj>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(glBatchViewer
|
target_link_libraries(glBatchViewer
|
||||||
|
@ -42,10 +42,8 @@ endif()
|
|||||||
|
|
||||||
_add_glfw_executable(glStencilViewer
|
_add_glfw_executable(glStencilViewer
|
||||||
main.cpp
|
main.cpp
|
||||||
../common/font_image.cpp
|
|
||||||
../common/hud.cpp
|
|
||||||
../common/gl_hud.cpp
|
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
|
$<TARGET_OBJECTS:examples_common_obj>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(glStencilViewer
|
target_link_libraries(glStencilViewer
|
||||||
|
@ -70,12 +70,9 @@ endforeach()
|
|||||||
|
|
||||||
_add_glfw_executable(glViewer
|
_add_glfw_executable(glViewer
|
||||||
viewer.cpp
|
viewer.cpp
|
||||||
../common/font_image.cpp
|
|
||||||
../common/hud.cpp
|
|
||||||
../common/gl_hud.cpp
|
|
||||||
../common/patchColors.cpp
|
|
||||||
${SHADER_FILES}
|
${SHADER_FILES}
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
|
$<TARGET_OBJECTS:examples_common_obj>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(glViewer
|
target_link_libraries(glViewer
|
||||||
|
@ -42,10 +42,8 @@ endif()
|
|||||||
|
|
||||||
_add_glfw_executable(limitEval
|
_add_glfw_executable(limitEval
|
||||||
main.cpp
|
main.cpp
|
||||||
../common/font_image.cpp
|
|
||||||
../common/hud.cpp
|
|
||||||
../common/gl_hud.cpp
|
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
|
$<TARGET_OBJECTS:examples_common_obj>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(limitEval
|
target_link_libraries(limitEval
|
||||||
|
@ -67,11 +67,9 @@ endforeach()
|
|||||||
|
|
||||||
_add_glfw_executable(paintTest
|
_add_glfw_executable(paintTest
|
||||||
main.cpp
|
main.cpp
|
||||||
../common/font_image.cpp
|
|
||||||
../common/hud.cpp
|
|
||||||
../common/gl_hud.cpp
|
|
||||||
${SHADER_FILES}
|
${SHADER_FILES}
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
|
$<TARGET_OBJECTS:examples_common_obj>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(paintTest
|
target_link_libraries(paintTest
|
||||||
|
@ -78,14 +78,10 @@ endforeach()
|
|||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
_add_glfw_executable(ptexViewer
|
_add_glfw_executable(ptexViewer
|
||||||
viewer.cpp
|
viewer.cpp
|
||||||
../common/font_image.cpp
|
${SHADER_FILES}
|
||||||
../common/hud.cpp
|
${INC_FILES}
|
||||||
../common/patchColors.cpp
|
$<TARGET_OBJECTS:examples_common_obj>
|
||||||
../common/gl_hud.cpp
|
|
||||||
../common/hdr_reader.cpp
|
|
||||||
${SHADER_FILES}
|
|
||||||
${INC_FILES}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(ptexViewer
|
target_link_libraries(ptexViewer
|
||||||
|
@ -69,11 +69,9 @@ endforeach()
|
|||||||
|
|
||||||
_add_glfw_executable(uvViewer
|
_add_glfw_executable(uvViewer
|
||||||
viewer.cpp
|
viewer.cpp
|
||||||
../common/font_image.cpp
|
|
||||||
../common/hud.cpp
|
|
||||||
../common/gl_hud.cpp
|
|
||||||
${SHADER_FILES}
|
${SHADER_FILES}
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
|
$<TARGET_OBJECTS:examples_common_obj>
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(uvViewer
|
target_link_libraries(uvViewer
|
||||||
|
@ -466,15 +466,25 @@ source_group("Inc" FILES ${INC_FILES})
|
|||||||
|
|
||||||
if (NOT NO_LIB)
|
if (NOT NO_LIB)
|
||||||
|
|
||||||
add_library(osd_static_cpu_obj
|
# Compile objs first for both the CPU and GPU libs -----
|
||||||
|
add_library(osd_cpu_obj
|
||||||
OBJECT
|
OBJECT
|
||||||
${CPU_SOURCE_FILES}
|
${CPU_SOURCE_FILES}
|
||||||
${PRIVATE_HEADER_FILES}
|
${PRIVATE_HEADER_FILES}
|
||||||
${PUBLIC_HEADER_FILES}
|
${PUBLIC_HEADER_FILES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
add_library(osd_gpu_obj
|
||||||
|
OBJECT
|
||||||
|
${GPU_SOURCE_FILES}
|
||||||
|
${PRIVATE_HEADER_FILES}
|
||||||
|
${PUBLIC_HEADER_FILES}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Build static libs ------------------------------------
|
||||||
add_library(osd_static_cpu
|
add_library(osd_static_cpu
|
||||||
STATIC
|
STATIC
|
||||||
$<TARGET_OBJECTS:osd_static_cpu_obj>
|
$<TARGET_OBJECTS:osd_cpu_obj>
|
||||||
)
|
)
|
||||||
set_target_properties(osd_static_cpu PROPERTIES OUTPUT_NAME osdCPU CLEAN_DIRECT_OUTPUT 1)
|
set_target_properties(osd_static_cpu PROPERTIES OUTPUT_NAME osdCPU CLEAN_DIRECT_OUTPUT 1)
|
||||||
|
|
||||||
@ -482,11 +492,11 @@ if (NOT NO_LIB)
|
|||||||
${PLATFORM_CPU_LIBRARIES}
|
${PLATFORM_CPU_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 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
|
_add_possibly_cuda_library(osd_static_gpu
|
||||||
STATIC
|
STATIC
|
||||||
${GPU_SOURCE_FILES}
|
$<TARGET_OBJECTS:osd_gpu_obj>
|
||||||
${PRIVATE_HEADER_FILES}
|
|
||||||
${PUBLIC_HEADER_FILES}
|
|
||||||
${KERNEL_FILES}
|
${KERNEL_FILES}
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
)
|
)
|
||||||
@ -499,22 +509,20 @@ if (NOT NO_LIB)
|
|||||||
install( TARGETS osd_static_cpu DESTINATION ${CMAKE_LIBDIR_BASE} )
|
install( TARGETS osd_static_cpu DESTINATION ${CMAKE_LIBDIR_BASE} )
|
||||||
install( TARGETS osd_static_gpu DESTINATION ${CMAKE_LIBDIR_BASE} )
|
install( TARGETS osd_static_gpu DESTINATION ${CMAKE_LIBDIR_BASE} )
|
||||||
|
|
||||||
|
# Build dynamic libs ----------------------------------
|
||||||
if (NOT WIN32 AND NOT IOS)
|
if (NOT WIN32 AND NOT IOS)
|
||||||
|
|
||||||
# Evaluate 'soname' from OSD version
|
# Evaluate 'soname' from OSD version
|
||||||
|
# replace '_' with '.'
|
||||||
|
string(REGEX REPLACE "(_)" "." OSD_SONAME ${OpenSubdiv_VERSION})
|
||||||
|
|
||||||
# replace '_' with '.'
|
# remove starting 'v' character
|
||||||
string(REGEX REPLACE "(_)" "." OSD_SONAME ${OpenSubdiv_VERSION})
|
string(REGEX REPLACE "^v" "" OSD_SONAME ${OSD_SONAME})
|
||||||
|
|
||||||
# remove starting 'v' character
|
|
||||||
string(REGEX REPLACE "^v" "" OSD_SONAME ${OSD_SONAME})
|
|
||||||
|
|
||||||
# generate dynamic-link targets
|
# generate dynamic-link targets
|
||||||
add_library(osd_dynamic_cpu
|
add_library(osd_dynamic_cpu
|
||||||
SHARED
|
SHARED
|
||||||
${CPU_SOURCE_FILES}
|
$<TARGET_OBJECTS:osd_cpu_obj>
|
||||||
${PRIVATE_HEADER_FILES}
|
|
||||||
${PUBLIC_HEADER_FILES}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(osd_dynamic_cpu
|
set_target_properties(osd_dynamic_cpu
|
||||||
@ -530,9 +538,7 @@ if (NOT NO_LIB)
|
|||||||
|
|
||||||
_add_possibly_cuda_library(osd_dynamic_gpu
|
_add_possibly_cuda_library(osd_dynamic_gpu
|
||||||
SHARED
|
SHARED
|
||||||
${GPU_SOURCE_FILES}
|
$<TARGET_OBJECTS:osd_gpu_obj>
|
||||||
${PRIVATE_HEADER_FILES}
|
|
||||||
${PUBLIC_HEADER_FILES}
|
|
||||||
${KERNEL_FILES}
|
${KERNEL_FILES}
|
||||||
${INC_FILES}
|
${INC_FILES}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user