conan-io / cmake-conan

CMake wrapper for conan C and C++ package manager
MIT License
822 stars 250 forks source link

tools.build:compiler_executables breaks build with Autotools and Xcode #618

Closed Nekto89 closed 8 months ago

Nekto89 commented 8 months ago
git clone https://github.com/Nekto89/cmake-conan.git -b bug/xcode_compiler_location
cmake -GXcode -DCMAKE_CONFIGURATION_TYPES=Release -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=../conan_provider.cmake -B build -S cmake-conan/example
Click to expand log ``` -- The C compiler identification is AppleClang 14.0.0.14000029 -- The CXX compiler identification is AppleClang 14.0.0.14000029 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang - skipped -- Detecting C compile features -- Detecting C compile features - done -- 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 -- CMake-Conan: first find_package() found. Installing dependencies with Conan -- CMake-Conan: Checking if a default profile exists /Users/mklymov/.conan2/profiles/default -- CMake-Conan: cmake_system_name=Darwin -- CMake-Conan: cmake_osx_deployment_target= -- CMake-Conan: cmake_system_processor=armv8 -- CMake-Conan: CMake compiler=AppleClang -- CMake-Conan: CMake compiler version=14.0.0.14000029 -- CMake-Conan: [settings] compiler=apple-clang -- CMake-Conan: [settings] compiler.version=14 -- CMake-Conan: Creating profile /Users/mklymov/test/build/conan_host_profile -- CMake-Conan: Profile: [settings] arch=armv8 os=Macos compiler=apple-clang compiler.version=14 compiler.cppstd=14 compiler.libcxx=libc++ [conf] tools.cmake.cmaketoolchain:generator=Xcode tools.build:compiler_executables={"c":"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang","cpp":"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++"} CMake Warning at /Users/mklymov/test/cmake-conan/conan_provider.cmake:531 (message): Cmake-conan: CMakeDeps generator was not defined in the conanfile. Please define the generator as it will be mandatory in the future Call Stack (most recent call first): CMakeLists.txt:7 (find_package) -- CMake-Conan: Installing both Debug and Release -- CMake-Conan: conan install /Users/mklymov/test/cmake-conan/example -of=/Users/mklymov/test/build/conan --profile:host=default;--profile:host=/Users/mklymov/test/build/conan_host_profile;--profile:build=default;-s;build_type=Release;--build=missing;-g;CMakeDeps ======== Input profiles ======== Profile host: [settings] arch=armv8 build_type=Release compiler=apple-clang compiler.cppstd=14 compiler.libcxx=libc++ compiler.version=14 os=Macos [conf] tools.build:compiler_executables={'c': '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang', 'cpp': '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++'} tools.cmake.cmaketoolchain:generator=Xcode Profile build: [settings] arch=armv8 build_type=Release compiler=apple-clang compiler.cppstd=gnu17 compiler.libcxx=libc++ compiler.version=14 os=Macos ======== Computing dependency graph ======== Graph root conanfile.txt: /Users/mklymov/test/cmake-conan/example/conanfile.txt Requirements icu/71.1#fa0837c81e75f43c054bc31d28b272bd - Cache ======== Computing necessary packages ======== icu/71.1: Checking 11 compatible configurations icu/71.1: Main binary package '5e175a889e1c1ac8097f8563a63c9423b4f55411' missing. Using compatible package '1a6a1e4d73470a79e619194c99dfb00bdb04c50b': compiler.cppstd=17 Requirements icu/71.1#fa0837c81e75f43c054bc31d28b272bd:1a6a1e4d73470a79e619194c99dfb00bdb04c50b#4964e826a60cc34055c5bfe563c275f1 - Cache ======== Installing packages ======== icu/71.1: Already installed! (1 of 1) WARN: deprecated: Usage of deprecated Conan 1.X features that will be removed in Conan 2.X: WARN: deprecated: 'cpp_info.names' used in: icu/71.1 WARN: deprecated: 'env_info' used in: icu/71.1 ======== Finalizing install (deploy, generators) ======== conanfile.txt: Writing generators to /Users/mklymov/test/build/conan/build/generators conanfile.txt: Generator 'CMakeDeps' calling 'generate()' conanfile.txt: CMakeDeps necessary find_package() and targets for your CMakeLists.txt find_package(ICU) target_link_libraries(... icu::icu) conanfile.txt: Generating aggregated env files conanfile.txt: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh'] Install finished successfully -- CMake-Conan: CONAN_GENERATORS_FOLDER=/Users/mklymov/test/build/conan/build/generators -- CMake-Conan: CONANFILE=/Users/mklymov/test/cmake-conan/example/conanfile.txt -- CMake-Conan: conan install /Users/mklymov/test/cmake-conan/example -of=/Users/mklymov/test/build/conan --profile:host=default;--profile:host=/Users/mklymov/test/build/conan_host_profile;--profile:build=default;-s;build_type=Debug;--build=missing;-g;CMakeDeps ======== Input profiles ======== Profile host: [settings] arch=armv8 build_type=Debug compiler=apple-clang compiler.cppstd=14 compiler.libcxx=libc++ compiler.version=14 os=Macos [conf] tools.build:compiler_executables={'c': '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang', 'cpp': '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++'} tools.cmake.cmaketoolchain:generator=Xcode Profile build: [settings] arch=armv8 build_type=Release compiler=apple-clang compiler.cppstd=gnu17 compiler.libcxx=libc++ compiler.version=14 os=Macos ======== Computing dependency graph ======== Graph root conanfile.txt: /Users/mklymov/test/cmake-conan/example/conanfile.txt Requirements icu/71.1#fa0837c81e75f43c054bc31d28b272bd - Cache ======== Computing necessary packages ======== icu/71.1: Checking 11 compatible configurations icu/71.1: Compatible configurations not found in cache, checking servers icu/71.1: 'de89b97ad61d78d0306b73365a5484cf0cb5bf7c': compiler.cppstd=98 icu/71.1: '1c5e732a6b108e33d8d90cc24a0147f54e169d4a': compiler.cppstd=gnu98 icu/71.1: '74f3c1c1e529be34ec7a8cebf08a9b13da9c1875': compiler.cppstd=11 icu/71.1: '6348eb97c08cd8e89c6b8038e4da51d2573de809': compiler.cppstd=gnu11 icu/71.1: '663fb33f1e442aa89d6a3f4ea84985cbde244039': compiler.cppstd=gnu14 icu/71.1: '7838046809bc321d088d4e46cc55922c25014260': compiler.cppstd=17 icu/71.1: '291a0944e3ac2b9f14c6f3c9302d5c87ad5e5da1': compiler.cppstd=gnu17 icu/71.1: '0e373f1e8a3a02fb1cce860ef549f1f75aa420a5': compiler.cppstd=20 icu/71.1: '46e9408cd6b52154e6cd854cac94867450b3cd87': compiler.cppstd=gnu20 icu/71.1: '8c553ef36f5f2dcdfcbdc0f8136a657e97e2313d': compiler.cppstd=23 icu/71.1: 'af183789b52feef149b556c0534abbf8eecbdcba': compiler.cppstd=gnu23 Requirements icu/71.1#fa0837c81e75f43c054bc31d28b272bd:b4ce41c723ecbd444ee714da4099f9c6747e9cdb - Build ======== Installing packages ======== -------- Installing package icu/71.1 (1 of 1) -------- icu/71.1: Building from source icu/71.1: Package icu/71.1:b4ce41c723ecbd444ee714da4099f9c6747e9cdb icu/71.1: Copying sources to build folder icu/71.1: Building your package in /Users/mklymov/.conan2/p/b/icudebc37755934f/b icu/71.1: Calling generate() icu/71.1: Generators folder: /Users/mklymov/.conan2/p/b/icudebc37755934f/b/build-debug/conan icu/71.1: Generating aggregated env files icu/71.1: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh'] icu/71.1: Calling build() icu/71.1: Apply patch (file): patches/0001-69.1-fix-mingw.patch icu/71.1: Apply patch (file): patches/0001-71.1-fix-undef-strict-ansi.patch icu/71.1: Apply patch (portability): Add config file for wasm-emscripten platform icu/71.1: Calling: > "/Users/mklymov/.conan2/p/b/icudebc37755934f/b/src/source/configure" --disable-shared --enable-static --prefix=/ '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' '--libdir=${prefix}/lib' '--includedir=${prefix}/include' '--oldincludedir=${prefix}/include' '--datarootdir=${prefix}/lib' --enable-release=no --enable-debug=yes --enable-dyload=yes --enable-extras=no --enable-icuio=yes --disable-layoutex --disable-layout --enable-tools=yes --enable-tests=no --disable-samples --with-library-bits=64 --with-data-packaging=archive icu/71.1: RUN: "/Users/mklymov/.conan2/p/b/icudebc37755934f/b/src/source/configure" --disable-shared --enable-static --prefix=/ '--bindir=${prefix}/bin' '--sbindir=${prefix}/bin' '--libdir=${prefix}/lib' '--includedir=${prefix}/include' '--oldincludedir=${prefix}/include' '--datarootdir=${prefix}/lib' --enable-release=no --enable-debug=yes --enable-dyload=yes --enable-extras=no --enable-icuio=yes --disable-layoutex --disable-layout --enable-tools=yes --enable-tests=no --disable-samples --with-library-bits=64 --with-data-packaging=archive checking for ICU version numbers... release 71.1, library 71.1, unicode version 14.0 checking build system type... arm-apple-darwin22.6.0 checking host system type... arm-apple-darwin22.6.0 checking whether to build debug libraries... yes checking whether to build release libraries... no checking whether the C compiler works... no configure: error: in `/Users/mklymov/.conan2/p/b/icudebc37755934f/b/build-debug': configure: error: C compiler cannot create executables See `config.log' for more details icu/71.1: ERROR: Package 'b4ce41c723ecbd444ee714da4099f9c6747e9cdb' build failed icu/71.1: WARN: Build folder /Users/mklymov/.conan2/p/b/icudebc37755934f/b/build-debug ERROR: icu/71.1: Error in build() method, line 204 autotools.configure(build_script_folder=os.path.join(self.source_folder, "source")) ConanException: Error 77 while executing CMake Error at /Users/mklymov/test/cmake-conan/conan_provider.cmake:432 (message): Conan install failed='1' Call Stack (most recent call first): /Users/mklymov/test/cmake-conan/conan_provider.cmake:543 (conan_install) CMakeLists.txt:7 (find_package) -- Configuring incomplete, errors occurred! See also "/Users/mklymov/test/build/CMakeFiles/CMakeOutput.log". ```

Probably the same problem as in #589 but in my case CMake uses different name of executable.

Is this a problem with cmake-conan or with ICU recipe? https://github.com/conan-io/conan-center-index/issues/22624

jcar87 commented 8 months ago

Hi @Nekto89 - thank you for reporting this.

Interesting, I can see why this is failing - I'm surprised that cmake is reporting clang and clang++ as the compilers, instead of cc and c++, which is (or used to be) the default behaviour.

What version of CMake are you using?

Nekto89 commented 8 months ago

Hi @Nekto89 - thank you for reporting this.

Interesting, I can see why this is failing - I'm surprised that cmake is reporting clang and clang++ as the compilers, instead of cc and c++, which is (or used to be) the default behaviour.

What version of CMake are you using?

cmake version 3.25.1

jcar87 commented 8 months ago

I'm unable to reproduce this:

A project like this:

cmake_minimum_required(VERSION 3.25)

project(foobar LANGUAGES C CXX)

CMake will report:

-- The C compiler identification is AppleClang 14.0.0.14000029
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode_14.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode_14.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done

The cc and c++ being detected is what should cause the current logic to do the right thing. ~Wondering what causes yours to report clang and clang++. Any chance you have set CC/CXX environment variables or similar? Oh, perhaps it's the use of -GXcode that causes this! I'll have a look~

Can reproduce this now with -GXcode - fix incoming!