Open elvisdukaj opened 3 months ago
Interesting: to fix the issue I had to remove the ninja and cmake from the tool requires. So with the following recipe:
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.env.virtualenv:powershell=False
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=193
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.env.virtualenv:powershell=False
It builds fine
Reporting the discussion from https://github.com/conan-io/conan/issues/16689#issuecomment-2233697696 for reference.
@memsharded replied with:
ninja: error: 'cmake_object_order_depends_target_yasmstd_DEBUG', needed by 'C:/Users/edukaj/.co
this would look like an issue in Ninja Multi-Config, because the Release configuration is being built but Ninja is looking for Debug somehow. Probably is not because of the [tool_requires], but because the change in tools.cmake.cmaketoolchain:generator=Ninja from Ninja Multi-Config
I confirm @memsharded assumption is correct: https://github.com/conan-io/conan/issues/16689#issuecomment-2235794753
This wouldn't be an issue of the Conan recipe, but an issue in the upstream CMakeLists.txt, defining the CMAKE_BUILD_TYPE, which will confuse the CMake Ninja Multi-Config generator, see https://github.com/yasm/yasm/blob/121ab150b3577b666c79a79f4a511798d7ad2432/CMakeLists.txt#L24
That CMakeLists.txt is apparently 10 years old, Ninja Multi-Config wasn't a thing back then, but it seems unlikely it will be fixed in the upstream if it hasn't been updated in 10 years.
I suspect that Ninja Multi-Config
would be an issue in many other packages in ConanCenter doing similar outdated practices, I am not sure it is worth fighting this battle.
I have tried to do a patch to remove the IF(NOT CMAKE_BUILD_TYPE)
logic completely, but it seems not enough, there might be something else in the build of the library that disallows using Ninja Multi-Config.
The following fixes it:
diff --git a/recipes/yasm/all/conanfile.py b/recipes/yasm/all/conanfile.py
index 7e50843bcd..de3dc02d90 100644
--- a/recipes/yasm/all/conanfile.py
+++ b/recipes/yasm/all/conanfile.py
@@ -1,7 +1,7 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
-from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
+from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir, replace_in_file
from conan.tools.gnu import Autotools, AutotoolsToolchain
from conan.tools.layout import basic_layout
from conan.tools.microsoft import is_msvc
@@ -49,6 +49,7 @@ class YASMConan(ConanFile):
def source(self):
get(self, **self.conan_data["sources"][self.version][0],
destination=self.source_folder, strip_root=True)
+ replace_in_file(self, "modules/CMakeLists.txt", "SET_SOURCE_FILES_PROPERTIES(init_plugin.c GENERATED)", "")
def _generate_autotools(self):
env = VirtualBuildEnv(self)
The problem is marking a file as GENERATED without adding the origin makes CMake + Ninja Multi-Config to introduce an apparently incorrect dependency on the different build-type targets: https://gitlab.kitware.com/cmake/cmake/-/issues/20608
From that ticket:
The purpose of those order-only dependencies is to say "nothing told CMake what generates this file, so we assume that something in one of the targets on which the target that compiles the source file depends will generate it". If we leave out the order-only dependencies, Ninja may try compiling the source file before it is generated.
To fix this, the "Assume dependencies for generated source file" section may need to be generated separately for each configuration. If that is too disruptive, I'd be okay with just telling projects they have to fix this to work with the new generator. The fix will improve behavior with plain Ninja too. It really is a case of needed dependency information not being provided to CMake.
Doing this would be a large change in yasm build scripts, probably not worth it.
Thank you @memsharded for the investigation! Yes probably the fix it's too invasive but we can submit a PR to the upstream project 😀
Description
I am trying to build yasm with msvc but I have build errors.
Package and Environment Details
Conan profile
======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=17 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows [tool_requires] *: ninja/1.11.1, cmake/3.28.1 [conf] tools.cmake.cmaketoolchain:generator=Ninja Multi-Config tools.env.virtualenv:powershell=False
Profile build: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=20 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows [conf] tools.cmake.cmaketoolchain:generator=Ninja tools.env.virtualenv:powershell=False
Steps to reproduce
conan create conan/center-index/recipes/yasm/all --version=1.3.0 --build=missing
Logs
Click to expand log
``` ======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=17 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows [tool_requires] *: ninja/1.11.1, cmake/3.28.1 [conf] tools.cmake.cmaketoolchain:generator=Ninja Multi-Config tools.env.virtualenv:powershell=False Profile build: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=20 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=193 os=Windows [conf] tools.cmake.cmaketoolchain:generator=Ninja tools.env.virtualenv:powershell=False ======== Computing dependency graph ======== Graph root cli Requirements yasm/1.3.0#f8b676849bfc7f0fb8c099374c4dd32e - Cache Build requirements cmake/3.28.1#6a1e0a2ffe43d562b8228c1a5aaaac61 - Cache ninja/1.11.1#cd30ca226f2040a979c359ebca4817d5 - Cache ======== Computing necessary packages ======== Requirements yasm/1.3.0#f8b676849bfc7f0fb8c099374c4dd32e:723257509aee8a72faf021920c2874abc738e029 - Build Build requirements cmake/3.28.1#6a1e0a2ffe43d562b8228c1a5aaaac61:522dcea5982a3f8a5b624c16477e47195da2f84f#29e6903b5006c2b2f81003c9ebf7551b - Cache ninja/1.11.1#cd30ca226f2040a979c359ebca4817d5:723257509aee8a72faf021920c2874abc738e029#1a592c653c6d8742bf921f77d92580f4 - Cache ======== Installing packages ======== cmake/3.28.1: Already installed! (1 of 3) cmake/3.28.1: Appending PATH environment variable: C:\Users\edukaj\.conan2\p\b\cmake658582c322d1b\p\bin cmake/3.28.1: Appending PATH environment variable: C:\Users\edukaj\.conan2\p\b\cmake658582c322d1b\p\bin ninja/1.11.1: Already installed! (2 of 3) yasm/1.3.0: Calling source() in C:\Users\edukaj\.conan2\p\yasm50c65a0373958\s\src -------- Installing package yasm/1.3.0 (3 of 3) -------- yasm/1.3.0: Building from source yasm/1.3.0: Package yasm/1.3.0:723257509aee8a72faf021920c2874abc738e029 yasm/1.3.0: Copying sources to build folder yasm/1.3.0: Building your package in C:\Users\edukaj\.conan2\p\b\yasm0a1497e8cfb40\b yasm/1.3.0: Calling generate() yasm/1.3.0: Generators folder: C:\Users\edukaj\.conan2\p\b\yasm0a1497e8cfb40\b\build\generators yasm/1.3.0: CMakeToolchain generated: conan_toolchain.cmake yasm/1.3.0: CMakeToolchain generated: C:\Users\edukaj\.conan2\p\b\yasm0a1497e8cfb40\b\build\generators\CMakePresets.json yasm/1.3.0: CMakeToolchain generated: C:\Users\edukaj\.conan2\p\b\yasm0a1497e8cfb40\b\src\CMakeUserPresets.json yasm/1.3.0: Generating aggregated env files yasm/1.3.0: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat'] yasm/1.3.0: Calling build() yasm/1.3.0: Apply patch (conan): CMake 3.0+ compatibility yasm/1.3.0: Running CMake.configure() yasm/1.3.0: RUN: cmake -G "Ninja Multi-Config" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/edukaj/.conan2/p/b/yasm0a1497e8cfb40/p" -DYASM_BUILD_TESTS="OFF" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:/Users/edukaj/.conan2/p/b/yasm0a1497e8cfb40/b/src" conanvcvars.bat: Activating environment Visual Studio 17 - amd64 - winsdk_version=None - vcvars_ver=14.3 [vcvarsall.bat] Environment initialized for: 'x64' CMake Deprecation Warning at CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED): Compatibility with CMake < 3.5 will be removed from a future version of CMake. Update the VERSION argument