Commit 9cc163cb by Ben Clayton

CMakeLists: Allow overriding of building cppdap

Outer projects may already build this target, in which case we don't want to build it again. Bug: b/148010928 Change-Id: I19eea95eb81f13495268f5109d5554ef16033598 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/40330Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 5837d877
......@@ -94,6 +94,12 @@ function (option_if_not_defined name description default)
endif()
endfunction()
function (set_if_not_defined name value)
if(NOT DEFINED ${name})
set(${name} ${value} PARENT_SCOPE)
endif()
endfunction()
option_if_not_defined(SWIFTSHADER_BUILD_EGL "Build the EGL library" 1)
option_if_not_defined(SWIFTSHADER_BUILD_GLESv2 "Build the OpenGL ES 2 library" 1)
option_if_not_defined(SWIFTSHADER_BUILD_GLES_CM "Build the OpenGL ES 1.1 library" 1)
......@@ -120,9 +126,9 @@ option_if_not_defined(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER "Enable vulkan debugger
set(BUILD_MARL ${SWIFTSHADER_BUILD_VULKAN})
if(${SWIFTSHADER_BUILD_VULKAN} AND ${SWIFTSHADER_ENABLE_VULKAN_DEBUGGER})
set(BUILD_CPPDAP 1)
set_if_not_defined(SWIFTSHADER_BUILD_CPPDAP 1)
else()
set(BUILD_CPPDAP 0)
set_if_not_defined(SWIFTSHADER_BUILD_CPPDAP 0)
endif()
set(DEFAULT_REACTOR_BACKEND "LLVM")
......@@ -2086,10 +2092,10 @@ if(BUILD_MARL)
add_subdirectory(third_party/marl)
endif(BUILD_MARL)
if(BUILD_CPPDAP)
if(SWIFTSHADER_BUILD_CPPDAP)
set(CPPDAP_THIRD_PARTY_DIR ${THIRD_PARTY_DIR})
add_subdirectory(${CPPDAP_DIR})
endif(BUILD_CPPDAP)
endif(SWIFTSHADER_BUILD_CPPDAP)
if(SWIFTSHADER_BUILD_VULKAN)
add_library(vk_swiftshader SHARED ${VULKAN_LIST})
......@@ -2100,21 +2106,21 @@ if(SWIFTSHADER_BUILD_VULKAN)
list(APPEND VULKAN_INCLUDE_DIR "${SPIRV-Headers_SOURCE_DIR}/include")
add_subdirectory(third_party/SPIRV-Tools)
# Copy the OpenCLDebugInfo100.h header that's generated by SPIRV-Tools
# out to a separate directory that can be added to the include path.
# Ideally, this header would just be pre-built and part of SPIRV-Headers.
# See: https://github.com/KhronosGroup/SPIRV-Headers/issues/137
set(SPIRV_TOOLS_EXT_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-ext/include)
add_custom_target(spirv_tools_ext_includes
DEPENDS spirv-tools-header-OpenCLDebugInfo100
COMMAND ${CMAKE_COMMAND} -E copy
${spirv-tools_BINARY_DIR}/OpenCLDebugInfo100.h
${SPIRV_TOOLS_EXT_INC_DIR}/spirv-tools/ext/OpenCLDebugInfo100.h
)
list(APPEND VULKAN_INCLUDE_DIR "${SPIRV_TOOLS_EXT_INC_DIR}")
add_dependencies(vk_swiftshader spirv_tools_ext_includes)
endif()
endif(NOT TARGET SPIRV-Tools)
# Copy the OpenCLDebugInfo100.h header that's generated by SPIRV-Tools
# out to a separate directory that can be added to the include path.
# Ideally, this header would just be pre-built and part of SPIRV-Headers.
# See: https://github.com/KhronosGroup/SPIRV-Headers/issues/137
set(SPIRV_TOOLS_EXT_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-ext/include)
add_custom_target(spirv_tools_ext_includes
DEPENDS spirv-tools-header-OpenCLDebugInfo100
COMMAND ${CMAKE_COMMAND} -E copy
${spirv-tools_BINARY_DIR}/OpenCLDebugInfo100.h
${SPIRV_TOOLS_EXT_INC_DIR}/spirv-tools/ext/OpenCLDebugInfo100.h
)
list(APPEND VULKAN_INCLUDE_DIR "${SPIRV_TOOLS_EXT_INC_DIR}")
add_dependencies(vk_swiftshader spirv_tools_ext_includes)
set_target_properties(vk_swiftshader PROPERTIES
INCLUDE_DIRECTORIES "${VULKAN_INCLUDE_DIR}"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment