conan-io / cmake-conan

CMake wrapper for conan C and C++ package manager
MIT License
828 stars 252 forks source link

IntelLLVM not recognized #381

Open alessandrofasse opened 2 years ago

alessandrofasse commented 2 years ago

I am trying to use the Intel Compiler within conan on Windows with ninja. For that I did setup a small cmake project with the following CMakeLists.txt:

cmake_minimum_required(VERSION 3.22.0)

## Language 
project(INTEL_TEST LANGUAGES CXX)

## Third parties
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/conan.cmake)
conan_cmake_run(
    REQUIRES
    gtest/1.11.0
    BUILD missing
)
conan_basic_setup(NO_OUTPUT_DIRS)

and I use conan.cmake from this repo/commit: https://github.com/conan-io/cmake-conan/blob/develop/conan.cmake

For Ninja I need to define the environment manually. So first call the corresponding bat script and then run cmake as:

C:\Program Files (x86)\Intel\oneAPI\setvars.bat intel64 vs2022
cmake -S . -B  .\build -G Ninja -DCMAKE_C_COMPILER=dpcpp -DCMAKE_CXX_COMPILER=dpcpp

Then I get the following output:

-- The CXX compiler identification is IntelLLVM 2022.0.0 with MSVC-like command-line
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/dpcpp.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Automatic detection of conan settings from cmake
CMake Error at scripts/conan.cmake:228 (message):
  Conan: compiler setup not recognized
Call Stack (most recent call first):
  scripts/conan.cmake:253 (_conan_detect_compiler)
  scripts/conan.cmake:767 (conan_cmake_settings)
  CMakeLists.txt:28 (conan_cmake_run)
-- Configuring incomplete, errors occurred!

First I though the problem comes with the fact that 2022.0.0 is a too new compiler and hence tried 2021.2 (which is in the current settings.yml file of conan). However this also did not work.

As it seems to me, there is no compiler mentioned as IntelLLVM for conan. I also check the same with loading the env for Visual Studio 2022 and that works easily. Also the compiler dpcpp or even icx are recognized but conan rejects to use them. Any ideas?

Environment Details (include every applicable attribute)

memsharded commented 2 years ago

It seems that this is an issue of the cmake.conan, that is not translating the IntelLLVM to the corresponding Conan setting. That conversion happens in the conan.cmake file, not in Conan client, so I'll move this issue to that repository.

Consider adding/forcing the setting to the intel-cc one in your cmake code, to avoid conan.cmake translation or auto-detection.

alessandrofasse commented 2 years ago

Thank you for fast feedback and indeed you were right. I worked on the conan.cmake and added the following section:

    elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL IntelLLVM)
        string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
        list(GET VERSION_LIST 0 MAJOR)
        list(GET VERSION_LIST 1 MINOR)
        set(COMPILER_VERSION ${MAJOR}.${MINOR})
        set(_CONAN_SETTING_COMPILER intel-cc)
        set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION})
        if( ${CMAKE_CXX_COMPILER} MATCHES dpcpp)
            set(_CONAN_SETTING_COMPILER_MODE dpcpp)
        endif()
        if( ${CMAKE_CXX_COMPILER} MATCHES icx)
            set(_CONAN_SETTING_COMPILER_MODE icx)
        endif()
        if (USING_CXX)
            conan_cmake_detect_unix_libcxx(_LIBCXX)
            set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
        endif ()

I also added (2022.0 in the settings.yml). Now everything goes through but stops again when he wants to build gtest. It stopes with this:

PS C:\Users\alfa\Projects\cubecnn> cmake -S . -B ./build -G Ninja -DCMAKE_CXX_COMPILER=dpcpp
-- COMPILER C:/Program Files (x86)/Intel/oneAPI/compiler/latest/windows/bin/dpcpp.exe
-- COMPILER IntelLLVM
-- VERSION 2022.0.0
-- FLAGS
-- LIB ARCH
-- BUILD TYPE Debug
-- GENERATOR Ninja
-- GENERATOR WIN64 1
-- Conan: Automatic detection of conan settings from cmake
append-file: input file not found
-- Conan: Settings= -s;build_type=Debug;-s;compiler=intel-cc;-s;compiler.version=2022.0;-s;compiler.libcxx=libc++;-s;compiler.mode=dpcpp
-- Conan: checking conan executable
-- Conan: Found program C:/Program Files/Conan/conan/conan.exe
-- Conan: Version found Conan version 1.43.1
-- Conan executing: C:/Program Files/Conan/conan/conan.exe install . -s build_type=Debug -s compiler=intel-cc -s compiler.version=2022.0 -s compiler.libcxx=libc++ -s compiler.mode=dpcpp -g=cmake --build=missing
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=intel-cc
compiler.libcxx=libc++
compiler.mode=dpcpp
compiler.version=2022.0
os=Windows
os_build=Windows
[options]
[build_requires]
[env]

conanfile.txt: Installing package
Requirements
    gtest/1.11.0 from 'conancenter' - Cache
Packages
    gtest/1.11.0:98f52bd6cb7894fe56eaacaadd4e845856fc5b5e - Build

Installing (downloading, building) binaries...
gtest/1.11.0: Copying sources to build folder
gtest/1.11.0: Building your package in C:\Users\aless\.conan\data\gtest\1.11.0\_\_\build\98f52bd6cb7894fe56eaacaadd4e845856fc5b5e
gtest/1.11.0: Generator cmake created conanbuildinfo.cmake
gtest/1.11.0: Aggregating env generators
gtest/1.11.0: Calling build()
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage-- Configuring incomplete, errors occurred!

gtest/1.11.0: 
gtest/1.11.0: WARN: gtest recipe lacks information about intel-cc compiler support.
gtest/1.11.0: WARN: Package binary is corrupted, removing: 98f52bd6cb7894fe56eaacaadd4e845856fc5b5e
gtest/1.11.0: WARN: Build folder is dirty, removing it: C:\Users\aless\.conan\data\gtest\1.11.0\_\_\build\98f52bd6cb7894fe56eaacaadd4e845856fc5b5e
gtest/1.11.0: ERROR: Package '98f52bd6cb7894fe56eaacaadd4e845856fc5b5e' build failed
gtest/1.11.0: WARN: Build folder C:\Users\aless\.conan\data\gtest\1.11.0\_\_\build\98f52bd6cb7894fe56eaacaadd4e845856fc5b5e
ERROR: gtest/1.11.0: Error in build() method, line 130
        cmake = self._configure_cmake()
while calling '_configure_cmake', line 124
        cmake.configure(build_folder=self._build_subfolder)
        ConanException: Error 1 while executing cd C:\Users\aless\.conan\data\gtest\1.11.0\_\_\build\98f52bd6cb7894fe56eaacaadd4e845856fc5b5e\build_subfolder && cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE="Debug" -DCONAN_IN_LOCAL_CACHE="ON" -DCONAN_COMPILER="intel-cc" -DCONAN_COMPILER_VERSION="2022.0" -DCONAN_LIBCXX="libc++" -DBUILD_SHARED_LIBS="OFF" -DCMAKE_INSTALL_PREFIX="C:\Users\aless\.conan\data\gtest\1.11.0\_\_\package\98f52bd6cb7894fe56eaacaadd4e845856fc5b5e" -DCMAKE_INSTALL_BINDIR="bin" -DCMAKE_INSTALL_SBINDIR="bin" -DCMAKE_INSTALL_LIBEXECDIR="bin" -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_INSTALL_INCLUDEDIR="include" -DCMAKE_INSTALL_OLDINCLUDEDIR="include" -DCMAKE_INSTALL_DATAROOTDIR="share" -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY="ON" -DCONAN_EXPORTED="1" -DCUSTOM_DEBUG_POSTFIX="d" -DBUILD_GMOCK="True" -Dgtest_hide_internal_symbols="False" -Wno-dev C:\Users\aless\.conan\data\gtest\1.11.0\_\_\build\98f52bd6cb7894fe56eaacaadd4e845856fc5b5e
CMake Error at scripts/conan.cmake:548 (message):
  Conan install failed='1'
Call Stack (most recent call first):
  scripts/conan.cmake:785 (old_conan_cmake_install)
  CMakeLists.txt:28 (conan_cmake_run)

-- Configuring incomplete, errors occurred!
See also "C:/Users/aless/Projects/cubecnn/build/CMakeFiles/CMakeOutput.log".

How can I set to use Ninja when building gtest?

alessandrofasse commented 2 years ago

Any help please :)? I think that solution is straight forward but I don't know the trick

memsharded commented 2 years ago

Hi @AlessandroFasse

The new intel-cc is not be supported fully by the "legacy" integrations, only by the new ones in conan.tools.xxx domain like CMakeToolchain, AutotoolsToolchain, etc. ConanCenter recipes have not been updated yet to these new integrations, it will hopefully happen soon.

Thanks for sharing your solution, I think it will help to fix the cmake-conan script.

alessandrofasse commented 2 years ago

I see and thanks for the information. But might it be possible that I fall back onto Visual Studio 2022 for the third parties and then use intel-cc for my build? If so, how could I do such a thing?