pcbjam/wasm/cmake/FindGLM.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

44 lines
1.7 KiB
CMake

# FindGLM.cmake for WASM cross-compilation
# This override is needed because CMake's find_file fails during cross-compilation
# GLM is a header-only library at ${GLM_INCLUDE_DIR}/glm/
# GLM_INCLUDE_DIR should be passed from the build script
if(NOT GLM_INCLUDE_DIR)
message(FATAL_ERROR "GLM_INCLUDE_DIR must be set for WASM builds")
endif()
# Verify the headers exist
if(NOT EXISTS "${GLM_INCLUDE_DIR}/glm/glm.hpp")
message(FATAL_ERROR "GLM headers not found at ${GLM_INCLUDE_DIR}/glm/glm.hpp")
endif()
# Extract version from setup.hpp
file(STRINGS "${GLM_INCLUDE_DIR}/glm/detail/setup.hpp" _glm_version_lines
REGEX "^#define[ \t]+GLM_VERSION_(MAJOR|MINOR|PATCH|REVISION)[ \t]+[0-9]+")
foreach(_line ${_glm_version_lines})
if(_line MATCHES "GLM_VERSION_MAJOR[ \t]+([0-9]+)")
set(_GLM_VERSION_MAJOR ${CMAKE_MATCH_1})
elseif(_line MATCHES "GLM_VERSION_MINOR[ \t]+([0-9]+)")
set(_GLM_VERSION_MINOR ${CMAKE_MATCH_1})
elseif(_line MATCHES "GLM_VERSION_PATCH[ \t]+([0-9]+)")
set(_GLM_VERSION_PATCH ${CMAKE_MATCH_1})
elseif(_line MATCHES "GLM_VERSION_REVISION[ \t]+([0-9]+)")
set(_GLM_VERSION_REVISION ${CMAKE_MATCH_1})
endif()
endforeach()
set(GLM_VERSION "${_GLM_VERSION_MAJOR}.${_GLM_VERSION_MINOR}.${_GLM_VERSION_PATCH}.${_GLM_VERSION_REVISION}")
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM
REQUIRED_VARS
GLM_INCLUDE_DIR
GLM_VERSION
VERSION_VAR GLM_VERSION)
mark_as_advanced(GLM_INCLUDE_DIR)
set(GLM_VERSION_MAJOR ${_GLM_VERSION_MAJOR} CACHE INTERNAL "")
set(GLM_VERSION_MINOR ${_GLM_VERSION_MINOR} CACHE INTERNAL "")
set(GLM_VERSION_PATCH ${_GLM_VERSION_PATCH} CACHE INTERNAL "")
set(GLM_VERSION_TWEAK ${_GLM_VERSION_REVISION} CACHE INTERNAL "")