CMake + Presets/Toolchain for iOS - Problem to find libs with find_package

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:

"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:
    set(XXX_PLATFORM "macOS")
    set(XXX_PLATFORM_MACOS ON)
    
  • iOS.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:

❯ 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:

❯ 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 …

❯ 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

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?!

{
      "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"
      }
    }

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?

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.

❯ 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:

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…

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.

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")

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:

-- 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?

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

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

@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:

When CMAKE_SYSTEM_NAME is iOS, search behavior is affected by this code path 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.

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 :slight_smile: