Skip to content

kiesner/cmake-conan-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Connect Permutation Demo (Conan 1.60.1 + CMake ≥ 3.20)

This tiny, layout‑agnostic example shows:

  • Single CMakeLib version resolution via Conan lockfiles
  • Permutation modeling (ASIL, SOC, CRYPTO) as Conan options
  • Validation of the selected permutation against each core’s published capability set (JSON) in CMake
  • A dummy hex target to illustrate full “source → hex” flow

Tested with Conan 1.60.x and CMake ≥3.20.

Contents

cmakelib/
  1.13.4/conanfile.py        # CMakeLib v1 (for ^1.x)
  2.2.0/conanfile.py         # CMakeLib v2 (for conflict demo)
cores/
  MoveCore/3.4.0/conanfile.py
  MoveCore/3.4.0/core_caps.json
  NexusCore/2.2.0/conanfile.py
  NexusCore/2.2.0/core_caps.json
  NexusCore/3.0.0/conanfile.py        # requires CMakeLib ^2.x (conflict demo)
  NexusCore/3.0.0/core_caps.json
connect/
  conanfile.py               # meta "connect-config" package with options
  CMakeLists.txt             # includes permutation validator & makes demo.hex
  cmake/perm_validate.cmake  # layout-agnostic permutation validator
profiles/
  gcc12-linux                # example profile (edit as needed)

Quickstart

0) Prereqs

  • Conan 1.60.1 (conan --version)
  • CMake ≥ 3.20
  • Ninja or Make; GCC/Clang as you prefer (profile here assumes GCC 12 on Linux—adjust for your host)

Enable revisions (recommended):

conan config set general.revisions_enabled=1

1) Export the demo packages (local cache)

From the repo root (this folder):

# CMakeLib variants
conan export cmakelib/1.13.4 CMakeLib/1.13.4@demo/stable
conan export cmakelib/2.2.0  CMakeLib/2.2.0@demo/stable

# Cores
conan export cores/MoveCore/3.4.0    MoveCore/3.4.0@demo/stable
conan export cores/NexusCore/2.2.0   NexusCore/2.2.0@demo/stable
conan export cores/NexusCore/3.0.0   NexusCore/3.0.0@demo/stable   # optional (for conflict Scenario B)

2) Scenario A — Compatible ranges & valid permutation

cd connect

# Resolve (pins a single CMakeLib within ^1.x) and write lockfile
conan lock create . -pr:h=../profiles/gcc12-linux -pr:b=../profiles/gcc12-linux \
  -o connect-config:asil=C -o connect-config:soc=tc397 -o connect-config:crypto=gcm \
  --lockfile-out=conan.lock

# Install using the lock
conan install . --lockfile=conan.lock --build=missing

# Configure CMake (pass capability JSONs; paths are layout-agnostic here)
cmake -S . -B build/ASIL=C_SOC=tc397 \
  -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
  -DASIL=C -DSOC=tc397 -DCRYPTO=gcm \
  -DCORE_CAPS_FILES="../cores/MoveCore/3.4.0/core_caps.json;../cores/NexusCore/2.2.0/core_caps.json"

# Build to the dummy hex
cmake --build build/ASIL=C_SOC=tc397 --target hex -j
# -> build/ASIL=C_SOC=tc397/hex/demo.hex contains the permutation & trace info

3) Scenario B — Version conflict (CMakeLib ^1.x vs ^2.x)

Edit connect/conanfile.py and change the NexusCore require to NexusCore/3.0.0@demo/stable (already exported). Then resolve again:

conan lock create . -pr:h=../profiles/gcc12-linux -pr:b=../profiles/gcc12-linux \
  -o connect-config:asil=C -o connect-config:soc=tc397 -o connect-config:crypto=gcm \
  --lockfile-out=conan.lock
# Expect a conflict error, with ranges:
#   MoveCore requires:  >=1.8,<2.0
#   NexusCore requires: >=2.1,<3.0
#   Intersection: ∅

4) Scenario C — Permutation conflict

Keep the compatible cores (MoveCore 3.4.0 + NexusCore 2.2.0), but request ASIL=D:

conan lock create . -pr:h=../profiles/gcc12-linux -pr:b=../profiles/gcc12-linux \
  -o connect-config:asil=D -o connect-config:soc=tc397 -o connect-config:crypto=gcm \
  --lockfile-out=conan.lock

conan install . --lockfile=conan.lock --build=missing

cmake -S . -B build/ASIL=D_SOC=tc397 \
  -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake \
  -DASIL=D -DSOC=tc397 -DCRYPTO=gcm \
  -DCORE_CAPS_FILES="../cores/MoveCore/3.4.0/core_caps.json;../cores/NexusCore/2.2.0/core_caps.json"
# Configure should fail fast with a clear "[Permutation mismatch]" message for MoveCore.

Notes

  • The demo keeps capability JSONs in-source for simplicity; in real packages you’d ship them inside the package and pass their paths from CMake package variables.
  • The hex target is a stub that writes a file embedding the permutation; replace with your real link/load pipeline.
  • This is fully layout‑agnostic: only the CORE_CAPS_FILES list is needed to validate permutations.

Enjoy!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors