Skip to content

Improve CMake/FetchContent support #1362

@ahoarau

Description

@ahoarau

Hi,
First of all, thanks for this great library ! I started integration in various CMake projects, and wondered if we could improve the integration.

Issues

First, I noticed that the layout of the amalgamated archive is as follows:

<archive>/arm/neon.h

While the brew/apt versions are under the "simde" folder:

/usr/include/simde/arm/neon.h
/opt/homebrew/Cellar/simde/0.8.2/include/simde/arm/neon.h

To use it in CMakeusing FetchContent, we have to use a little trick to match the packaged version:

  include(FetchContent)
  FetchContent_Declare(
    simde
    URL https://github.com/simd-everywhere/simde/releases/download/v0.8.2/simde-amalgamated-0.8.2.tar.xz
    URL_HASH MD5=57239a45e0cc7ceccb20b3b69cae6db5
    # NOTE: we change the base dir with SOURCE_DIR to match the simde installed with apt-get (simde prefix)
    SOURCE_DIR ${FETCHCONTENT_BASE_DIR}/simde-src/simde
  )
  FetchContent_MakeAvailable(simde)

  add_library(simde::simde INTERFACE IMPORTED)
  target_include_directories(simde::simde SYSTEM INTERFACE ${FETCHCONTENT_BASE_DIR}/simde-src)

Proposed solutions

1. Add a "simde" sub-folder in the amalgatated archive

This would simplify the FetchContent usage to a more standard:

  include(FetchContent)
  FetchContent_Declare(
    simde
    URL https://github.com/simd-everywhere/simde/releases/download/v0.8.2/simde-amalgamated-0.8.2.tar.xz
    URL_HASH MD5=57239a45e0cc7ceccb20b3b69cae6db5
  )
  FetchContent_MakeAvailable(simde)

  add_library(simde::simde INTERFACE IMPORTED)
  target_include_directories(simde::simde SYSTEM INTERFACE ${simde_SOURCE_DIR})

2. Provide a CMake support for the repo

Use cases concerned:

  • Using simde as a submodule
  • Using simde as a subfolder
  • Using simde with FetchContent/CPM
  include(FetchContent)
  FetchContent_Declare(
    simde
    GIT_REPOSITORY https://github.com/simd-everywhere/simde
  )
  FetchContent_MakeAvailable(simde)
  # Use the imported simde::simde target

3. Provide a Cmake Support for the amalgamated version

Adding a CMakeLists.txt in the amalgamated archive like this one would enable native FetchContent:

cmake_minimum_required(VERSION 3.10)
project(simde VERSION 0.8.7)
add_library(simde::simde INTERFACE IMPORTED)
target_include_directories(simde::simde SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions