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