graph TD A["find_package\n fmt CONFIG QUIET "] --> B{"fmt_FOUND?"} B -- "Yes β " --> C["System package\n Zero compile "] B -- "No" --> D["CPMAddPackage\n Download & build "] style A fill:#4caf50 style C fill:#4caf50 style D fill:#ff9800
graph TD subgraph CI["GitHub Actions CI"] Ubuntu["Ubuntu β "] --> MacOS["MacOS β "] MacOS --> Windows["Windows β "] Windows --> Install["Install β"] end style Ubuntu fill:#4caf50,color:#fff style MacOS fill:#4caf50,color:#fff style Windows fill:#4caf50,color:#fff style Install fill:#f44336,color:#fff
graph LR A["fmt::fmt already\nexists as IMPORTED"] --> B["CPM tries to\ncreate ALIAS"] B --> C{"Target type\n mismatch? "} C -- "Yes β" --> D["add_library cannot\ncreate ALIAS target"] style A fill:#e3f2fd style B fill:#ff9800 style C fill:#f44336 style D fill:#f44336,color:#fff
graph TD subgraph Simple["Simple Projects β "] S1["lds-gen-cpp"] --> S2["fmt"] S1 --> S3["spdlog"] end subgraph Complex["Complex Projects β"] C1["corr-solver-cpp"] --> C2["fmt"] C1 --> C3["EllAlgo"] C3 --> C4["fmt"] C3 --> C5["spdlog"] end style Simple fill:#e8f5e9 style Complex fill:#fce4ec style C1 fill:#f44336 style C3 fill:#ff9800
graph LR A["CMAKE_DISABLE\n_fmt=ON"] --> B["find_package(fmt)\n fails (hidden) "] B --> C["CPMAddPackage(fmt)\n creates REAL target "] C --> D["find_package(Project)\n works β "] style A fill:#2196f3,color:#fff style C fill:#4caf50,color:#fff style D fill:#4caf50
graph LR A["I set CPM_fmt_ADDED"] --> B["CPM ignored it β"] B --> C["Why? CPM checks CPM_PACKAGES\nlist, not _ADDED variable"] style A fill:#ff9800 style B fill:#f44336,color:#fff style C fill:#e3f2fd
graph LR A["find_package creates\nIMPORTED fmt::fmt"] --> B["I create REAL\nfmt INTERFACE"] B --> C["CPM sees TARGET fmt\nskips CPMAddPackage β "] C --> D["...BUT spdlog's bundled fmt\ntries REAL add_library"] D --> E["add_library cannot create\n'fmt' β ALIAS conflict"] style A fill:#e3f2fd style B fill:#ff9800 style C fill:#4caf50 style D fill:#f44336,color:#fff style E fill:#f44336
graph TD subgraph find_package["find_package Mode"] A["find_package(fmt CONFIG)\nloads fmt-config.cmake"] --> B["add_library(fmt::fmt\n SHARED IMPORTED )"] B --> C["fmt::fmt = IMPORTED target\n references external binary "] end subgraph CPMAddPackage["CPMAddPackage Mode"] D["CPM fetches fmt source\nruns fmt/CMakeLists.txt"] --> E["add_library(fmt::fmt\n ALIAS )"] E --> F["fmt::fmt = ALIAS target\n references REAL fmt lib "] end style A fill:#e3f2fd style B fill:#e3f2fd style D fill:#fff3e0 style E fill:#fff3e0
graph TD subgraph Pattern["Universal test_installed Pattern"] CPM["include(CPM.cmake)"] --> Deps["find_package for\nsimple deps (fmt)"] Deps --> CPMDeps["CPMAddPackage for\ntransitive deps (EllAlgo)"] CPMDeps --> Proj["find_package\n(Project)"] Proj --> Libs["set(SPECIFIC_LIBS ...)"] Libs --> Standalone["add_subdirectory\n(standalone)"] end style Pattern fill:#e8f5e9 style Deps fill:#4caf50 style CPMDeps fill:#ff9800 style Proj fill:#4caf50
graph LR A["Project A\nuse find_package(fmt)"] --> B["Creates fmt::fmt\nIMPORTED β "] C["Project B (dep of A)\nuse CPMAddPackage(fmt)"] --> D["Tries to create\nfmt::fmt ALIAS β"] A --> E["test_installed\nconfigure"] C --> E E --> F{"fmt::fmt exists\nas IMPORTED"} F -- "CPM tries ALIAS" --> G["ERROR π₯"] style A fill:#e3f2fd style C fill:#fff3e0 style F fill:#ff9800 style G fill:#f44336,color:#fff
graph TD subgraph Cost["Cost of Guessing π₯"] G1["β 6 failed CI runs"] --> G2["β 3 hours debugging"] G2 --> G3["β 5 different attempted fixes"] G3 --> G4["β Mutliple rollbacks"] end subgraph Better["Better Approach π‘"] B1["β Stop. Read CPM source."] --> B2["β Check packageProject DEPENDENCIES"] B2 --> B3["β Map the FULL transitive dep tree"] B3 --> B4["β Find the working reference (projgeom)"] B4 --> B5["β Apply ONE consistent pattern"] end Cost --> Better style Cost fill:#fce4ec,stroke:#f44336 style Better fill:#e8f5e9,stroke:#4caf50 style G1 fill:#f44336,color:#fff style G2 fill:#f44336,color:#fff style G3 fill:#f44336,color:#fff style G4 fill:#f44336,color:#fff style B1 fill:#4caf50,color:#fff style B2 fill:#4caf50,color:#fff style B3 fill:#4caf50,color:#fff style B4 fill:#4caf50,color:#fff style B5 fill:#4caf50,color:#fff