Skip to content

Build fails with gcc 9 and CMake < 3.11 #7654

@mxxo

Description

@mxxo
  • Checked for duplicates

Describe the bug

The build fails with gcc 9 and CMake 3.10, which I believe comes from the use of a CMake 3.11 feature.
The lines that fail are:

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND
${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 9)
target_compile_options(${lib} INTERFACE -Wno-deprecated-copy)
endif()

Build log:

max@max-VirtualBox:~/projects/rootdev/root/new-build$ cmake .. -Dccache=ON -Dtesting=ON -Dxrootd=OFF -Droot7=ON -During=ON
-- Detected ROOT_VERSION 6.25.01
-- Looking for Python
-- Found GCC. Major version 9, minor version 3
-- ROOT Platform: linux
-- ROOT Compiler: GNU 9.3.0
-- ROOT Processor: x86_64
-- ROOT Architecture: linuxx8664gcc
-- Build Type: 'RelWithDebInfo' (flags = '-O3 -g')
-- Compiler Flags:  -std=c++14 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O3 -g
-- ROOT default compression algorithm: zlib
-- PyROOT will be built for version 2.7.17
-- Found ccache: /usr/bin/ccache
-- Looking for ZLib
-- Looking for Freetype
-- Building LZMA version 5.2.4 included in ROOT itself
-- Looking for X11
-- Could NOT find GIF (missing: GIF_LIBRARY GIF_INCLUDE_DIR) 
-- Could NOT find TIFF (missing: TIFF_LIBRARY TIFF_INCLUDE_DIR) 
-- Could NOT find JPEG (missing: JPEG_LIBRARY JPEG_INCLUDE_DIR) 
-- Building AfterImage library included in ROOT itself
-- Looking for liburing
-- Cannot select cudnn without selecting cuda or tmva-gpu. Option is ignored
CMake Error at cmake/modules/SearchInstalledSoftware.cmake:1783 (target_compile_options):
  Cannot specify compile options for imported target "gtest".
Call Stack (most recent call first):
  CMakeLists.txt:219 (include)


CMake Error at cmake/modules/SearchInstalledSoftware.cmake:1783 (target_compile_options):
  Cannot specify compile options for imported target "gtest_main".
Call Stack (most recent call first):
  CMakeLists.txt:219 (include)


CMake Error at cmake/modules/SearchInstalledSoftware.cmake:1783 (target_compile_options):
  Cannot specify compile options for imported target "gmock".
Call Stack (most recent call first):
  CMakeLists.txt:219 (include)


CMake Error at cmake/modules/SearchInstalledSoftware.cmake:1783 (target_compile_options):
  Cannot specify compile options for imported target "gmock_main".
Call Stack (most recent call first):
  CMakeLists.txt:219 (include)


-- Building LLVM in 'Release' mode.
-- Could NOT find Z3: Found unsuitable version "0.0.0", but required is at least "4.7.1" (found Z3_LIBRARIES-NOTFOUND)
-- Could NOT find LibXml2 (missing: LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 
-- Native target architecture is X86
-- Threads disabled.
-- Doxygen disabled.
-- Go bindings disabled.
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- Could NOT find OCaml (missing: OCAMLFIND OCAML_VERSION OCAML_STDLIB_PATH) 
-- OCaml bindings disabled.
-- LLVM host triple: x86_64-unknown-linux-gnu
-- LLVM default target triple: x86_64-unknown-linux-gnu
-- Building with -fPIC
-- Constructing LLVMBuild project information
-- Linker detection: GNU ld
-- Targeting X86
-- Targeting NVPTX
-- Clang version: 9.0.1
-- Cling version (from VERSION file): ROOT_0.9~dev
-- Cling will look for C++ headers in '/usr/include/c++/9:/usr/include/x86_64-linux-gnu/c++/9:/usr/include/c++/9/backward' at runtime.
-- And then fallback to: 'x86_64-linux-gnu-g++-9'
-- Performing Test found_stdstringview
-- Performing Test found_stdstringview - Failed
-- Performing Test found_stdexpstringview
-- Performing Test found_stdexpstringview - Success
-- Performing Test found_stod_stringview
-- Performing Test found_stod_stringview - Failed
-- Performing Test found_stdapply
-- Performing Test found_stdapply - Failed
-- Performing Test found_stdinvoke
-- Performing Test found_stdinvoke - Failed
-- Performing Test found_stdindexsequence
-- Performing Test found_stdindexsequence - Success
-- 530/857 C++ tutorials have been activated.
-- 119/166 python tutorials have been activated.
-- ROOT Configuration 

System          Linux-5.11.0-051100-generic
Processor       4 core Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz (x86_64)
Build type      RelWithDebInfo
Install path    /usr/local
Compiler        GNU 9.3.0
Compiler flags:
C                -Wno-implicit-fallthrough -pipe -Wall -W -pthread -O3 -g -DNDEBUG
C++              -std=c++14 -Wno-implicit-fallthrough -Wno-noexcept-type -pipe  -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char -pthread -O3 -g -DNDEBUG
Linker flags:
Executable       -rdynamic
Module          
Shared           -Wl,--no-undefined -Wl,--hash-style="both"

-- Enabled support for:  asimage builtin_afterimage builtin_clang builtin_cling builtin_llvm builtin_lz4 builtin_lzma builtin_nlohmannjson builtin_openssl builtin_openui5 builtin_pcre builtin_tbb builtin_vdt builtin_xxhash builtin_zstd ccache clad dataframe exceptions gdml http imt mlp pyroot roofit webgui root7 runtime_cxxmodules shared ssl tmva spectrum uring vdt x11
-- Configuring incomplete, errors occurred!
See also "/home/max/projects/rootdev/root/new-build/CMakeFiles/CMakeOutput.log".
See also "/home/max/projects/rootdev/root/new-build/CMakeFiles/CMakeError.log".

Setup

  • ROOT master
  • Ubuntu 18.04
  • gcc 9.3
  • CMake 3.10.2

Possible fix

We could use a workaround similar to #5396 (this diff builds cleanly but is untested).

diff --git a/cmake/modules/SearchInstalledSoftware.cmake b/cmake/modules/SearchInstalledSoftware.cmake
index 1778dba165..a6d51ddd6f 100644
--- a/cmake/modules/SearchInstalledSoftware.cmake
+++ b/cmake/modules/SearchInstalledSoftware.cmake
@@ -1779,7 +1779,9 @@ if (testing)
     add_dependencies(${lib} googletest)
     if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND
         ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL 9)
-      target_compile_options(${lib} INTERFACE -Wno-deprecated-copy)
+      # TODO cmake 3.11
+      #target_compile_options(${lib} INTERFACE -Wno-deprecated-copy)
+      SET_PROPERTY(TARGET ${lib} APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "-Wno-deprecated-copy")
     endif()
   endforeach()
   # Once we require at least cmake 3.11, target_include_directories will work for imported targets

Additional context

Similar PR: #5396
From target_compile_options documentation: "New in version 3.11: Allow setting INTERFACE items on IMPORTED targets."

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions