mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-10 06:10:07 +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))
|
||||
|
||||
add_subdirectory(common)
|
||||
|
||||
add_subdirectory(glViewer)
|
||||
add_subdirectory(glBatchViewer)
|
||||
add_subdirectory(glStencilViewer)
|
||||
add_subdirectory(simpleCpu)
|
||||
add_subdirectory(limitEval)
|
||||
add_subdirectory(tessellateObjFile)
|
||||
|
||||
if (NOT APPLE)
|
||||
add_subdirectory(uvViewer)
|
||||
endif()
|
||||
|
||||
if(OPENGL_4_3_FOUND AND (NOT APPLE))
|
||||
# the paintTest example requires GL functionality not available on OSX
|
||||
add_subdirectory(paintTest)
|
||||
endif()
|
||||
|
||||
if(PTEX_FOUND)
|
||||
add_subdirectory(ptexViewer)
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
set(MISSING "")
|
||||
|
||||
if (NOT OPENGL_FOUND)
|
||||
@ -70,6 +78,7 @@ if(DXSDK_FOUND)
|
||||
if(PTEX_FOUND)
|
||||
add_subdirectory(dxPtexViewer)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
|
||||
@ -79,8 +88,7 @@ if(MAYA_FOUND)
|
||||
# manuelk: the following plugins are disabled until further notice
|
||||
|
||||
#add_subdirectory(mayaViewer)
|
||||
|
||||
if(PTEX_FOUND)
|
||||
#if(PTEX_FOUND)
|
||||
#add_subdirectory(mayaPtexViewer)
|
||||
endif()
|
||||
#endif()
|
||||
endif()
|
||||
|
@ -42,9 +42,6 @@ include_directories(
|
||||
)
|
||||
|
||||
set(SOURCE_FILES
|
||||
../common/font_image.cpp
|
||||
../common/hud.cpp
|
||||
../common/d3d11_hud.cpp
|
||||
dxPtexViewer.cpp
|
||||
)
|
||||
|
||||
@ -74,6 +71,7 @@ _add_possibly_cuda_executable(dxPtexViewer WIN32
|
||||
${SOURCE_FILES}
|
||||
${SHADER_FILES}
|
||||
${INC_FILES}
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
target_link_libraries(dxPtexViewer
|
||||
|
@ -40,9 +40,6 @@ include_directories(
|
||||
)
|
||||
|
||||
set(SOURCE_FILES
|
||||
../common/font_image.cpp
|
||||
../common/hud.cpp
|
||||
../common/d3d11_hud.cpp
|
||||
dxViewer.cpp
|
||||
)
|
||||
|
||||
@ -72,6 +69,7 @@ _add_possibly_cuda_executable(dxViewer WIN32
|
||||
${SOURCE_FILES}
|
||||
${SHADER_FILES}
|
||||
${INC_FILES}
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
target_link_libraries(dxViewer
|
||||
|
@ -73,12 +73,9 @@ _add_glfw_executable(glBatchViewer
|
||||
delegate.cpp
|
||||
effect.cpp
|
||||
effectRegistry.cpp
|
||||
../common/font_image.cpp
|
||||
../common/hud.cpp
|
||||
../common/patchColors.cpp
|
||||
../common/gl_hud.cpp
|
||||
${SHADER_FILES}
|
||||
${INC_FILES}
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
target_link_libraries(glBatchViewer
|
||||
|
@ -42,10 +42,8 @@ endif()
|
||||
|
||||
_add_glfw_executable(glStencilViewer
|
||||
main.cpp
|
||||
../common/font_image.cpp
|
||||
../common/hud.cpp
|
||||
../common/gl_hud.cpp
|
||||
${INC_FILES}
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
target_link_libraries(glStencilViewer
|
||||
|
@ -70,12 +70,9 @@ endforeach()
|
||||
|
||||
_add_glfw_executable(glViewer
|
||||
viewer.cpp
|
||||
../common/font_image.cpp
|
||||
../common/hud.cpp
|
||||
../common/gl_hud.cpp
|
||||
../common/patchColors.cpp
|
||||
${SHADER_FILES}
|
||||
${INC_FILES}
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
target_link_libraries(glViewer
|
||||
|
@ -42,10 +42,8 @@ endif()
|
||||
|
||||
_add_glfw_executable(limitEval
|
||||
main.cpp
|
||||
../common/font_image.cpp
|
||||
../common/hud.cpp
|
||||
../common/gl_hud.cpp
|
||||
${INC_FILES}
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
target_link_libraries(limitEval
|
||||
|
@ -67,11 +67,9 @@ endforeach()
|
||||
|
||||
_add_glfw_executable(paintTest
|
||||
main.cpp
|
||||
../common/font_image.cpp
|
||||
../common/hud.cpp
|
||||
../common/gl_hud.cpp
|
||||
${SHADER_FILES}
|
||||
${INC_FILES}
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
target_link_libraries(paintTest
|
||||
|
@ -78,14 +78,10 @@ endforeach()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
_add_glfw_executable(ptexViewer
|
||||
viewer.cpp
|
||||
../common/font_image.cpp
|
||||
../common/hud.cpp
|
||||
../common/patchColors.cpp
|
||||
../common/gl_hud.cpp
|
||||
../common/hdr_reader.cpp
|
||||
${SHADER_FILES}
|
||||
${INC_FILES}
|
||||
viewer.cpp
|
||||
${SHADER_FILES}
|
||||
${INC_FILES}
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
target_link_libraries(ptexViewer
|
||||
|
@ -69,11 +69,9 @@ endforeach()
|
||||
|
||||
_add_glfw_executable(uvViewer
|
||||
viewer.cpp
|
||||
../common/font_image.cpp
|
||||
../common/hud.cpp
|
||||
../common/gl_hud.cpp
|
||||
${SHADER_FILES}
|
||||
${INC_FILES}
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
target_link_libraries(uvViewer
|
||||
|
@ -466,15 +466,25 @@ source_group("Inc" FILES ${INC_FILES})
|
||||
|
||||
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
|
||||
${CPU_SOURCE_FILES}
|
||||
${PRIVATE_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
|
||||
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)
|
||||
|
||||
@ -482,11 +492,11 @@ if (NOT NO_LIB)
|
||||
${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
|
||||
STATIC
|
||||
${GPU_SOURCE_FILES}
|
||||
${PRIVATE_HEADER_FILES}
|
||||
${PUBLIC_HEADER_FILES}
|
||||
$<TARGET_OBJECTS:osd_gpu_obj>
|
||||
${KERNEL_FILES}
|
||||
${INC_FILES}
|
||||
)
|
||||
@ -499,22 +509,20 @@ if (NOT NO_LIB)
|
||||
install( TARGETS osd_static_cpu DESTINATION ${CMAKE_LIBDIR_BASE} )
|
||||
install( TARGETS osd_static_gpu DESTINATION ${CMAKE_LIBDIR_BASE} )
|
||||
|
||||
# Build dynamic libs ----------------------------------
|
||||
if (NOT WIN32 AND NOT IOS)
|
||||
|
||||
# Evaluate 'soname' from OSD version
|
||||
# replace '_' with '.'
|
||||
string(REGEX REPLACE "(_)" "." OSD_SONAME ${OpenSubdiv_VERSION})
|
||||
|
||||
# replace '_' with '.'
|
||||
string(REGEX REPLACE "(_)" "." OSD_SONAME ${OpenSubdiv_VERSION})
|
||||
|
||||
# remove starting 'v' character
|
||||
string(REGEX REPLACE "^v" "" OSD_SONAME ${OSD_SONAME})
|
||||
# remove starting 'v' character
|
||||
string(REGEX REPLACE "^v" "" OSD_SONAME ${OSD_SONAME})
|
||||
|
||||
# generate dynamic-link targets
|
||||
add_library(osd_dynamic_cpu
|
||||
SHARED
|
||||
${CPU_SOURCE_FILES}
|
||||
${PRIVATE_HEADER_FILES}
|
||||
${PUBLIC_HEADER_FILES}
|
||||
$<TARGET_OBJECTS:osd_cpu_obj>
|
||||
)
|
||||
|
||||
set_target_properties(osd_dynamic_cpu
|
||||
@ -530,9 +538,7 @@ if (NOT NO_LIB)
|
||||
|
||||
_add_possibly_cuda_library(osd_dynamic_gpu
|
||||
SHARED
|
||||
${GPU_SOURCE_FILES}
|
||||
${PRIVATE_HEADER_FILES}
|
||||
${PUBLIC_HEADER_FILES}
|
||||
$<TARGET_OBJECTS:osd_gpu_obj>
|
||||
${KERNEL_FILES}
|
||||
${INC_FILES}
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user