question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Subdirectory conan_cmake_run fails after most recent changes

See original GitHub issue

Reverting to previous versions of conan.cmake fixes the problem. The problem looks to be introduced by commit 8674d123b6222892467c5c62b5ee3fa69a081867.

I have a structure basically like this:

ProjectRoot/
  | CMakeLists.txt
  | conanfile.py
  | Tests/
    | CMakeLists.txt
    | conanfile.py

For simplicity, the CMakeLists and conanfiles are basically identical in the two directories. The top-level CMakeLists.txt looks like this:

project(MyProject)

set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)

if (NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
   message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
   file(DOWNLOAD 
        "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
        "${CMAKE_BINARY_DIR}/conan.cmake")
endif()

include(${CMAKE_BINARY_DIR}/conan.cmake)

conan_cmake_run(CONANFILE conanfile.py
                BASIC_SETUP CMAKE_TARGETS
                BUILD missing
                SETTINGS os=Windows
                )

add_subdirectory(Tests)

The Tests/ CMakeLists does the same conan_cmake_run. The conanfile is very simple, it doesn’t really require anything except the os setting (my real example is more complicated, but even this version is broken).

from conans import ConanFile
class TestConanFile(ConanFile):
   settings = 'os'

After all of this, opening the ProjectRoot directory in Visual Studio and letting it run its CMake configuration step gives me the following output:

1> CMake generation started for default configuration: 'x64-Debug (default)'.
1> Command line: "cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PREVIEW\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\ConanIssue\out\install\x64-Debug (default)" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Preview/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Preview/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PREVIEW\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\work\ConanIssue" 2>&1"
1> Working directory: C:\work\ConanIssue\out\build\x64-Debug (default)
1> [CMake] -- Conan: Automatic detection of conan settings from cmake
1> [CMake] -- Conan: Detected VS runtime: MDd
1> [CMake] -- Conan: os was added as an argument. Not using the autodetected one.
1> [CMake] -- Conan: Settings= -s;arch=x86_64;-s;build_type=Debug;-s;compiler=Visual Studio;-s;compiler.version=16;-s;compiler.runtime=MDd;-s;os=Windows
1> [CMake] -- Conan: checking conan executable
1> [CMake] -- Conan: Found program C:/Users/jacorice/AppData/Local/Programs/Python/Python37/Scripts/conan.exe
1> [CMake] -- Conan: Version found Conan version 1.32.1
1> [CMake] 
1> [CMake] -- Conan executing: C:/Users/jacorice/AppData/Local/Programs/Python/Python37/Scripts/conan.exe install C:/work/ConanIssue/conanfile.py -s arch=x86_64 -s build_type=Debug -s compiler=Visual Studio -s compiler.version=16 -s compiler.runtime=MDd -s os=Windows -g=cmake --build=missing
1> [CMake] Configuration:
1> [CMake] [settings]
1> [CMake] arch=x86_64
1> [CMake] arch_build=x86_64
1> [CMake] build_type=Debug
1> [CMake] compiler=Visual Studio
1> [CMake] compiler.runtime=MDd
1> [CMake] compiler.version=16
1> [CMake] os=Windows
1> [CMake] os_build=Windows
1> [CMake] [options]
1> [CMake] [build_requires]
1> [CMake] [env]
1> [CMake] 
1> [CMake] conanfile.py: Installing package
1> [CMake] Requirements
1> [CMake] Packages
1> [CMake] 
1> [CMake] Installing (downloading, building) binaries...
1> [CMake] conanfile.py: Generator cmake created conanbuildinfo.cmake
1> [CMake] conanfile.py: Generator txt created conanbuildinfo.txt
1> [CMake] conanfile.py: Generated conaninfo.txt
1> [CMake] conanfile.py: Generated graphinfo
1> [CMake] -- Conan: Loading conanbuildinfo.cmake
1> [CMake] -- Conan: Adjusting output directories
1> [CMake] -- Conan: Using cmake targets configuration
1> [CMake] -- Conan: Adjusting default RPATHs Conan policies
1> [CMake] -- Conan: Adjusting language standard
1> [CMake] -- Current conanbuildinfo.cmake directory: C:/work/ConanIssue/out/build/x64-Debug (default)
1> [CMake] -- WARN: CONAN_COMPILER variable not set, please make sure yourself that your compiler and version matches your declared settings
1> [CMake] -- Conan: Automatic detection of conan settings from cmake
1> [CMake] -- Conan: Detected VS runtime: MDd
1> [CMake] -- Conan: os was added as an argument. Not using the autodetected one.
1> [CMake] -- Conan: Settings= -s;arch=x86_64;-s;build_type=Debug;-s;compiler=Visual Studio;-s;compiler.version=16;-s;compiler.runtime=MDd;-s;os=Windows
1> [CMake] -- Conan: checking conan executable
1> [CMake] -- Conan: Found program C:/Users/jacorice/AppData/Local/Programs/Python/Python37/Scripts/conan.exe
1> [CMake] -- Conan: Version found Conan version 1.32.1
1> [CMake] 
1> [CMake] CMake Warning (dev) at out/build/x64-Debug (default)/conan.cmake:566 (elseif):
1> [CMake]   Policy CMP0054 is not set: Only interpret if() arguments as variables or
1> [CMake]   keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
1> [CMake]   details.  Use the cmake_policy command to set the policy and suppress this
1> [CMake]   warning.
1> [CMake] 
1> [CMake]   Quoted variables like "BUILD" will no longer be dereferenced when the
1> [CMake]   policy is set to NEW.  Since the policy is not set the OLD behavior will be
1> [CMake]   used.
1> [CMake] Call Stack (most recent call first):
1> [CMake]   out/build/x64-Debug (default)/conan.cmake:755 (_conan_cmake_install)
1> [CMake]   Tests/CMakeLists.txt:5 (conan_cmake_run)
1> [CMake] This warning is for project developers.  Use -Wno-dev to suppress it.
1> [CMake] CMake Warning (dev) at out/build/x64-Debug (default)/conan.cmake:595 (if):
1> [CMake]   Policy CMP0054 is not set: Only interpret if() arguments as variables or
1> [CMake]   keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
1> [CMake]   details.  Use the cmake_policy command to set the policy and suppress this
1> [CMake]   warning.
1> [CMake] 
1> [CMake]   Quoted variables like "BUILD" will no longer be dereferenced when the
1> [CMake]   policy is set to NEW.  Since the policy is not set the OLD behavior will be
1> [CMake]   used.
1> [CMake] Call Stack (most recent call first):
1> [CMake]   out/build/x64-Debug (default)/conan.cmake:755 (_conan_cmake_install)
1> [CMake]   Tests/CMakeLists.txt:5 (conan_cmake_run)
1> [CMake] This warning is for project developers.  Use -Wno-dev to suppress it.
1> [CMake] -- Conan executing: C:/Users/jacorice/AppData/Local/Programs/Python/Python37/Scripts/conan.exe install --build missing --settings -s --settings arch=x86_64 --settings -s --settings build_type=Debug --settings -s --settings compiler=Visual Studio --settings -s --settings compiler.version=16 --settings -s --settings compiler.runtime=MDd --settings -s --settings os=Windows --settings CONANFILE --settings conanfile.py --settings BASIC_SETUP --settings CMAKE_TARGETS --settings os=Windows
1> [CMake] usage: conan install [-h] [-g GENERATOR] [-if INSTALL_FOLDER] [-m [MANIFESTS]]
1> [CMake]                      [-mi [MANIFESTS_INTERACTIVE]] [-v [VERIFY]]
1> [CMake]                      [--no-imports] [-j JSON] [-b [BUILD]] [-r REMOTE] [-u]
1> [CMake]                      [-l LOCKFILE] [--lockfile-out LOCKFILE_OUT] [-e ENV_HOST]
1> [CMake]                      [-e:b ENV_BUILD] [-e:h ENV_HOST] [-o OPTIONS_HOST]
1> [CMake]                      [-o:b OPTIONS_BUILD] [-o:h OPTIONS_HOST]
1> [CMake]                      [-pr PROFILE_HOST] [-pr:b PROFILE_BUILD]
1> [CMake]                      [-pr:h PROFILE_HOST] [-s SETTINGS_HOST]
1> [CMake]                      [-s:b SETTINGS_BUILD] [-s:h SETTINGS_HOST]
1> [CMake]                      [--lockfile-node-id LOCKFILE_NODE_ID]
1> [CMake]                      path_or_reference [reference]
1> [CMake] conan install: error: argument -s/--settings: expected 1 argument
1> [CMake] ERROR: Exiting with code: 2
1> [CMake] CMake Error at out/build/x64-Debug (default)/conan.cmake:628 (message):
1> [CMake]   Conan install failed='2'
1> [CMake] Call Stack (most recent call first):
1> [CMake]   out/build/x64-Debug (default)/conan.cmake:755 (_conan_cmake_install)
1> [CMake]   Tests/CMakeLists.txt:5 (conan_cmake_run)
1> [CMake] CMake Warning (dev) in C:\work\ConanIssue\CMakeLists.txt:
1> [CMake]   No cmake_minimum_required command is present.  A line of code such as
1> [CMake] 
1> [CMake]     cmake_minimum_required(VERSION 3.18)
1> [CMake] 
1> [CMake]   should be added at the top of the file.  The version specified may be lower
1> [CMake]   if you wish to support older CMake versions for this project.  For more
1> [CMake]   information run "cmake --help-policy CMP0000".
1> [CMake] This warning is for project developers.  Use -Wno-dev to suppress it.
1> [CMake] 
1> [CMake] -- Configuring incomplete, errors occurred!
1> [CMake] See also "C:/work/ConanIssue/out/build/x64-Debug (default)/CMakeFiles/CMakeOutput.log".
1> 'cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PREVIEW\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\ConanIssue\out\install\x64-Debug (default)" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Preview/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Preview/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PREVIEW\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\work\ConanIssue" 2>&1"' execution failed with error: ''cmd.exe' '/c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PREVIEW\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Ninja"  -DCMAKE_BUILD_TYPE:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\work\ConanIssue\out\install\x64-Debug (default)" -DCMAKE_C_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Preview/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe" -DCMAKE_CXX_COMPILER:FILEPATH="C:/Program Files (x86)/Microsoft Visual Studio/2019/Preview/VC/Tools/MSVC/14.28.29333/bin/Hostx64/x64/cl.exe"  -DCMAKE_MAKE_PROGRAM="C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2019\PREVIEW\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\Ninja\ninja.exe" "C:\work\ConanIssue" 2>&1"' returned with exit code: 1'.

You can see that the conan install command for Tests/ is specifying settings like this: --settings -s --settings compiler.runtime=MDd, though the top-level version, which is identical, is correct.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
thegwyddcommented, Feb 26, 2021

I confirm it works for me too. Thank you!

1reaction
czoidocommented, Feb 25, 2021

Thank you for reporting! I’ll release a 0.16.1 as soon as the ci passes

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subdirectory conan_cmake_run fails after most recent changes
After all of this, opening the ProjectRoot directory in Visual Studio and letting it run its CMake configuration step gives me the following...
Read more >
conan create fails with can't find conanbuildinfo.cmake #249
I have been trying to use conan_cmake_run in my CMakeLists.txt files to allow conan to be run in the cmake configure step, such...
Read more >
Change working directory for conan imports command when ...
I run into a situation where I need to decouple the conan installation folder from the import root folder. The main goal is...
Read more >
CMake: Best Practices
CMake has a (AFAIK) unique version system. If a file start with this: Then CMake will set all policies (which cover all behavior...
Read more >
Conan Documentation - Conan Docs
Conan is a software package manager which is intended for C and C++ developers. Conan is universal and portable. It works in all...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found