[develop2, BUG] Unknown arguments specified in conan_provider.cmake:519
YanzhaoW opened this issue · 2 comments
YanzhaoW commented
Hello,
I'm trying to install conan packages using conan_provider. But I got the following error:
CMake Warning (dev) at conan_provider.cmake:519 (if):
Policy CMP0057 is not set: Support new IN_LIST if() operator. Run "cmake
--help-policy CMP0057" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
IN_LIST will be interpreted as an operator when the policy is set to NEW.
Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
CMakeLists.txt:5 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning (dev) at conan_provider.cmake:519 (if):
Policy CMP0057 is not set: Support new IN_LIST if() operator. Run "cmake
--help-policy CMP0057" for policy details. Use the cmake_policy command to
set the policy and suppress this warning.
IN_LIST will be interpreted as an operator when the policy is set to NEW.
Since the policy is not set the OLD behavior will be used.
Call Stack (most recent call first):
CMakeLists.txt:5 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at conan_provider.cmake:519 (if):
if given arguments:
"default" "IN_LIST" "CONAN_HOST_PROFILE" "OR" "default" "IN_LIST" "CONAN_BUILD_PROFILE"
Unknown arguments specified
Call Stack (most recent call first):
CMakeLists.txt:5 (find_package)
CMake Error at CMakeLists.txt:5 (find_package):
By not providing "Findsol2.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "sol2", but
CMake did not find one.
Could not find a package configuration file provided by "sol2" with any of
the following names:
sol2Config.cmake
sol2-config.cmake
Add the installation prefix of "sol2" to CMAKE_PREFIX_PATH or set
"sol2_DIR" to a directory containing one of the above files. If "sol2"
provides a separate development package or SDK, be sure it has been
installed.
command
cmake --preset default ..
CMakePresets.json
{
"version": 4,
"cmakeMinimumRequired": {
"major": 3,
"minor": 24,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default Config",
"description": "Default build using Ninja generator",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build/default",
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES": "conan_provider.cmake"
}
}
]
}
CMakeLists.txt
project(cppsol2)
cmake_minimum_required(VERSION 3.24)
find_package(sol2 REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PUBLIC sol2::sol2)
conanfile.txt
[requires]
sol2/3.3.1
[generators]
CMakeDeps
CMakeToolchain
[layout]
cmake_layout
Here are some version infos:
- cmake: 3.24.3
- conan: 2.0.17
- os: Debian GNU/Linux 10 (buster)
memsharded commented
Thanks for your report @YanzhaoW
It seems your CMakeLists.txt
is incorrect. The cmake_minimum_required()
must be before project()
.
Also, you will need to set the CXX standard, otherwise sol2 will fail, so something like:
cmake_minimum_required(VERSION 3.24)
project(cppsol2)
set(CMAKE_CXX_STANDARD 17)
find_package(sol2 REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PUBLIC sol2::sol2)
YanzhaoW commented
Thanks very much for your answer. @memsharded
Yes, putting cmake_minimum_required()
before project()
solves the issue.