Git Product home page Git Product logo

Comments (10)

memsharded avatar memsharded commented on August 17, 2024 1

Oh, I had no idea this was possible. What's the meaning this syntax? Is it aliasing Debug to MyBuildType? Does it create any conflicts with the actual Debug build type wrt binary revision resolution?

The & is a pattern, all settings, options, confs, can be specified per-package like <pattern>:setting=value, like options with *:shared=True for making all dependencies shared libraries (when defined). The & is a pattern for the current "consumer" project. If you have a conanfile.py and define a name = "consumer", it will be equivalent to something like consumer/*:build_type=Debug, and it works for whatever name and current consumer is.

This allows to explicitly define the intention: "the current project is a Debug project, but I want the dependencies built with MyBuildType instead. Because Conan supports even more advanced cases than CMake, and I have seen conditional requirements depending on the build_type to depend on different versions, and this is possible with the explicit definition of the build_type for different packages.

from conan.

memsharded avatar memsharded commented on August 17, 2024

Hi @sykhro

Thanks for your report and specially for the reproducer.

I am having a look.

First quick feedback:

include(out/conan_toolchain.cmake)

Please do not include toolchains from CMakeLists.txt. The toolchain must be passed externally with cmake ... -DCMAKE_TOOLCHAIN_FILE=....conan_toolchain.cmake. The behavior and the result is not the same.

If I run the above steps in Windows, I get:

fmt/10.2.1: Running CMake.configure()
fmt/10.2.1: RUN: cmake -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/memsharded/.conan2/p/b/fmtf6bf24ba447c7/p" -DFMT_DOC="OFF" -DFMT_TEST="OFF" -DFMT_INSTALL="ON" -DFMT_LIB_DIR="lib" -DFMT_OS="ON" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:\Users\memsharded\.conan2\p\b\fmtf6bf24ba447c7\b\src"
-- CMake version: 3.25.3
-- Using Conan toolchain: C:/Users/memsharded/.conan2/p/b/fmtf6bf24ba447c7/b/build/generators/conan_toolchain.cmake
-- Conan toolchain: CMAKE_GENERATOR_TOOLSET=v143
-- Conan toolchain: C++ Standard 14 with extensions OFF
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The CXX compiler identification is MSVC 19.38.33135.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Version: 10.2.1
-- Build type: Release
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/memsharded/.conan2/p/b/fmtf6bf24ba447c7/b/build

fmt/10.2.1: Running CMake.build()
fmt/10.2.1: RUN: cmake --build "C:\Users\memsharded\.conan2\p\b\fmtf6bf24ba447c7\b\build" --config MyBuildType
MSBuild version 17.9.8+b34f75857 for .NET Framework

C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.CppBuild.targets(452,5): error MSB8013: This project doesn't cont ain the Configuration and Platform combination of MyBuildType|x64. [C:\Users\memsharded\.conan2\p\b\fmtf6bf24ba447c7\b\build\ZERO_CHECK.vcxproj]

I am not sure why it works for you, maybe it is that in other OS, the build scripts of fmt are more permissive and will build even for an unknown build_type? Can you please share the logs of the building of fmt with the custom build-type?

from conan.

sykhro avatar sykhro commented on August 17, 2024

Please do not include toolchains from CMakeLists.txt. The toolchain must be passed externally with cmake ... -DCMAKE_TOOLCHAIN_FILE=....conan_toolchain.cmake. The behavior and the result is not the same.

Thanks, noted. However, in my actual usecase, I remove many blocks from the toolchain and only keep the search paths.

I am not sure why it works for you, maybe it is that in other OS, the build scripts of fmt are more permissive and will build even for an unknown build_type? Can you please share the logs of the building of fmt with the custom build-type?

Sorry, I forgot to mention, it needs Ninja Multi-Config (or a mess of custom Build.Props). I'm setting it in the profile for this toolchain. I have reproduced this:

  • compiling for Linux on Linux
  • compiling for Windows on Windows with clang-cl
  • compiling for thePlatform on Windows

from conan.

sykhro avatar sykhro commented on August 17, 2024

... the build scripts of fmt are more permissive and will build even for an unknown build_type?

It may come as a surprise but so far the most random recipes from conan-center have built fine with this build_type and 0 changes required to the packages themselves. In my experience of porting to cursed platforms, building dependencies has never been this painless :)

from conan.

memsharded avatar memsharded commented on August 17, 2024

With

conan install . -s:h "build_type=MyBuildType" -d full_deploy --deployer-folder=out --output-folder=out --build=missing -g CMakeToolchain -g CMakeDeps -c tools.cmake.cmaketoolchain:generator="Ninja Multi-Config"

[vcvarsall.bat] Environment initialized for: 'x64'
ninja: error: loading 'build-MyBuildType.ninja': The system cannot find the file specified.

It may come as a surprise but so far the most random recipes from conan-center have built fine with this build_type and 0 changes required to the packages themselves. In my experience of porting to cursed platforms, building dependencies has never been this painless :)

Yes, a bit surprising :)
Are you building for Windows too?

from conan.

sykhro avatar sykhro commented on August 17, 2024

With

conan install . -s:h "build_type=MyBuildType" -d full_deploy --deployer-folder=out --output-folder=out --build=missing -g CMakeToolchain -g CMakeDeps -c tools.cmake.cmaketoolchain:generator="Ninja Multi-Config"

[vcvarsall.bat] Environment initialized for: 'x64'
ninja: error: loading 'build-MyBuildType.ninja': The system cannot find the file specified.

It may come as a surprise but so far the most random recipes from conan-center have built fine with this build_type and 0 changes required to the packages themselves. In my experience of porting to cursed platforms, building dependencies has never been this painless :)

Yes, a bit surprising :) Are you building for Windows too?

I guess that the error is related to your profile being MSVC? For my Windows config, I have compiler=clang with the executable set to clang-cl.exe (I can't use MSVC unfortunately)

from conan.

memsharded avatar memsharded commented on August 17, 2024

Not really...

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=MyBuildType
compiler=clang
compiler.version=16
os=Windows
[tool_requires]
*: ninja/[*]
[conf]
tools.build:compiler_executables={'cpp': 'clang++', 'c': 'clang', 'rc': 'clang'}
tools.cmake.cmaketoolchain:generator=Ninja Multi-Config


-------- Installing package fmt/10.2.1 (2 of 2) --------
fmt/10.2.1: Building from source
fmt/10.2.1: Package fmt/10.2.1:b55c038de9aa058b59f069fa5be24860b9ace96c
fmt/10.2.1: Copying sources to build folder
..
fmt/10.2.1: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
fmt/10.2.1: Calling build()
fmt/10.2.1: apply_conandata_patches(): No patches defined in conandata
fmt/10.2.1: Running CMake.configure()
fmt/10.2.1: RUN: cmake -G "Ninja Multi-Config" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/memsharded/.conan2/p/b/fmtf7b8469784f80/p" -DFMT_DOC="OFF" -DFMT_TEST="OFF" -DFMT_INSTALL="ON" -DFMT_LIB_DIR="lib" -DFMT_OS="ON" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:\Users\memsharded\.conan2\p\b\fmtf7b8469784f80\b\src"
-- CMake version: 3.25.3
-- Using Conan toolchain: C:/Users/memsharded/.conan2/p/b/fmtf7b8469784f80/b/build/generators/conan_toolchain.cmake
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The CXX compiler identification is Clang 16.0.4 with GNU-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/ws/LLVM/clang16/bin/clang++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Version: 10.2.1
-- Build type: Release
-- Performing Test HAS_NULLPTR_WARNING
-- Performing Test HAS_NULLPTR_WARNING - Success
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/memsharded/.conan2/p/b/fmtf7b8469784f80/b/build

fmt/10.2.1: Running CMake.build()
fmt/10.2.1: RUN: cmake --build "C:\Users\memsharded\.conan2\p\b\fmtf7b8469784f80\b\build" --config MyBuildType -- -j8
ninja: error: loading 'build-MyBuildType.ninja': The system cannot find the file specified.

Not sure what could I be missing here.

from conan.

sykhro avatar sykhro commented on August 17, 2024

It's most likely thatCMAKE_CONFIGURATION_TYPES is not set correctly and CMake has generated build-Release.ninja and build-Debug.ninja. thePlatform toolchain file sets it; I didn't need to set it on Linux though (on the conan invocation at least). I can't test on Windows for a couple days now, but I imagine you could work it around with a small toolchain file in the profile?

from conan.

memsharded avatar memsharded commented on August 17, 2024

Sure, passing a user_toolchain defining CMAKE_CONFIGURATION_TYPES works to build fmt

Now the command:

cmake -B build -G "Ninja Multi-Config" -DCMAKE_CONFIGURATION_TYPES="MyBuildType;Release" && cmake --build build --config MyBuildType

Fails, and this is expected, because it is not being passed the -DCMAKE_TOOLCHAIN_FILE=....conan_toolchain.cmake.

I am using cmake --preset conan-default instead and it worked. Then cmake --build --preset conan-mybuildtype did manage to build the .exe successfully.

Then, I tried to uncomment the line, and indeed it failed.
It seems that Conan doesn't have enough information to handle this, but it can be passed. I made it work with profile:

[settings]
os=Windows
compiler=clang
compiler.version=16
build_type=MyBuildType
arch=x86_64
&:build_type=Debug

[conf]
tools.build:compiler_executables={"cpp": "clang++", "c": "clang", "rc": "clang"}
tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
tools.cmake.cmaketoolchain:user_toolchain+={{os.path.join(profile_dir, "mytypes.cmake")}}

[tool_requires]
ninja/[*]

[buildenv]
PATH+=(path)C:/ws/LLVM/clang16/bin

Then:

rm -rf build && conan install . --build=missing -pr=profile && cmake --preset conan-default && cmake --build --preset conan-debug

from conan.

sykhro avatar sykhro commented on August 17, 2024

&:build_type=Debug

Oh, I had no idea this was possible. What's the meaning this syntax? Is it aliasing Debug to MyBuildType? Does it create any conflicts with the actual Debug build type wrt binary revision resolution?

from conan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.