From 04ff84bc3546c971bfdc930f029d35baf420b839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MACHIZAUD=20Andr=C3=A9a?= Date: Mon, 9 May 2022 16:44:59 +0200 Subject: [PATCH] Expose preprocessor definition about enabled features --- opensubdiv/CMakeLists.txt | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/opensubdiv/CMakeLists.txt b/opensubdiv/CMakeLists.txt index 07cba067..5047fe56 100644 --- a/opensubdiv/CMakeLists.txt +++ b/opensubdiv/CMakeLists.txt @@ -366,6 +366,57 @@ if (NOT NO_LIB) endif() endif() + + # Expose preprocessor macro to the interface so that client know which feature are enabled + if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.0) + foreach(osd_target osd_static_cpu osd_static_gpu osd_dynamic_cpu osd_dynamic_gpu osd_static_framework osd_dynamic_framework) + if(TARGET ${osd_target}) + if(CLEW_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_CLEW) + endif() + if(CUDA_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_CUDA) + endif() + if(DXSDK_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_DX11SDK) + endif() + if(METAL_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_METAL) + endif() + if(OPENCL_CL_D3D11_EXT_H_FOUND OR OPENCL_CL_D3D11_H_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_OPENCL_DX_INTEROP) + endif() + if(OPENCL_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_OPENCL) + endif() + if(OPENGL_4_2_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK) + endif() + if(OPENGL_4_3_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_GLSL_COMPUTE) + endif() + if(NOT NO_OPENGL AND OPENGL_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_OPENGL) + endif() + if(NOT NO_OPENGL AND OPENGLES_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_OPENGLES) + endif() + if(OPENMP_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_OPENMP) + endif() + if(OPENSUBDIV_GREGORY_EVAL_TRUE_DERIVATIVES) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_GREGORY_EVAL_TRUE_DERIVATIVES) + endif() + if(PTEX_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_PTEX) + endif() + if(TBB_FOUND) + target_compile_definitions(${osd_target} INTERFACE OPENSUBDIV_HAS_TBB) + endif() + endif() + endforeach() + endif() + endif() #-------------------------------------------------------------------------------