Use obj targets for faster CPU/GPU lib builds

Further leverage cmake object libraries to share object files for CPU
and GPU OSD libraries, avoiding duplicate complation for dynamic/static
build passes.

CMake restricts object library inputs to header and source files, so the
.inc files were renamed to .gen.h (which seems like a better name
anyway) to make CMake happy.

Also updated the .gitignore file to ignore .gen.h files.

Conflicts:
	opensubdiv/osd/CMakeLists.txt
This commit is contained in:
jcowles 2013-12-23 22:30:34 -08:00 committed by manuelk
parent 94d2408c15
commit eb09b9e14c
8 changed files with 19 additions and 19 deletions

1
.gitignore vendored
View File

@ -2,6 +2,7 @@
# ignore stringified kernels
*.inc
*.inc.rule
*.gen.h
# ignore build files
/build*

View File

@ -446,7 +446,7 @@ foreach(kernel_file ${KERNEL_FILES})
if(NOT ${extension} STREQUAL "cu")
string(REGEX REPLACE "(.*)[.].*" "\\1.inc" inc_file ${kernel_file})
string(REGEX REPLACE "(.*)[.].*" "\\1.gen.h" inc_file ${kernel_file})
list(APPEND INC_FILES ${inc_file})
add_custom_command(
@ -479,6 +479,7 @@ if (NOT NO_LIB)
${GPU_SOURCE_FILES}
${PRIVATE_HEADER_FILES}
${PUBLIC_HEADER_FILES}
${INC_FILES}
)
# Build static libs ------------------------------------
@ -498,7 +499,6 @@ if (NOT NO_LIB)
STATIC
$<TARGET_OBJECTS:osd_gpu_obj>
${KERNEL_FILES}
${INC_FILES}
)
set_target_properties(osd_static_gpu PROPERTIES OUTPUT_NAME osdGPU CLEAN_DIRECT_OUTPUT 1)
@ -538,9 +538,8 @@ if (NOT NO_LIB)
_add_possibly_cuda_library(osd_dynamic_gpu
SHARED
$<TARGET_OBJECTS:osd_gpu_obj>
${KERNEL_FILES}
${INC_FILES}
$<TARGET_OBJECTS:osd_gpu_obj>
${KERNEL_FILES}
)
set_target_properties(osd_dynamic_gpu

View File

@ -33,7 +33,7 @@
#endif
static const char *clSource =
#include "clKernel.inc"
#include "clKernel.gen.h"
;
#define CL_CHECK_ERROR(x, ...) { \

View File

@ -43,19 +43,19 @@ OsdD3D11DrawConfig::~OsdD3D11DrawConfig()
}
static const char *commonShaderSource =
#include "hlslPatchCommon.inc"
#include "hlslPatchCommon.gen.h"
;
static const char *ptexShaderSource =
#include "hlslPtexCommon.inc"
#include "hlslPtexCommon.gen.h"
;
static const char *bsplineShaderSource =
#include "hlslPatchBSpline.inc"
#include "hlslPatchBSpline.gen.h"
;
static const char *gregoryShaderSource =
#include "hlslPatchGregory.inc"
#include "hlslPatchGregory.gen.h"
;
static const char *transitionShaderSource =
#include "hlslPatchTransition.inc"
#include "hlslPatchTransition.gen.h"
;
OsdD3D11DrawRegistryBase::~OsdD3D11DrawRegistryBase() {}

View File

@ -40,7 +40,7 @@ namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
static const char *shaderSource =
#include "../osd/hlslComputeKernel.inc"
#include "../osd/hlslComputeKernel.gen.h"
;
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }

View File

@ -39,19 +39,19 @@ OsdGLDrawConfig::~OsdGLDrawConfig()
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
static const char *commonShaderSource =
#include "glslPatchCommon.inc"
#include "glslPatchCommon.gen.h"
;
static const char *ptexShaderSource =
#include "glslPtexCommon.inc"
#include "glslPtexCommon.gen.h"
;
static const char *bsplineShaderSource =
#include "glslPatchBSpline.inc"
#include "glslPatchBSpline.gen.h"
;
static const char *gregoryShaderSource =
#include "glslPatchGregory.inc"
#include "glslPatchGregory.gen.h"
;
static const char *transitionShaderSource =
#include "glslPatchTransition.inc"
#include "glslPatchTransition.gen.h"
;
#endif

View File

@ -42,7 +42,7 @@ namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
static const char *shaderSource =
#include "../osd/glslComputeKernel.inc"
#include "../osd/glslComputeKernel.gen.h"
;
OsdGLSLComputeKernelBundle::OsdGLSLComputeKernelBundle()

View File

@ -45,7 +45,7 @@ namespace OpenSubdiv {
namespace OPENSUBDIV_VERSION {
static const char *shaderSource =
#include "../osd/glslTransformFeedbackKernel.inc"
#include "../osd/glslTransformFeedbackKernel.gen.h"
;
static const char *shaderDefines = ""