Bug 1531678

Summary: CMAKE_LIBRARY_ARCHITECTURE is empty
Product: [Fedora] Fedora Reporter: Roman Tsisyk <roman>
Component: cmakeAssignee: Björn 'besser82' Esser <besser82>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: besser82, jreznik, orion, rdieter, walter.pete
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-01-14 16:08:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Roman Tsisyk 2018-01-05 19:09:15 UTC
Description of problem:

CMake's internal compiler checks doesn't detect CMAKE_LIBRARY_ARCHITECTURE properly on Fedora.

Version-Release number of selected component (if applicable):

Name         : cmake
Version      : 3.10.1
Release      : 8.fc28

How reproducible:

Steps to Reproduce:

1. Create an empty CMake project:

project (TestCase C CXX)
cmake_minimum_required (VERSION 2.8)

message(STATUS "CMAKE_LIBRARY_ARCHITECTURE ${CMAKE_LIBRARY_ARCHITECTURE}")

2. cmake .

Actual results:

-- The C compiler identification is GNU 7.2.1
-- The CXX compiler identification is GNU 7.2.1
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /bin/c++
-- Check for working CXX compiler: /bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_LIBRARY_ARCHITECTURE  <!-- EMPTY
-- Configuring done
-- Generating done


Expected results:


-- The C compiler identification is GNU 7.2.1
-- The CXX compiler identification is GNU 7.2.1
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /bin/c++
-- Check for working CXX compiler: /bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_LIBRARY_ARCHITECTURE x86_64-redhat-linux <!-- non-empty
-- Configuring done
-- Generating done


Additional info:

From /usr/share/cmake/Modules/CMakeDetermineCompilerABI.cmake

48 # Match multiarch library directory names.
49 set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")

112       # Detect library architecture directory name.
113       if(CMAKE_LIBRARY_ARCHITECTURE_REGEX)
114         foreach(dir ${implicit_dirs})
115           if("${dir}" MATCHES "/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$")
116             get_filename_component(arch "${dir}" NAME)
117             set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${arch}" PARENT_SCOPE)
119             break()
120           endif()
121         endforeach()
122       endif()

Fedora uses "x86_64-redhat-linux" compiler triplet which is not matched by "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*". I suggest to patch CMAKE_LIBRARY_ARCHITECTURE_REGEX.

Comment 1 Björn 'besser82' Esser 2018-01-14 16:08:44 UTC
As explained in the Cmake documentation [1], this is set only, if the compiler reports subdir triplets[2] as the implicit linker search path[3] for multi-arch.

We do not use such arch-triplets inside of %{_libdir} in Fedora nor RHEL, so this is expected not to be set.  AFAIK, this has been implemented for Debian and Ubuntu, as they do multi-arch is way.


[1]  https://cmake.org/cmake/help/v3.10/variable/CMAKE_LIBRARY_ARCHITECTURE.html
[2]  https://cmake.org/cmake/help/v3.10/variable/CMAKE_LANG_LIBRARY_ARCHITECTURE.html#variable:CMAKE_<LANG>_LIBRARY_ARCHITECTURE
[3]  https://cmake.org/cmake/help/v3.10/variable/CMAKE_LIBRARY_ARCHITECTURE_REGEX.html#index-0-variable:CMAKE_<LANG>_LIBRARY_ARCHITECTURE