Make dawn components support CMake's BUILD_SHARED_LIBS

Convention in CMake land is that libraries default to STATIC or
SHARED based on BUILD_SHARED_LIBS. Do that for Dawn components
that users will link against, but make sure to correctly set
macros used for the export headers.

Bug: None

Change-Id: I6a96cb95706b63c18942424baada11ff81691866
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/28503
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2020-09-16 19:03:18 +00:00 committed by Commit Bot service account
parent c236769548
commit 19b910d796
3 changed files with 19 additions and 3 deletions

View File

@ -80,6 +80,10 @@ DawnJSONGenerator(
RESULT_VARIABLE "DAWNPROC_GEN_SOURCES"
)
add_library(dawn_proc STATIC ${DAWN_DUMMY_FILE})
add_library(dawn_proc ${DAWN_DUMMY_FILE})
target_compile_definitions(dawn_proc PRIVATE "WGPU_IMPLEMENTATION")
if(BUILD_SHARED_LIBS)
target_compile_definitions(dawn_proc PRIVATE "WGPU_SHARED_LIBRARY")
endif()
target_sources(dawn_proc PRIVATE ${DAWNPROC_GEN_SOURCES})
target_link_libraries(dawn_proc PUBLIC dawn_headers)

View File

@ -18,7 +18,13 @@ DawnJSONGenerator(
RESULT_VARIABLE "DAWN_NATIVE_UTILS_GEN_SOURCES"
)
add_library(dawn_native STATIC ${DAWN_DUMMY_FILE})
add_library(dawn_native ${DAWN_DUMMY_FILE})
target_compile_definitions(dawn_native PRIVATE "DAWN_NATIVE_IMPLEMENTATION")
if(BUILD_SHARED_LIBS)
target_compile_definitions(dawn_native PRIVATE "DAWN_NATIVE_SHARED_LIBRARY")
endif()
target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_native/DawnNative.h"
"${DAWN_INCLUDE_DIR}/dawn_native/dawn_native_export.h"

View File

@ -18,7 +18,13 @@ DawnJSONGenerator(
RESULT_VARIABLE "DAWN_WIRE_GEN_SOURCES"
)
add_library(dawn_wire STATIC ${DAWN_DUMMY_FILE})
add_library(dawn_wire ${DAWN_DUMMY_FILE})
target_compile_definitions(dawn_wire PRIVATE "DAWN_WIRE_IMPLEMENTATION")
if(BUILD_SHARED_LIBS)
target_compile_definitions(dawn_wire PRIVATE "DAWN_WIRE_SHARED_LIBRARY")
endif()
target_sources(dawn_wire PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_wire/Wire.h"
"${DAWN_INCLUDE_DIR}/dawn_wire/WireClient.h"