c++cmakemakefilegtkcairo

Why are my compilation flags looking for errors when connecting cairomm.h?


The first time I decided to write a CMake file, I ran into a problem. To be honest, I don't understand why this is happening. My compilation flags cause errors in cairomm.h. Everything was fine before the addition of cairomm.h

CMakeLists.txt:

# Set the minimum version of CMake
cmake_minimum_required(VERSION 3.16)


# Set the project name, version, and specify the language
project(graphbuilder VERSION 0.1 LANGUAGES CXX)


# Specify that we are using C++20
set(CMAKE_CXX_STANDARD 20)


# Make the standard requirement mandatory
set(CMAKE_CXX_STANDARD_REQUIRED ON)


# Prevent the compiler from including its extensions
set(CMAKE_CXX_EXTENSIONS OFF)



# TODO: remove in release
# Set the default CMAKE_BUILD_TYPE to Debug
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type" FORCE)
endif()


# Compilation flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")


# Additional flags for debugging
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -D_DEBUG -ggdb3")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Waggressive-loop-optimizations -Wmissing-declarations -Wcast-align -Wcast-qual -Wchar-subscripts -Wconversion -Wempty-body -Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat=2 -Winline -Wlogical-op -Wopenmp-simd -Wpacked -Wpointer-arith -Winit-self -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=2 -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wundef -Wunreachable-code -Wvariadic-macros -Wno-missing-field-initializers -Wno-narrowing -Wno-varargs -Wstack-protector -fcheck-new -fstack-protector -fstrict-overflow -flto-odr-type-merging -fno-omit-frame-pointer -pie -fPIE -Werror=vla")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,alignment,bool,bounds,enum,float-cast-overflow,float-divide-by-zero,integer-divide-by-zero,leak,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,undefined,unreachable,vla-bound,vptr")
endif()


# Setting library paths
# Library for information about library compilation
# Necessary for further pkg_check_modules
find_package(PkgConfig REQUIRED)
# Store information about gtkmm-3.0 in GTKMM
pkg_check_modules(GTKMM REQUIRED gtkmm-3.0)
# Store information about gtk+-3.0
pkg_check_modules(GTK REQUIRED gtk+-3.0)
# Store information about cairo
pkg_check_modules(CAIRO REQUIRED cairo)


# Add gtk directories
include_directories(${GTKMM_INCLUDE_DIRS} ${GTK_INCLUDE_DIRS} ${CAIRO_INCLUDE_DIRS})
# Add gtk flags
set(CMAKE_CXX_FLAGS, "${CMAKE_CXX_FLAGS} ${GTK_CFLAGS} ${GTKMM_CFLAGS} ${CAIRO_CFLAGS}")


# Add executables
# -------------------------
# Add a basic example
set(SRCS_EXAMPLE 
    example.cpp
)
# Add a mathematical expression parser
# TODO: do something with the parser graphs
set(SRCS_PARSER
    src/Charts/ParsingTree/ParsingTree.cpp
    src/Charts/ParsingTree/ParsingTreeGraph.cpp
)
# Add a board 
set(SRCS_BOARD
    src/Graphics/Board.cpp
)
# Add a non-graphical interface
set(SRCS_INTERFACE_CLI
    src/Interface/CLI.cpp
)
# Add a graphical interface
set(SRCS_INTERFACE_GUI
    src/Interface/GUI.cpp
)
# -------------------------


# Create libraries from source files
# -------------------------
# Add parser library
add_library(parser STATIC ${SRCS_PARSER})
# Add board library
add_library(board STATIC ${SRCS_BOARD})
# Add CLI library
add_library(interface_cli STATIC ${SRCS_INTERFACE_CLI})
# Add GUI library
add_library(interface_gui STATIC ${SRCS_INTERFACE_GUI})
# -------------------------


# Create an executable for the basic example
add_executable(graph ${SRCS_EXAMPLE})


# TODO: maybe separate compilation for CLI and GUI
# TODO: give a name to GTK
# Set up dependencies
# Set dependencies for board
target_link_libraries(board 
    ${GTKMM_LIBRARIES} 
    ${GTK_LIBRARIES}
    ${CAIRO_LIBRARIES}
)
# Set dependencies for cli
target_link_libraries(interface_cli 
    parser 
    board 
)
# Setting dependencies for gui
target_link_libraries(interface_gui 
    parser 
    board
)
# Setting dependencies for the basic example
target_link_libraries(graph
    interface_cli
    interface_gui
)

# Tests
# -------------------------
# Activating test mode
enable_testing()
# Looking for gtest, required for tests
find_package(GTest REQUIRED)
# Adding gtest directories
include_directories(${GTEST_INCLUDE_DIRS}) 

# Adding parser test
set(SRCS_PARSER_TESTS src/Tests/parser_tests.cpp)
add_executable(parser_tests ${SRCS_PARSER_TESTS})
target_link_libraries(parser_tests
    parser
    ${GTEST_LIBRARIES}
)
add_test(NAME ParserTests COMMAND parser_tests)

# TODO: add tests for GUI CLI

# -------------------------

make VERBOSE=1:

/home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -S/home/garik/PROJECTS/graphbuilder -B/home/garik/PROJECTS/graphbuilder/build --check-build-system CMakeFiles/Makefile.cmake 0
/home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -E cmake_progress_start /home/garik/PROJECTS/graphbuilder/build/CMakeFiles /home/garik/PROJECTS/graphbuilder/build//CMakeFiles/progress.marks
make  -f CMakeFiles/Makefile2 all
make[1]: вход в каталог «/home/garik/PROJECTS/graphbuilder/build»
make  -f CMakeFiles/parser.dir/build.make CMakeFiles/parser.dir/depend
make[2]: вход в каталог «/home/garik/PROJECTS/graphbuilder/build»
cd /home/garik/PROJECTS/graphbuilder/build && /home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -E cmake_depends "Unix Makefiles" /home/garik/PROJECTS/graphbuilder /home/garik/PROJECTS/graphbuilder /home/garik/PROJECTS/graphbuilder/build /home/garik/PROJECTS/graphbuilder/build /home/garik/PROJECTS/graphbuilder/build/CMakeFiles/parser.dir/DependInfo.cmake "--color="
make[2]: выход из каталога «/home/garik/PROJECTS/graphbuilder/build»
make  -f CMakeFiles/parser.dir/build.make CMakeFiles/parser.dir/build
make[2]: вход в каталог «/home/garik/PROJECTS/graphbuilder/build»
[  7%] Building CXX object CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTree.cpp.o
/usr/bin/c++  -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/atkmm-1.6 -I/usr/lib/x86_64-linux-gnu/atkmm-1.6/include -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -Wall -Wextra -Werror -lm -g -D_DEBUG -ggdb3 -Waggressive-loop-optimizations -Wmissing-declarations -Wcast-align -Wcast-qual -Wchar-subscripts -Wconversion -Wempty-body -Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat=2 -Winline -Wlogical-op -Wopenmp-simd -Wpacked -Wpointer-arith -Winit-self -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=2 -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wundef -Wunreachable-code -Wvariadic-macros -Wno-missing-field-initializers -Wno-narrowing -Wno-varargs -Wstack-protector -fcheck-new -fstack-protector -fstrict-overflow -flto-odr-type-merging -fno-omit-frame-pointer -pie -fPIE -Werror=vla -fsanitize=address,alignment,bool,bounds,enum,float-cast-overflow,float-divide-by-zero,integer-divide-by-zero,leak,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,undefined,unreachable,vla-bound,vptr -g -std=c++20 -MD -MT CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTree.cpp.o -MF CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTree.cpp.o.d -o CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTree.cpp.o -c /home/garik/PROJECTS/graphbuilder/src/Charts/ParsingTree/ParsingTree.cpp
[ 15%] Building CXX object CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTreeGraph.cpp.o
/usr/bin/c++  -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/atkmm-1.6 -I/usr/lib/x86_64-linux-gnu/atkmm-1.6/include -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -Wall -Wextra -Werror -lm -g -D_DEBUG -ggdb3 -Waggressive-loop-optimizations -Wmissing-declarations -Wcast-align -Wcast-qual -Wchar-subscripts -Wconversion -Wempty-body -Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat=2 -Winline -Wlogical-op -Wopenmp-simd -Wpacked -Wpointer-arith -Winit-self -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=2 -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wundef -Wunreachable-code -Wvariadic-macros -Wno-missing-field-initializers -Wno-narrowing -Wno-varargs -Wstack-protector -fcheck-new -fstack-protector -fstrict-overflow -flto-odr-type-merging -fno-omit-frame-pointer -pie -fPIE -Werror=vla -fsanitize=address,alignment,bool,bounds,enum,float-cast-overflow,float-divide-by-zero,integer-divide-by-zero,leak,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,undefined,unreachable,vla-bound,vptr -g -std=c++20 -MD -MT CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTreeGraph.cpp.o -MF CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTreeGraph.cpp.o.d -o CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTreeGraph.cpp.o -c /home/garik/PROJECTS/graphbuilder/src/Charts/ParsingTree/ParsingTreeGraph.cpp
[ 23%] Linking CXX static library libparser.a
/home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -P CMakeFiles/parser.dir/cmake_clean_target.cmake
/home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/parser.dir/link.txt --verbose=1
/usr/bin/ar qc libparser.a CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTree.cpp.o CMakeFiles/parser.dir/src/Charts/ParsingTree/ParsingTreeGraph.cpp.o
/usr/bin/ranlib libparser.a
make[2]: выход из каталога «/home/garik/PROJECTS/graphbuilder/build»
[ 23%] Built target parser
make  -f CMakeFiles/board.dir/build.make CMakeFiles/board.dir/depend
make[2]: вход в каталог «/home/garik/PROJECTS/graphbuilder/build»
cd /home/garik/PROJECTS/graphbuilder/build && /home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -E cmake_depends "Unix Makefiles" /home/garik/PROJECTS/graphbuilder /home/garik/PROJECTS/graphbuilder /home/garik/PROJECTS/graphbuilder/build /home/garik/PROJECTS/graphbuilder/build /home/garik/PROJECTS/graphbuilder/build/CMakeFiles/board.dir/DependInfo.cmake "--color="
make[2]: выход из каталога «/home/garik/PROJECTS/graphbuilder/build»
make  -f CMakeFiles/board.dir/build.make CMakeFiles/board.dir/build
make[2]: вход в каталог «/home/garik/PROJECTS/graphbuilder/build»
[ 30%] Building CXX object CMakeFiles/board.dir/src/Graphics/Board.cpp.o
/usr/bin/c++  -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/atkmm-1.6 -I/usr/lib/x86_64-linux-gnu/atkmm-1.6/include -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -Wall -Wextra -Werror -lm -g -D_DEBUG -ggdb3 -Waggressive-loop-optimizations -Wmissing-declarations -Wcast-align -Wcast-qual -Wchar-subscripts -Wconversion -Wempty-body -Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat=2 -Winline -Wlogical-op -Wopenmp-simd -Wpacked -Wpointer-arith -Winit-self -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=2 -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wundef -Wunreachable-code -Wvariadic-macros -Wno-missing-field-initializers -Wno-narrowing -Wno-varargs -Wstack-protector -fcheck-new -fstack-protector -fstrict-overflow -flto-odr-type-merging -fno-omit-frame-pointer -pie -fPIE -Werror=vla -fsanitize=address,alignment,bool,bounds,enum,float-cast-overflow,float-divide-by-zero,integer-divide-by-zero,leak,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,undefined,unreachable,vla-bound,vptr -g -std=c++20 -MD -MT CMakeFiles/board.dir/src/Graphics/Board.cpp.o -MF CMakeFiles/board.dir/src/Graphics/Board.cpp.o.d -o CMakeFiles/board.dir/src/Graphics/Board.cpp.o -c /home/garik/PROJECTS/graphbuilder/src/Graphics/Board.cpp
[ 38%] Linking CXX static library libboard.a
/home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -P CMakeFiles/board.dir/cmake_clean_target.cmake
/home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/board.dir/link.txt --verbose=1
/usr/bin/ar qc libboard.a CMakeFiles/board.dir/src/Graphics/Board.cpp.o
/usr/bin/ranlib libboard.a
make[2]: выход из каталога «/home/garik/PROJECTS/graphbuilder/build»
[ 38%] Built target board
make  -f CMakeFiles/interface_cli.dir/build.make CMakeFiles/interface_cli.dir/depend
make[2]: вход в каталог «/home/garik/PROJECTS/graphbuilder/build»
cd /home/garik/PROJECTS/graphbuilder/build && /home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -E cmake_depends "Unix Makefiles" /home/garik/PROJECTS/graphbuilder /home/garik/PROJECTS/graphbuilder /home/garik/PROJECTS/graphbuilder/build /home/garik/PROJECTS/graphbuilder/build /home/garik/PROJECTS/graphbuilder/build/CMakeFiles/interface_cli.dir/DependInfo.cmake "--color="
make[2]: выход из каталога «/home/garik/PROJECTS/graphbuilder/build»
make  -f CMakeFiles/interface_cli.dir/build.make CMakeFiles/interface_cli.dir/build
make[2]: вход в каталог «/home/garik/PROJECTS/graphbuilder/build»
[ 46%] Building CXX object CMakeFiles/interface_cli.dir/src/Interface/CLI.cpp.o
/usr/bin/c++  -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/atkmm-1.6 -I/usr/lib/x86_64-linux-gnu/atkmm-1.6/include -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -Wall -Wextra -Werror -lm -g -D_DEBUG -ggdb3 -Waggressive-loop-optimizations -Wmissing-declarations -Wcast-align -Wcast-qual -Wchar-subscripts -Wconversion -Wempty-body -Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat=2 -Winline -Wlogical-op -Wopenmp-simd -Wpacked -Wpointer-arith -Winit-self -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=2 -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wundef -Wunreachable-code -Wvariadic-macros -Wno-missing-field-initializers -Wno-narrowing -Wno-varargs -Wstack-protector -fcheck-new -fstack-protector -fstrict-overflow -flto-odr-type-merging -fno-omit-frame-pointer -pie -fPIE -Werror=vla -fsanitize=address,alignment,bool,bounds,enum,float-cast-overflow,float-divide-by-zero,integer-divide-by-zero,leak,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,undefined,unreachable,vla-bound,vptr -g -std=c++20 -MD -MT CMakeFiles/interface_cli.dir/src/Interface/CLI.cpp.o -MF CMakeFiles/interface_cli.dir/src/Interface/CLI.cpp.o.d -o CMakeFiles/interface_cli.dir/src/Interface/CLI.cpp.o -c /home/garik/PROJECTS/graphbuilder/src/Interface/CLI.cpp
[ 53%] Linking CXX static library libinterface_cli.a
/home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -P CMakeFiles/interface_cli.dir/cmake_clean_target.cmake
/home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -E cmake_link_script CMakeFiles/interface_cli.dir/link.txt --verbose=1
/usr/bin/ar qc libinterface_cli.a CMakeFiles/interface_cli.dir/src/Interface/CLI.cpp.o
/usr/bin/ranlib libinterface_cli.a
make[2]: выход из каталога «/home/garik/PROJECTS/graphbuilder/build»
[ 53%] Built target interface_cli
make  -f CMakeFiles/interface_gui.dir/build.make CMakeFiles/interface_gui.dir/depend
make[2]: вход в каталог «/home/garik/PROJECTS/graphbuilder/build»
cd /home/garik/PROJECTS/graphbuilder/build && /home/garik/.local/lib/python3.11/site-packages/cmake/data/bin/cmake -E cmake_depends "Unix Makefiles" /home/garik/PROJECTS/graphbuilder /home/garik/PROJECTS/graphbuilder /home/garik/PROJECTS/graphbuilder/build /home/garik/PROJECTS/graphbuilder/build /home/garik/PROJECTS/graphbuilder/build/CMakeFiles/interface_gui.dir/DependInfo.cmake "--color="
make[2]: выход из каталога «/home/garik/PROJECTS/graphbuilder/build»
make  -f CMakeFiles/interface_gui.dir/build.make CMakeFiles/interface_gui.dir/build
make[2]: вход в каталог «/home/garik/PROJECTS/graphbuilder/build»
[ 61%] Building CXX object CMakeFiles/interface_gui.dir/src/Interface/GUI.cpp.o
/usr/bin/c++  -I/usr/include/gtkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gtkmm-3.0/include -I/usr/include/giomm-2.4 -I/usr/lib/x86_64-linux-gnu/giomm-2.4/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/cairomm-1.0 -I/usr/lib/x86_64-linux-gnu/cairomm-1.0/include -I/usr/include/pangomm-1.4 -I/usr/lib/x86_64-linux-gnu/pangomm-1.4/include -I/usr/include/atkmm-1.6 -I/usr/lib/x86_64-linux-gnu/atkmm-1.6/include -I/usr/include/gtk-3.0/unix-print -I/usr/include/gdkmm-3.0 -I/usr/lib/x86_64-linux-gnu/gdkmm-3.0/include -Wall -Wextra -Werror -lm -g -D_DEBUG -ggdb3 -Waggressive-loop-optimizations -Wmissing-declarations -Wcast-align -Wcast-qual -Wchar-subscripts -Wconversion -Wempty-body -Wformat-nonliteral -Wformat-security -Wformat-signedness -Wformat=2 -Winline -Wlogical-op -Wopenmp-simd -Wpacked -Wpointer-arith -Winit-self -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=2 -Wsuggest-attribute=noreturn -Wsuggest-final-methods -Wsuggest-final-types -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wundef -Wunreachable-code -Wvariadic-macros -Wno-missing-field-initializers -Wno-narrowing -Wno-varargs -Wstack-protector -fcheck-new -fstack-protector -fstrict-overflow -flto-odr-type-merging -fno-omit-frame-pointer -pie -fPIE -Werror=vla -fsanitize=address,alignment,bool,bounds,enum,float-cast-overflow,float-divide-by-zero,integer-divide-by-zero,leak,nonnull-attribute,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,undefined,unreachable,vla-bound,vptr -g -std=c++20 -MD -MT CMakeFiles/interface_gui.dir/src/Interface/GUI.cpp.o -MF CMakeFiles/interface_gui.dir/src/Interface/GUI.cpp.o.d -o CMakeFiles/interface_gui.dir/src/Interface/GUI.cpp.o -c /home/garik/PROJECTS/graphbuilder/src/Interface/GUI.cpp
In file included from /usr/include/sigc++-2.0/sigc++/visit_each.h:21,
                 from /usr/include/sigc++-2.0/sigc++/functors/slot.h:6,
                 from /usr/include/sigc++-2.0/sigc++/slot.h:19,
                 from /usr/include/cairomm-1.0/cairomm/surface.h:32,
                 from /usr/include/cairomm-1.0/cairomm/context.h:24,
                 from /usr/include/cairomm-1.0/cairomm/cairomm.h:35,
                 from /home/garik/PROJECTS/graphbuilder/src/Interface/GUI.hpp:3,
                 from /home/garik/PROJECTS/graphbuilder/src/Interface/GUI.cpp:1:
/usr/include/sigc++-2.0/sigc++/type_traits.h:35:27: error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
   35 | struct type_trait<T_type[N]>
      |                           ^
In file included from /usr/include/giomm-2.4/giomm/drive.h:26,
                 from /usr/include/giomm-2.4/giomm/file.h:37,
                 from /usr/include/giomm-2.4/giomm/applicationcommandline.h:25,
                 from /usr/include/giomm-2.4/giomm/application.h:30,
                 from /usr/include/giomm-2.4/giomm.h:29,
                 from /usr/include/gtkmm-3.0/gtkmm.h:101,
                 from /home/garik/PROJECTS/graphbuilder/src/Interface/GUI.hpp:4:
/usr/include/giomm-2.4/giomm/mount.h:735:28: error: redundant redeclaration of ‘Glib::RefPtr<Gio::Mount> Glib::wrap(GMount*, bool)’ in same scope [-Werror=redundant-decls]
  735 |   Glib::RefPtr<Gio::Mount> wrap(GMount* object, bool take_copy = false);
      |                            ^~~~
/usr/include/giomm-2.4/giomm/mount.h:686:26: note: previous declaration of ‘Glib::RefPtr<Gio::Mount> Glib::wrap(GMount*, bool)’
  686 | Glib::RefPtr<Gio::Mount> wrap(GMount* object, bool take_copy);
      |                          ^~~~
/usr/include/giomm-2.4/giomm/drive.h:656:28: error: redundant redeclaration of ‘Glib::RefPtr<Gio::Drive> Glib::wrap(GDrive*, bool)’ in same scope [-Werror=redundant-decls]
  656 |   Glib::RefPtr<Gio::Drive> wrap(GDrive* object, bool take_copy = false);
      |                            ^~~~
/usr/include/giomm-2.4/giomm/drive.h:607:26: note: previous declaration of ‘Glib::RefPtr<Gio::Drive> Glib::wrap(GDrive*, bool)’
  607 | Glib::RefPtr<Gio::Drive> wrap(GDrive* object, bool take_copy);
      |                          ^~~~
/usr/include/giomm-2.4/giomm/file.h:3686:27: error: redundant redeclaration of ‘Glib::RefPtr<Gio::File> Glib::wrap(GFile*, bool)’ in same scope [-Werror=redundant-decls]
 3686 |   Glib::RefPtr<Gio::File> wrap(GFile* object, bool take_copy = false);
      |                           ^~~~
/usr/include/giomm-2.4/giomm/file.h:3637:25: note: previous declaration of ‘Glib::RefPtr<Gio::File> Glib::wrap(GFile*, bool)’
 3637 | Glib::RefPtr<Gio::File> wrap(GFile* object, bool take_copy);
      |                         ^~~~
In file included from /usr/include/giomm-2.4/giomm.h:163:
/usr/include/giomm-2.4/giomm/volume.h:523:29: error: redundant redeclaration of ‘Glib::RefPtr<Gio::Volume> Glib::wrap(GVolume*, bool)’ in same scope [-Werror=redundant-decls]
  523 |   Glib::RefPtr<Gio::Volume> wrap(GVolume* object, bool take_copy = false);
      |                             ^~~~
/usr/include/giomm-2.4/giomm/volume.h:474:27: note: previous declaration of ‘Glib::RefPtr<Gio::Volume> Glib::wrap(GVolume*, bool)’
  474 | Glib::RefPtr<Gio::Volume> wrap(GVolume* object, bool take_copy);
      |                           ^~~~
In file included from /usr/include/pangomm-1.4/pangomm/layout.h:35,
                 from /usr/include/gtkmm-3.0/gtkmm/widget.h:32,
                 from /usr/include/gtkmm-3.0/gtkmm/action.h:31,
                 from /usr/include/gtkmm-3.0/gtkmm/toggleaction.h:29,
                 from /usr/include/gtkmm-3.0/gtkmm.h:108:
/usr/include/pangomm-1.4/pangomm/layoutline.h:251:33: error: redundant redeclaration of ‘Glib::RefPtr<Pango::LayoutLine> Glib::wrap(PangoLayoutLine*, bool)’ in same scope [-Werror=redundant-decls]
  251 | Glib::RefPtr<Pango::LayoutLine> wrap(PangoLayoutLine* object, bool take_copy = false);
      |                                 ^~~~
/usr/include/pangomm-1.4/pangomm/layoutline.h:212:33: note: previous declaration of ‘Glib::RefPtr<Pango::LayoutLine> Glib::wrap(PangoLayoutLine*, bool)’
  212 | Glib::RefPtr<Pango::LayoutLine> wrap(PangoLayoutLine* object, bool take_copy /* = false */);
      |                                 ^~~~
In file included from /usr/include/gtkmm-3.0/gtkmm/recentchooser.h:29,
                 from /usr/include/gtkmm-3.0/gtkmm/recentaction.h:30,
                 from /usr/include/gtkmm-3.0/gtkmm.h:258:
/usr/include/gtkmm-3.0/gtkmm/recentinfo.h:41:6: error: redundant redeclaration of ‘void gtk_recent_info_unref(GtkRecentInfo*)’ in same scope [-Werror=redundant-decls]
   41 | void gtk_recent_info_unref(GtkRecentInfo* info);
      |      ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/gtk-3.0/gtk/gtkrecentchooser.h:28,
                 from /usr/include/gtk-3.0/gtk/gtk.h:175,
                 from /usr/include/gtkmm-3.0/gtkmm/enums.h:31,
                 from /usr/include/gtkmm-3.0/gtkmm/widget.h:47:
/usr/include/gtk-3.0/gtk/gtkrecentmanager.h:207:23: note: previous declaration of ‘void gtk_recent_info_unref(GtkRecentInfo*)’
  207 | void                  gtk_recent_info_unref                (GtkRecentInfo  *info);
      |                       ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/glibmm-2.4/glibmm.h:107,
                 from /usr/include/gtkmm-3.0/gtkmm.h:100:
/usr/include/glibmm-2.4/glibmm/arrayhandle.h: In instantiation of ‘std::size_t Glib::Container_Helpers::compute_array_size(const T*) [with T = int; std::size_t = long unsigned int]’:
/usr/include/glibmm-2.4/glibmm/arrayhandle.h:687:62:   required from here
/usr/include/glibmm-2.4/glibmm/arrayhandle.h:42:16: error: conversion to ‘std::size_t’ {aka ‘long unsigned int’} from ‘long int’ may change the sign of the result [-Werror=sign-conversion]
   42 |   return (pend - array);
      |          ~~~~~~^~~~~~~~
cc1plus: all warnings being treated as errors

I tried to get rid of include_directories, but it didn't work. I tried using target_compile_options instead of CMAKE_CXX_FLAGS, it didn't help


Solution

  • You globally enabled extra warnings and then asked the compiler to treat each warning as error:

    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
    

    and then it looks like the library you are using would produce some warnings, so now it doesn't compile, e.g. implicit sign conversion treated as error:

    error: conversion to ‘long unsigned int’ from ‘int’ may change the sign of the result [-Werror=sign-conversion]
    

    One possible solution is to use target_include_directories with SYSTEM optional argument, to ignore warnings from the library code. E.g.:

    target_include_directories(YourTarget SYSTEM PUBLIC ${CAIRO_INCLUDE_DIRS})
    

    You would need to also remove redundant global include_directories settings (it's not the best practise to use it anyway).