# CMake + Presets/Toolchain for iOS - Problem to find libs with find\_package

**URL:** https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642
**Category:** Code
**Tags:** gen:xcode, os:ios
**Created:** [October 11, 2022, 7:49pm UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642 "2022-10-11T19:49:06Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![DrAuraHxC](https://discourse.cmake.org/user_avatar/discourse.cmake.org/draurahxc/32/2827_2.png) [@DrAuraHxC](https://discourse.cmake.org/u/DrAuraHxC)
#### Post date: [October 11, 2022, 7:49pm UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/1 "2022-10-11T19:49:06Z")

</div>

Hi everyone,

I’m facing something strange and I can’t figure out if it’s actually a bug or a misunderstanding of the system.  
I use the preset system to manage the different OS with toolchain.

Here is an extract of my presets:

```json
"version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 24,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "release",
      "hidden": true,
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/.build/${presetName}",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release",
        "CMAKE_MODULE_PATH": "${sourceDir}/cmake/modules"
      }
    },
    {
      "name": "debug",
      "hidden": true,
      "generator": "Ninja",
      "inherits": ["release"],
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug",
        "CMAKE_VERBOSE_MAKEFILE": "ON"
      }
    },
    {
      "name": "release-macOS",
      "description": "",
      "inherits": ["release"],
      "toolchainFile": "${sourceDir}/cmake/toolchains/macOS.cmake",
      "cacheVariables": {
        "CMAKE_PREFIX_PATH": "$env{TVP_PUBLIBS}/_install/macOS/release/lib/cmake"
      },
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Darwin"
      }
    },
    {
      "name": "debug-macOS",
      "description": "",
      "inherits": ["debug", "release-macOS"],
      "cacheVariables": {
        "CMAKE_PREFIX_PATH": "$env{TVP_PUBLIBS}/_install/macOS/debug/lib/cmake"
      }
    },
    {
      "name": "release-iOS",
      "description": "",
      "inherits": ["release"],
      "generator": "Xcode",
      "toolchainFile": "${sourceDir}/cmake/toolchains/iOS.cmake",
      "cacheVariables": {
        "CMAKE_PREFIX_PATH": "$env{TVP_PUBLIBS}/_install/iOS/release/lib/cmake"
      },
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Darwin"
      }
    },
    {
      "name": "debug-iOS",
      "description": "",
      "inherits": ["debug", "release-iOS"],
      "generator": "Xcode",
      "cacheVariables": {
        "CMAKE_PREFIX_PATH": "$env{TVP_PUBLIBS}/_install/iOS/debug/lib/cmake"
      }
    }
  ]
}

```

and here are the toolchains:

- macOS.cmake:

```cmake
set(XXX_PLATFORM "macOS")
set(XXX_PLATFORM_MACOS ON)

```

- iOS.cmake:

```cmake
set(CMAKE_SYSTEM_NAME iOS)
set(CMAKE_OSX_ARCHITECTURES)
set(CMAKE_OSX_DEPLOYMENT_TARGET)

set(XXX_PLATFORM "iOS")
set(XXX_PLATFORM_IOS ON)

```

When I configure my project with the debug-macOS presets for example, everything works fine:

```auto
❯ cmake --preset=debug-macOS --fresh
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  CMAKE_MODULE_PATH="/Users/naubry/xxxx/NextVersion/yyy/cmake/modules"
  CMAKE_PREFIX_PATH="/Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake"
  CMAKE_TOOLCHAIN_FILE:FILEPATH="/Users/naubry/xxx/NextVersion/yyy/cmake/toolchains/macOS.cmake"
  CMAKE_VERBOSE_MAKEFILE="ON"

-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/opt/ccache/libexec/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The constant TVP_ALPHA is set to 1
-- Project Dependencies
-- Found fmt: /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/fmt/fmt-config.cmake (found version "9.0.0")
-- Found nlohmann_json: /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found version "3.10.5") 
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found spdlog: /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/spdlog/spdlogConfig.cmake (found version "1.10.0")
-- Found tinyxml2: /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/tinyxml2/tinyxml2-config.cmake (found version "9.0.0")
-- Project Dependencies - all components found
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/naubry/xxx/NextVersion/yyy/.build/debug-macOS

```

But when I configure my project for iOS then it does not find the libraries even though they are present:

```auto
❯ cmake --preset=debug-iOS --fresh
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  CMAKE_MODULE_PATH="/Users/naubry/xxx/NextVersion/yyy/cmake/modules"
  CMAKE_PREFIX_PATH="/Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake"
  CMAKE_TOOLCHAIN_FILE:FILEPATH="/Users/naubry/xxx/NextVersion/yyy/cmake/toolchains/iOS.cmake"
  CMAKE_VERBOSE_MAKEFILE="ON"

-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The constant TVP_ALPHA is set to 1
-- Project Dependencies
CMake Error at cmake/utilities/ProjectDependencies.cmake:13 (find_package):
  By not providing "Findfmt.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "fmt", but
  CMake did not find one.

  Could not find a package configuration file provided by "fmt" with any of
  the following names:

    fmtConfig.cmake
    fmt-config.cmake

  Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set "fmt_DIR"
  to a directory containing one of the above files. If "fmt" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:62 (include_project_dependencies)

-- Configuring incomplete, errors occurred!
See also "/Users/naubry/xxx/NextVersion/yyy/.build/debug-iOS/CMakeFiles/CMakeOutput.log".

```

What is quite strange is that if I do not set the variable `set(CMAKE_SYSTEM_NAME iOS)` with iOS but with nothing like this `set(CMAKE_SYSTEM_NAME)` then in this case no more worries but the configuration will not be good logically, so it is a problem …

```auto
❯ cmake --preset=debug-iOS --fresh
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  CMAKE_MODULE_PATH="/Users/naubry/xxx/NextVersion/yyy/cmake/modules"
  CMAKE_PREFIX_PATH="/Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake"
  CMAKE_TOOLCHAIN_FILE:FILEPATH="/Users/naubry/xxx/NextVersion/yyy/cmake/toolchains/iOS.cmake"
  CMAKE_VERBOSE_MAKEFILE="ON"

-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The constant TVP_ALPHA is set to 1
-- Project Dependencies
-- Found fmt: /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/fmt/fmt-config.cmake (found version "9.0.0")
-- Found nlohmann_json: /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/nlohmann_json/nlohmann_jsonConfig.cmake (found version "3.10.5") 
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found spdlog: /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/spdlog/spdlogConfig.cmake (found version "1.10.0")
-- Found tinyxml2: /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/tinyxml2/tinyxml2-config.cmake (found version "9.0.0")
-- Project Dependencies - all components found
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_BUILD_TYPE

-- Build files have been written to: /Users/naubry/xxx/NextVersion/yyy/.build/debug-iOS

```

---

<div class="post-metadata">

### Author: ![DrAuraHxC](https://discourse.cmake.org/user_avatar/discourse.cmake.org/draurahxc/32/2827_2.png) [@DrAuraHxC](https://discourse.cmake.org/u/DrAuraHxC)
#### Post date: [October 12, 2022, 10:05am UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/2 "2022-10-12T10:05:17Z")

</div>

If I am more explicit about the path for the configuration files for iOS Preset, it seems to work but why in all other presets `"CMAKE_PREFIX_PATH": "..."` is sufficient and for iOS it’s stuck?!

```auto
{
      "name": "release-iOS",
      "description": "",
      "inherits": ["release"],
      "generator": "Xcode",
      "toolchainFile": "${sourceDir}/cmake/toolchains/iOS.cmake",
      "cacheVariables": {
        "CMAKE_SYSTEM_NAME": "iOS",
        "CMAKE_OSX_ARCHITECTURES": "arm64;x86_64",
        "CMAKE_PREFIX_PATH": "$env{TVP_PUBLIBS}/_install/iOS/release/lib/cmake",
        "fmt_DIR": "$env{TVP_PUBLIBS}/_install/iOS/release/lib/cmake/fmt",
        "nlohmann_json_DIR": "$env{TVP_PUBLIBS}/_install/iOS/release/lib/cmake/nlohmann_json",
        "spdlog_DIR": "$env{TVP_PUBLIBS}/_install/iOS/release/lib/cmake/spdlog",
        "tinyxml2_DIR": "$env{TVP_PUBLIBS}/_install/iOS/release/lib/cmake/tinyxml2"
      },
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Darwin"
      }
    },
    {
      "name": "debug-iOS",
      "description": "",
      "inherits": ["debug", "release-iOS"],
      "generator": "Xcode",
      "cacheVariables": {
        "CMAKE_PREFIX_PATH": "$env{TVP_PUBLIBS}/_install/iOS/debug/lib/cmake",
        "fmt_DIR": "$env{TVP_PUBLIBS}/_install/iOS/debug/lib/cmake/fmt",
        "nlohmann_json_DIR": "$env{TVP_PUBLIBS}/_install/iOS/debug/lib/cmake/nlohmann_json",
        "spdlog_DIR": "$env{TVP_PUBLIBS}/_install/iOS/debug/lib/cmake/spdlog",
        "tinyxml2_DIR": "$env{TVP_PUBLIBS}/_install/iOS/debug/lib/cmake/tinyxml2"
      }
    }

```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 16, 2022, 2:33pm UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/3 "2022-10-16T14:33:48Z")

</div>

I think using `--find-debug` might be able to help here. Maybe CMake’s iOS search paths need updated?

Though…`CMAKE_PREFIX_PATH` should probably drop the `lib/cmake` suffix. Does it work if you do that?

---

<div class="post-metadata">

### Author: ![DrAuraHxC](https://discourse.cmake.org/user_avatar/discourse.cmake.org/draurahxc/32/2827_2.png) [@DrAuraHxC](https://discourse.cmake.org/u/DrAuraHxC)
#### Post date: [October 17, 2022, 7:13am UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/4 "2022-10-17T07:13:22Z")

</div>

First of all, thank you for your answer.

If I remove `lib/cmake` from the path of CMAKE\_PREFIX\_PATH exactly the same thing happens.

```auto
❯ cmake --preset=debug-iOS --fresh
Preset CMake variables:

  CMAKE_BUILD_TYPE="Debug"
  CMAKE_MODULE_PATH="/Users/naubry/xxx/NextVersion/yyy/cmake/modules"
  CMAKE_PREFIX_PATH="/Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug"
  CMAKE_TOOLCHAIN_FILE:FILEPATH="/Users/naubry/xxx/NextVersion/yyy/cmake/toolchains/iOS.cmake"
  CMAKE_VERBOSE_MAKEFILE="ON"

-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The constant TVP_ALPHA is set to 1
-- Project Dependencies
CMake Error at cmake/utilities/ProjectDependencies.cmake:13 (find_package):
  By not providing "Findfmt.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "fmt", but
  CMake did not find one.

  Could not find a package configuration file provided by "fmt" with any of
  the following names:

    fmtConfig.cmake
    fmt-config.cmake

  Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set "fmt_DIR"
  to a directory containing one of the above files. If "fmt" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:62 (include_project_dependencies)

-- Configuring incomplete, errors occurred!

```

EDIT : I found `--debug-find` – I’m going to do a test

This is what the debug gives me:

```auto
CMake Debug Log at cmake/utilities/ProjectDependencies.cmake:13 (find_package):
  find_package considered the following paths for Findfmt.cmake:

    /Users/naubry/xxx/NextVersion/yyy/cmake/modules/Findfmt.cmake
    /Users/naubry/xxx/NextVersion/yyy/cmake/Findfmt.cmake
    /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/Findfmt.cmake

  The file was not found.

    /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/fmt/fmtConfig.cmake
    /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/fmt/fmt-config.cmake

Call Stack (most recent call first):
  CMakeLists.txt:62 (include_project_dependencies)

CMake Debug Log at cmake/utilities/ProjectDependencies.cmake:17 (find_package):
  find_package considered the following paths for Findnlohmann_json.cmake:

    /Users/naubry/xxx/NextVersion/yyy/cmake/modules/Findnlohmann_json.cmake
    /Users/naubry/xxx/NextVersion/yyy/cmake/Findnlohmann_json.cmake
    /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/Findnlohmann_json.cmake

  The file was not found.

    /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/nlohmann_json/nlohmann_jsonConfig.cmake

Call Stack (most recent call first):
  CMakeLists.txt:62 (include_project_dependencies)

CMake Debug Log at /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/spdlog/spdlogConfig.cmake:30 (find_package):
  find_package considered the following paths for FindThreads.cmake:

    /Users/naubry/xxx/NextVersion/yyy/cmake/modules/FindThreads.cmake
    /Users/naubry/xxx/NextVersion/yyy/cmake/FindThreads.cmake

  The file was found at

    /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/FindThreads.cmake

Call Stack (most recent call first):
  cmake/utilities/ProjectDependencies.cmake:20 (find_package)
  CMakeLists.txt:62 (include_project_dependencies)

CMake Debug Log at /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
    /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/fmt/fmtConfig.cmake
    /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/fmt/fmt-config.cmake

Call Stack (most recent call first):
  /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/spdlog/spdlogConfig.cmake:38 (find_dependency)
  cmake/utilities/ProjectDependencies.cmake:20 (find_package)
  CMakeLists.txt:62 (include_project_dependencies)

CMake Debug Log at cmake/utilities/ProjectDependencies.cmake:20 (find_package):
  find_package considered the following paths for Findspdlog.cmake:

    /Users/naubry/xxx/NextVersion/yyy/cmake/modules/Findspdlog.cmake
    /Users/naubry/xxx/NextVersion/yyy/cmake/Findspdlog.cmake
    /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/Findspdlog.cmake

  The file was not found.

    /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/spdlog/spdlogConfig.cmake

Call Stack (most recent call first):
  CMakeLists.txt:62 (include_project_dependencies)

CMake Debug Log at cmake/utilities/ProjectDependencies.cmake:24 (find_package):
  find_package considered the following paths for Findtinyxml2.cmake:

    /Users/naubry/xxx/NextVersion/yyy/cmake/modules/Findtinyxml2.cmake
    /Users/naubry/xxx/NextVersion/yyy/cmake/Findtinyxml2.cmake
    /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/Findtinyxml2.cmake

  The file was not found.

    /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/tinyxml2/tinyxml2Config.cmake
    /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake/tinyxml2/tinyxml2-config.cmake

Call Stack (most recent call first):
  CMakeLists.txt:62 (include_project_dependencies)

```

I have trouble understanding why it doesn’t find… I have the impression for example for spdlog that it goes into the config file because it searches for Thread but then it tells me that it doesn’t find the spdlog config file…

---

<div class="post-metadata">

### Author: ![DrAuraHxC](https://discourse.cmake.org/user_avatar/discourse.cmake.org/draurahxc/32/2827_2.png) [@DrAuraHxC](https://discourse.cmake.org/u/DrAuraHxC)
#### Post date: [October 17, 2022, 9:19am UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/5 "2022-10-17T09:19:40Z")

</div>

This is how CMake behaves in another configuration.  
It’s interesting to see that it will actually configure itself with other variables like `CMAKE_PREFIX_PATH` / `CMAKE_FIND_USE_CMAKE_PATH` – which it obviously doesn’t do at all in iOS configuration.

```auto
CMake Debug Log at cmake/utilities/ProjectDependencies.cmake:13 (find_package):
  find_package considered the following paths for Findfmt.cmake:

    /Users/naubry/xxx/NextVersion/yyy/cmake/modules/Findfmt.cmake
    /Users/naubry/xxx/NextVersion/yyy/cmake/Findfmt.cmake
    /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/Findfmt.cmake

  The file was not found.

  The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR.

    /Users/naubry/xxx/NextVersion/yyy/.build/macOS/debug/CMakeFiles/pkgRedirects

  <PackageName>_ROOT CMake variable [CMAKE_FIND_USE_PACKAGE_ROOT_PATH].

    none

  CMAKE_PREFIX_PATH variable [CMAKE_FIND_USE_CMAKE_PATH].

    /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables
  [CMAKE_FIND_USE_CMAKE_PATH].

  Env variable fmt_DIR [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_PREFIX_PATH env variable [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables
  [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  Paths specified by the find_package HINTS option.

    none

  Standard system environment variables
  [CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].

    /Users/naubry/.local
    /Users/naubry/Flutter
    /usr/local/opt/ccache/libexec
    /Users/naubry/.cargo
    /usr/local
    /usr
    /
    /Library/Apple/usr

  CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].

    none

  CMake variables defined in the Platform file
  [CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].

    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr
    /usr/local/Cellar/cmake/3.24.2
    /usr/X11R6
    /usr/pkg
    /opt
    /sw
    /opt/local
    /Users/naubry/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/Network/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Library/Frameworks
    /Library/Frameworks
    /Network/Library/Frameworks
    /System/Library/Frameworks
    /Users/naubry/Applications
    /Applications
    /Applications/Xcode.app/Contents/Applications
    /Applications/Xcode.app/Contents/Developer/Applications

  CMake System Package Registry
  [CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].

    none

  Paths specified by the find_package PATHS option.

    none

  find_package considered the following locations for fmt's Config module:

    /Users/naubry/xxx/NextVersion/yyy/.build/macOS/debug/CMakeFiles/pkgRedirects/fmtConfig.cmake
    /Users/naubry/xxx/NextVersion/yyy/.build/macOS/debug/CMakeFiles/pkgRedirects/fmt-config.cmake
    /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/fmtConfig.cmake
    /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/fmt-config.cmake
    /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/fmt/fmtConfig.cmake
    /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/fmt/fmt-config.cmake

  The file was found at

    /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/fmt/fmt-config.cmake

Call Stack (most recent call first):
  CMakeLists.txt:62 (include_project_dependencies)

-- Found fmt: /Users/naubry/xxx/NextVersion/publibs/_install/macOS/debug/lib/cmake/fmt/fmt-config.cmake (found version "9.1.0")

```

---

<div class="post-metadata">

### Author: ![DrAuraHxC](https://discourse.cmake.org/user_avatar/discourse.cmake.org/draurahxc/32/2827_2.png) [@DrAuraHxC](https://discourse.cmake.org/u/DrAuraHxC)
#### Post date: [October 17, 2022, 9:29am UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/6 "2022-10-17T09:29:37Z")

</div>

Sorry if my answers are completely disjointed…

Okay, so if we really want to draw a parallel with a working configuration here’s what’s going on with the iOS configuration:

```auto
-- Project Dependencies
CMake Error at cmake/utilities/ProjectDependencies.cmake:13 (find_package):
  By not providing "Findfmt.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "fmt", but
  CMake did not find one.

  Could not find a package configuration file provided by "fmt" with any of
  the following names:

    fmtConfig.cmake
    fmt-config.cmake

  Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set "fmt_DIR"
  to a directory containing one of the above files. If "fmt" provides a
  separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
  CMakeLists.txt:62 (include_project_dependencies)

CMake Debug Log at cmake/utilities/ProjectDependencies.cmake:13 (find_package):
  find_package considered the following paths for Findfmt.cmake:

    /Users/naubry/xxx/NextVersion/yyy/cmake/modules/Findfmt.cmake
    /Users/naubry/xxx/NextVersion/yyy/cmake/Findfmt.cmake
    /usr/local/Cellar/cmake/3.24.2/share/cmake/Modules/Findfmt.cmake

  The file was not found.

  The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR.

    /Users/naubry/xxx/NextVersion/yyy/.build/debug-iOS/CMakeFiles/pkgRedirects

  <PackageName>_ROOT CMake variable [CMAKE_FIND_USE_PACKAGE_ROOT_PATH].

    none

  CMAKE_PREFIX_PATH variable [CMAKE_FIND_USE_CMAKE_PATH].

    /Users/naubry/xxx/NextVersion/publibs/_install/iOS/debug/lib/cmake

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables
  [CMAKE_FIND_USE_CMAKE_PATH].

  Env variable fmt_DIR [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_PREFIX_PATH env variable [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables
  [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].

    none

  Paths specified by the find_package HINTS option.

    none

  Standard system environment variables
  [CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].

    /Users/naubry/.local
    /Users/naubry/Flutter
    /usr/local/opt/ccache/libexec
    /Users/naubry/.cargo
    /usr/local
    /usr
    /
    /Library/Apple/usr

  CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].

    none

  CMake variables defined in the Platform file
  [CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/usr
    /usr/local/Cellar/cmake/3.24.2
    /usr/X11R6
    /usr/pkg
    /opt
    /sw
    /opt/local
    /Users/naubry/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/Network/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/System/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks
    /Applications/Xcode.app/Contents/Developer/Library/Frameworks
    /Library/Frameworks
    /Network/Library/Frameworks
    /System/Library/Frameworks
    /Users/naubry/Applications
    /Applications
    /Applications/Xcode.app/Contents/Applications
    /Applications/Xcode.app/Contents/Developer/Applications

  CMake System Package Registry
  [CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].

    none

  Paths specified by the find_package PATHS option.

    none

  find_package considered the following locations for fmt's Config module:

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/usr/fmtConfig.cmake
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/usr/fmt-config.cmake
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/fmtConfig.cmake
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/fmt-config.cmake
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/usr/fmtConfig.cmake
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/usr/fmt-config.cmake
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/System/Library/Frameworks/fmtConfig.cmake
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/System/Library/Frameworks/fmt-config.cmake
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/System/Library/Frameworks/fmtConfig.cmake
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.0.sdk/System/Library/Frameworks/fmt-config.cmake

  The file was not found.

Call Stack (most recent call first):
  CMakeLists.txt:62 (include_project_dependencies)

-- Configuring incomplete, errors occurred!
See also "/Users/naubry/xxx/NextVersion/yyy/.build/debug-iOS/CMakeFiles/CMakeOutput.log".

```

So we can see at the end that it drops completely the search in the path stipulated in CMAKE\_PREFIX\_PATH unlike the functional configuration in a previous message.

So it is normal that it does not find because it does not go in the folder informed to seek the configuration files. Now the question is, why this behavior?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [October 17, 2022, 12:03pm UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/7 "2022-10-17T12:03:32Z")

</div>

@brad.king Do you know much about this (or who would know)? @gjasny maybe?

---

<div class="post-metadata">

### Author: ![DrAuraHxC](https://discourse.cmake.org/user_avatar/discourse.cmake.org/draurahxc/32/2827_2.png) [@DrAuraHxC](https://discourse.cmake.org/u/DrAuraHxC)
#### Post date: [October 24, 2022, 9:31am UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/8 "2022-10-24T09:31:05Z")

</div>

Do you have any feedback for me on this?  
Thanks in advance.

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [November 15, 2022, 2:57pm UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/9 "2022-11-15T14:57:55Z")

</div>

@DrAuraHxC the posted example is not complete enough for us to try locally. It would help a lot if you can create a standalone and complete example demonstrating the problem.

Meanwhile I’ll take a guess:

> [@DrAuraHxC](#):
>
> in all other presets `"CMAKE_PREFIX_PATH": "..."` is sufficient and for iOS it’s stuck?!

When `CMAKE_SYSTEM_NAME` is `iOS`, search behavior is affected by [this code path](https://gitlab.kitware.com/cmake/cmake/-/blob/v3.24.3/Modules/Platform/Darwin.cmake#L3-18) that sets `CMAKE_FIND_ROOT_PATH_MODE_PACKAGE` to `ONLY`. That may affect whether/how the values in `CMAKE_PREFIX_PATH` are considered by `find_package`.

---

<div class="post-metadata">

### Author: ![DrAuraHxC](https://discourse.cmake.org/user_avatar/discourse.cmake.org/draurahxc/32/2827_2.png) [@DrAuraHxC](https://discourse.cmake.org/u/DrAuraHxC)
#### Post date: [November 16, 2022, 2:54pm UTC](https://discourse.cmake.org/t/cmake-presets-toolchain-for-ios-problem-to-find-libs-with-find-package/6642/10 "2022-11-16T14:54:10Z")

</div>

If I add this line to my presets file for iOS, my external libraries are indeed discovered again:  
`"CMAKE_FIND_ROOT_PATH_MODE_PACKAGE": "BOTH"`

Thanks for the answer 🙂
