Skip to content

OpenGL::GL causes build failure #40

@rpav

Description

@rpav

For some reason, using target_link_libraries(... OpenGL::GL) causes -isystem /usr/include to be added to the PCH build, which apparently causes breakage:

/usr/include/c++/8.3.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.

This doesn't seem to be added to the actual build (e.g., does not occur in compile_commands.json).

Minimal example

Minimal CMakeLists.txt example reproducing bug or showing requested feature:

cmake_minimum_required(VERSION 3.11)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMake/CMakePCHCompiler)

project(test CXX CXXPCH)

find_package(OpenGL REQUIRED COMPONENTS OpenGL)

add_executable(demo demo.cpp)
target_link_libraries(demo PRIVATE
  OpenGL::GL
  )

target_precompiled_header(demo prefix.h)

Of course, one must have some minimal prefix.h:

#include <cstdlib>

This is the only difference:

$ /usr/bin/g++   -isystem /usr/include  -O3 -DNDEBUG   -x c++-header -o CMakeFiles/demo.pch.dir/prefix.h.gch -c /home/rpav/tmp/test/prefix.h


In file included from /home/rpav/tmp/test/prefix.h:1:
/usr/include/c++/8.3.0/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
               ^~~~~~~~~~
compilation terminated.
$ /usr/bin/g++  -O3 -DNDEBUG   -x c++-header -o CMakeFiles/demo.pch.dir/prefix.h.gch -c /home/rpav/tmp/test/prefix.h
$

Additional information

  • OS: Linux (Arch, current)
  • CMake version 3.14.4
  • Compiler type and version: gcc-8.3 (also clang-8.0)
  • Additional Libraries used: Platform GL (nvidia)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions