pcbjam/wasm/cmake/FindZSTD.cmake
Viktor Vaczi c408410c7d Add KiCad PCBnew build script and CMake Find modules
- Add scripts/kicad/build-pcbnew.sh with clean-by-default and --no-clean flag
- Remove old scripts/build-pcbnew-wasm.sh (moved to scripts/kicad/)
- Add Boost build script with Emscripten toolset for Boost.Locale
- Add header download scripts for CURL and libgit2 (stub libraries)
- Add CMake Find modules for cross-compilation compatibility:
  - FindGLM.cmake: Reads version from setup.hpp
  - FindZSTD.cmake: Explicit sysroot paths
  - FindCURL.cmake: Header-only stub
  - FindSPNAV.cmake: Disabled (3D mouse not needed in browser)
  - FindCairo.cmake: Finds our built Cairo
  - FindPixman.cmake: Finds our built Pixman
  - Findlibgit2.cmake: Header-only stub
- Fix OpenCASCADE build: correct extracted dir name, add CMake policy
- Fix Protobuf build: correct GitHub release tag format (v21.12 not v3.21.12)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-08 11:37:14 +01:00

48 lines
1.5 KiB
CMake

# FindZSTD.cmake for WASM cross-compilation
# This override is needed because CMake's find_path/find_library fail during cross-compilation
# ZSTD_INCLUDE_DIR and ZSTD_LIBRARY should be passed from the build script
# or we can use CMAKE_PREFIX_PATH/ZSTD_ROOT
if(NOT ZSTD_INCLUDE_DIR)
find_path(ZSTD_INCLUDE_DIR NAMES zstd.h
PATHS ${ZSTD_ROOT} ${CMAKE_PREFIX_PATH}
PATH_SUFFIXES include
NO_DEFAULT_PATH)
endif()
if(NOT ZSTD_LIBRARY)
find_library(ZSTD_LIBRARY NAMES zstd libzstd zstd_static
PATHS ${ZSTD_ROOT} ${CMAKE_PREFIX_PATH}
PATH_SUFFIXES lib
NO_DEFAULT_PATH)
endif()
# Fallback: if not found via find_* commands, check if passed directly
if(NOT ZSTD_INCLUDE_DIR AND DEFINED ENV{SYSROOT})
set(ZSTD_INCLUDE_DIR "$ENV{SYSROOT}/include")
endif()
if(NOT ZSTD_LIBRARY AND DEFINED ENV{SYSROOT})
set(ZSTD_LIBRARY "$ENV{SYSROOT}/lib/libzstd.a")
endif()
# Verify files exist
if(ZSTD_INCLUDE_DIR AND NOT EXISTS "${ZSTD_INCLUDE_DIR}/zstd.h")
message(WARNING "ZSTD headers not found at ${ZSTD_INCLUDE_DIR}/zstd.h")
unset(ZSTD_INCLUDE_DIR)
endif()
if(ZSTD_LIBRARY AND NOT EXISTS "${ZSTD_LIBRARY}")
message(WARNING "ZSTD library not found at ${ZSTD_LIBRARY}")
unset(ZSTD_LIBRARY)
endif()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZSTD DEFAULT_MSG
ZSTD_LIBRARY ZSTD_INCLUDE_DIR)
if(ZSTD_FOUND)
message(STATUS "Found Zstd: ${ZSTD_LIBRARY}")
endif()
mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARY)