@@ -14,20 +14,23 @@ if(EXISTS ${FILEPATH_CURRENT_DIR})
1414elseif (EXISTS ${FILEPATH_PROJECT_ROOT} )
1515 set (TARGET_FILE_PATH ${PROJECT_ROOT} )
1616else ()
17- message (FATAL_ERROR "File ${FILENAME} not found in either ${CMAKE_CURRENT_SOURCE_DIR} or ${CMAKE_CURRENT_SOURCE_DIR} /../../" )
17+ message (
18+ FATAL_ERROR
19+ "File ${FILENAME} not found in either ${CMAKE_CURRENT_SOURCE_DIR} or ${CMAKE_CURRENT_SOURCE_DIR} /../../"
20+ )
1821endif ()
1922
2023# Define architecture and build type directories or file names
2124if (CMAKE_SIZEOF_VOID_P EQUAL 8)
22- set (ARCH "x64" )
25+ set (ARCH "x64" )
2326else ()
24- set (ARCH "x86" )
27+ set (ARCH "x86" )
2528endif ()
2629
2730if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
28- set (BUILD_TYPE "Debug" )
31+ set (BUILD_TYPE "Debug" )
2932else ()
30- set (BUILD_TYPE "Release" )
33+ set (BUILD_TYPE "Release" )
3134endif ()
3235
3336add_library (webgpulib SHARED IMPORTED )
@@ -38,22 +41,39 @@ add_dependencies(gpu webgpulib)
3841target_include_directories (gpu INTERFACE ${TARGET_FILE_PATH} )
3942
4043# Add headers webgpu.h
41- target_include_directories (wgpu INTERFACE ${TARGET_FILE_PATH} /third_party/headers)
44+ target_include_directories (wgpu
45+ INTERFACE ${TARGET_FILE_PATH} /third_party/headers)
4246if (WIN32 )
43- set (DLL_PATH "${TARGET_FILE_PATH} /third_party/lib/libdawn_${ARCH} _${BUILD_TYPE} .dll" )
47+ set (DLL_PATH
48+ "${TARGET_FILE_PATH} /third_party/lib/libdawn_${ARCH} _${BUILD_TYPE} .dll" )
4449 if (EXISTS ${DLL_PATH} )
45- file (COPY ${DLL_PATH} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
46- target_link_libraries (webgpulib INTERFACE ${DLL_PATH} )
50+ file (COPY ${DLL_PATH} DESTINATION ${CMAKE_CURRENT_BINARY_DIR} )
51+ target_link_libraries (webgpulib INTERFACE ${DLL_PATH} )
4752 else ()
48- message (FATAL_ERROR "libdawn dll not found at: ${DLL_PATH} " )
49- endif ()
53+ message (FATAL_ERROR "libdawn dll not found at: ${DLL_PATH} " )
54+ endif ()
5055else ()
51- find_library (LIBDAWN dawn REQUIRED PATHS "${TARGET_FILE_PATH} /third_party/lib" )
56+ find_library (LIBDAWN dawn PATHS "${TARGET_FILE_PATH} /third_party/lib" )
5257 if (LIBDAWN)
5358 message (STATUS "Found libdawn: ${LIBDAWN} " )
54- # Link against libdawn
59+ # Link against libdawn
5560 target_link_libraries (webgpulib INTERFACE ${LIBDAWN} )
5661 else ()
57- message (FATAL_ERROR "libdawn not found" )
62+ message (
63+ FATAL_ERROR "libdawn not found, try downloading from the release" )
64+ FetchContent_Declare(
65+ libdawn
66+ url https://github.com/austinvhuang/dawn-artifacts/releases/download/prerelease/libdawn.dylib
67+ DOWNLOAD_DIR
68+ "${TARGET_FILE_PATH} /third_party/lib" )
69+ FetchContent_MakeAvailable(libdawn)
70+ find_library (LIBDAWN dawn PATHS "${TARGET_FILE_PATH} /third_party/lib" )
71+ if (LIBDAWN)
72+ message (STATUS "Found libdawn: ${LIBDAWN} " )
73+ # Link against libdawn
74+ target_link_libraries (webgpulib INTERFACE ${LIBDAWN} )
75+ else ()
76+ message (
77+ FATAL_ERROR "libdawn not found" )
5878 endif ()
59- endif ()
79+ endif ()
0 commit comments