From 124e86e4baa0b1ae9fdace847eac2185b5ed4d9b Mon Sep 17 00:00:00 2001 From: Jaswant Panchumarti Date: Wed, 19 Jun 2024 11:10:03 -0400 Subject: [PATCH] Test cmake refactor branch --- CMakeLists.txt | 67 +++++--------------------------------------------- 1 file changed, 6 insertions(+), 61 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 895a6b4..38b02f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,76 +21,21 @@ include(FetchContent) set(dawn_disconnect_subsequent_updates ON) FetchContent_Declare(dawn GIT_REPOSITORY https://dawn.googlesource.com/dawn - GIT_TAG "chromium/${CHROMIUM_VERSION_PATCH}" + GIT_TAG "chromium/6546" GIT_SUBMODULES "" GIT_SHALLOW ON) -# Dawn outputs various library files in a directory structure that mirrors -# it's source tree. While this is convenient to understand provenance, -# having all of them under one roof is quite convenient for packaging. -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib") -set(CMAKE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin") # Forces dawn to generate static libraries and bundle them all into one giant shared library. set(BUILD_SHARED_LIBS OFF) +set(DAWN_ENABLE_INSTALL ON) +set(DAWN_FETCH_DEPENDENCIES ON) # Disable unneeded parts -set(DAWN_BUILD_SAMPLES OFF) set(DAWN_USE_GLFW OFF) -set(DAWN_BUILD_PROTOBUF OFF) -set(DAWN_FETCH_DEPENDENCIES ON) +set(DAWN_BUILD_SAMPLES OFF) set(TINT_BUILD_CMD_TOOLS OFF) set(TINT_BUILD_SAMPLES OFF) set(TINT_BUILD_DOCS OFF) set(TINT_BUILD_TESTS OFF) -# add dawn source directory to build system FetchContent_MakeAvailable(dawn) -# This is all of necessary dawn libraries bundled up. -add_library(dawn SHARED "${dawn_BINARY_DIR}/gen/src/dawn/native/webgpu_dawn_native_proc.cpp") -add_library(dawn::dawn ALIAS dawn) -# 'nested-namespace-definition' requires compiler flag '/std:c++17' -target_compile_features(dawn PRIVATE cxx_std_17) -target_link_libraries(dawn - PRIVATE dawn_native) -# associate the header with the target so that it gets installed. -target_sources(dawn INTERFACE - FILE_SET dawn_webgpu_header - TYPE HEADERS - BASE_DIRS "${dawn_BINARY_DIR}/gen/include" - FILES "${dawn_BINARY_DIR}/gen/include/dawn/webgpu.h") -target_compile_definitions(dawn - PUBLIC "WGPU_SHARED_LIBRARY") -target_compile_definitions(dawn - PRIVATE "WGPU_IMPLEMENTATION") -# installs header `dawn/webgpu.h` and the shared library `dawn` -include(GNUInstallDirs) -install(TARGETS dawn - EXPORT dawn-targets - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - FILE_SET dawn_webgpu_header) -install( - DIRECTORY "${dawn_BINARY_DIR}/gen/emscripten-bits" - TYPE LIB) -# installs helpful package info so that folks can locate us via cmake find_package or pkg-config. -install(EXPORT dawn-targets - FILE dawnTargets.cmake - NAMESPACE dawn:: - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dawn) -# Create a ConfigVersion.cmake file: -include(CMakePackageConfigHelpers) -write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/dawnConfigVersion.cmake - COMPATIBILITY AnyNewerVersion) -# Configure config file -configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/dawnConfig.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/dawnConfig.cmake - INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dawn) -# Install the fully generated config and configVersion files -install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/dawnConfig.cmake - ${CMAKE_CURRENT_BINARY_DIR}/dawnConfigVersion.cmake - DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/dawn) # Run simple unit tests to ensure wgpu symbols were exported. include(CTest) set(BUILD_TESTING ON) @@ -108,10 +53,10 @@ if (BUILD_TESTING) add_executable(simple_cpp tests/simple.cpp) target_compile_features(simple_cpp PRIVATE cxx_std_17) target_link_libraries(simple_cpp PRIVATE webgpu_headers ${CMAKE_DL_LIBS}) - add_test(NAME test-simple-cpp COMMAND simple_cpp "$") + add_test(NAME test-simple-cpp COMMAND simple_cpp "$") add_executable(simple_c tests/simple.c) target_link_libraries(simple_c PRIVATE webgpu_headers ${CMAKE_DL_LIBS}) - add_test(NAME test-simple-c COMMAND simple_c "$") + add_test(NAME test-simple-c COMMAND simple_c "$") endif () # Packaging include(CPack)