When I run cmake .. in ./build, I get the output:
`-- Checking for module 'gtkmm3'
-- Package 'gtkmm3', required by 'virtual:world', not found
CMake Error at /nix/store/i78xz11da295kd8ynsjmxvi2r56rbhzw-clion-2024.1.3/clion/bin/cmake/linux/x64/share/cmake-3.28/Modules/FindPkgConfig.cmake:619 (message):
The following required packages were not found:
- gtkmm3
Call Stack (most recent call first):
/nix/store/i78xz11da295kd8ynsjmxvi2r56rbhzw-clion-2024.1.3/clion/bin/cmake/linux/x64/share/cmake-3.28/Modules/FindPkgConfig.cmake:841 (_pkg_check_modules_internal)
CMakeLists.txt:20 (pkg_check_modules)
-- Configuring incomplete, errors occurred!
I have tried using g++ and ran the following command without any errors.
g++ -o ./build/bin/button_example ./src/main.cpp pkg-config --cflags --libs gtkmm-3.0'`
This is my nix flake:
{
description = "A Nix-flake-based C/C++ development environment with GTK support";
inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit system; };
});
in
{
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell.override
{
# Optionally override stdenv for specific compiler settings:
# stdenv = pkgs.clangStdenv;
}
{
packages = with pkgs; [
clang-tools
cmake
codespell
conan
cppcheck
doxygen
gtest
lcov
vcpkg
vcpkg-tool
gtkmm3
pkg-config
] ++ (if system == "aarch64-darwin" then [ ] else [ gdb ]);
};
});
};
}`
and this is my cmakelists.txt:
# Minimum CMake version
cmake_minimum_required(VERSION 3.21)
# Define the project
project(calculator VERSION 1.0 LANGUAGES CXX)
# Enable C++20 standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
# Set the output directory for binaries
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Include directories
include_directories(${CMAKE_SOURCE_DIR}/src)
# Find gtkmm-3.0 package using pkg-config
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTKMM REQUIRED gtkmm3)
# Include GTKMM directories and link libraries
include_directories(${GTKMM_INCLUDE_DIRS})
link_directories(${GTKMM_LIBRARY_DIRS})
add_definitions(${GTKMM_CFLAGS_OTHER})
# Add the source files
file(GLOB_RECURSE SOURCES "src/*.cpp")
# Create the executable
add_executable(calculator ${SOURCES})
# Link GTKMM libraries
target_link_libraries(calculator ${GTKMM_LIBRARIES})
I have tried using different gtk versions with no luck. I get the same error no matter what, unless I use g++. I'm new-ish both nix and c++, so don't have many idea's on what else to try.
gtkmm-3.0package, then specify exactly that name inpkg_check_modulescall:pkg_check_modules(GTKMM REQUIRED gtkmm-3.0)/home/eris/Projects/calculator-cpp/src/main.cpp:1:10: fatal error: gtkmm-3.0: No such file or directory 1 | #include <gtkmm-3.0> | ^~~~~~~~~~~ive also tried gtkmm3 instead and gtkmm3.hgtkmm.h: gnome.pages.gitlab.gnome.org/gtkmm