Skip to content
This repository was archived by the owner on Apr 16, 2026. It is now read-only.

Commit d666d09

Browse files
committed
Link against host Glibmm using pkg-config
1 parent 6c0a74e commit d666d09

10 files changed

Lines changed: 59 additions & 29 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ cmake_minimum_required(VERSION 3.26.5)
66
# so that it works well with tools like CPM or other
77
# manual dependency management
88

9+
# Load PkgConfig so we can use pkg_check_modules later
10+
# to find local packages.
11+
find_package(PkgConfig REQUIRED)
12+
913
# Only set the cxx_standard if it is not set by someone else
1014
if (NOT DEFINED CMAKE_CXX_STANDARD)
1115
set(CMAKE_CXX_STANDARD 23)

Dependencies.cmake

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,6 @@ function(cloysterhpc_setup_dependencies)
8686
endif()
8787
endif()
8888

89-
if(NOT TARGET glibmm::glibmm)
90-
if (cloysterhpc_ENABLE_CONAN)
91-
CPMFindPackage(NAME glibmm)
92-
else()
93-
CPMAddPackage("gh:GNOME/glibmm@2.78.1")
94-
endif()
95-
endif()
96-
9789
if(NOT TARGET SDBusCpp::sdbus-c++)
9890
if (cloysterhpc_ENABLE_CONAN)
9991
CPMFindPackage(NAME sdbus-c++)
@@ -123,13 +115,29 @@ function(cloysterhpc_setup_dependencies)
123115
endif()
124116

125117
# Standalone packages
118+
include(FindPackageHandleStandardArgs)
119+
126120
# Include module path for packages that we need to find or build
127121
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
128122
include(cmake/Findnewt.cmake)
129123
if(NOT TARGET newt)
130124
CPMFindPackage(NAME newt)
131125
endif()
132126

127+
if(NOT TARGET glibmm)
128+
pkg_check_modules(GLIBMM REQUIRED glibmm-2.4)
129+
130+
message(STATUS "GLIBMM_LIBRARIES=${GLIBMM_LIBRARIES}")
131+
message(STATUS "GLIBMM_INCLUDE_DIRS=${GLIBMM_INCLUDE_DIRS}")
132+
find_package_handle_standard_args(glibmm
133+
DEFAULT_MSG
134+
GLIBMM_LIBRARIES
135+
GLIBMM_INCLUDE_DIRS)
136+
137+
mark_as_advanced(GLIBMM_INCLUDE_DIRS GLIBMM_LIBRARIES)
138+
# include_directories(${GLIBMM_INCLUDE_DIRS})
139+
endif()
140+
133141
# Set the variable ${STDC++FS} to the correct library
134142
include(cmake/Addstdcppfs.cmake)
135143

buildrpm.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
#!/bin/bash -eu
22

3+
SUPPORTED_BUILD_DISTS=(rocky)
4+
ID=$(awk -F= '/^ID=/ { gsub("\"" , "", $2); print $2}' /etc/os-release)
5+
6+
case "${SUPPORTED_BUILD_DISTS[*]}" in
7+
"${ID}")
8+
;;
9+
*)
10+
echo "Build RPM Environment not supported, you need to run this" \
11+
"in one of these distros: ${SUPPORTED_BUILD_DISTS}"
12+
exit -1
13+
;;
14+
esac
15+
16+
exit 0
17+
18+
319
VERSION=$(awk '/Version:/ {print $2}' rpmspecs/opencattus.spec)
420
cp rpmspecs/opencattus.spec ~/rpmbuild/SPECS/
521
git archive -o ~/rpmbuild/SOURCES/opencattus-${VERSION}.tar.gz \
6-
--format tgz HEAD --prefix opencattus-${VERSION}/
22+
--format tgz HEAD --prefix opencattus-${VERSION}/
723
rpmbuild -ba ~/rpmbuild/SPECS/opencattus.spec
824
echo "RPM Generated"
925
ls -l ~/rpmbuild/RPMS/*/opencattus-installer*.rpm

cmake/CommonLibraries.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ set(COMMON_LIBS
99
Boost::thread
1010
spdlog::spdlog
1111
gsl::gsl-lite
12-
glibmm::glibmm
12+
${GLIBMM_LIBRARIES}
1313
magic_enum::magic_enum
1414
SimpleIni::SimpleIni
1515
resolv

conanfile.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from conan import ConanFile
22
from conan.tools.cmake import cmake_layout, CMakeToolchain, CMake
3+
from conan.tools.gnu import PkgConfigDeps
34

45
class MyProjectConan(ConanFile):
56
name = "CloysterHPC"
67
version = "0.1.1"
7-
88
settings = "os", "arch", "compiler", "build_type"
99

1010
def requirements(self):
11+
self.tool_requires("pkgconf/1.9.3") # Ensure pkg-config is available
1112
self.requires("cli11/[>=2.4.0 <2.5.0]")
1213
self.requires("spdlog/[>=1.14.0 <1.15.0]")
1314
self.requires("fmt/[>=10.0.0 <12.0.0]")
@@ -16,7 +17,7 @@ def requirements(self):
1617
self.requires("gsl-lite/[>=0.41.0 <0.42.0]")
1718
self.requires("doctest/[>=2.4.0 <2.5.0]")
1819
self.requires("sdbus-cpp/[>=2.0.0 <2.1.0]")
19-
self.requires("glibmm/[>=2.78.1 <2.79.0]")
20+
# self.requires("glibmm/[>=2.78.1 <2.79.0]")
2021

2122
# Override libmount to unify on 2.39.2.
2223
# This prevents the conflict with glib and sdbus-cpp requirements.
@@ -30,6 +31,8 @@ def layout(self):
3031
def generate(self):
3132
tc = CMakeToolchain(self)
3233
tc.generate()
34+
pkg = PkgConfigDeps(self)
35+
pkg.generate()
3336

3437
def build(self):
3538
cmake = CMake(self)

include/cloysterhpc/functions.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,10 @@
55
#include <boost/process/child.hpp>
66
#include <boost/process/pipe.hpp>
77
#include <cloysterhpc/services/repos.h>
8-
#include <concepts>
98
#include <filesystem>
10-
#include <glibmm/ustring.h>
9+
// #include <glibmm/ustring.h>
1110
#include <list>
1211
#include <optional>
13-
#include <ranges>
1412
#include <string>
1513

1614
#include <boost/asio.hpp>

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ target_link_system_libraries(
2121

2222
# Build a library and a ${cloysterhpc_BINARY_NAME} binary that links to the library
2323
add_library(cloysterhpc_object OBJECT ${SOURCE_FILES})
24+
25+
# Include glibmm headers as SYSTEM header to avoid warnings
26+
target_include_directories(cloysterhpc_object SYSTEM PRIVATE ${GLIBMM_INCLUDE_DIRS})
27+
2428
# add_library(cloysterhpc_static STATIC $<TARGET_OBJECTS:cloysterhpc_object>)
2529
add_library(cloysterhpc_static STATIC $<TARGET_OBJECTS:cloysterhpc_object> $<TARGET_OBJECTS:cloysterhpc_presenter_object>)
2630
add_executable(${cloysterhpc_BINARY_NAME} main.cpp)

src/diskImage.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
#include <cloysterhpc/services/log.h>
1111
#include <cstddef>
1212
#include <fstream>
13-
#include <glibmm/checksum.h>
1413
#include <ios>
1514
#include <istream>
1615
#include <unordered_map>
1716
#include <vector>
1817

18+
#include <glibmm.h>
19+
1920
// @FIXME: This file need some work
2021
//
2122
// - The ISO can be probed for more information usign isoinfo command
@@ -108,7 +109,7 @@ bool DiskImage::hasVerifiedChecksum(const std::filesystem::path& path)
108109
"e" }
109110
};
110111

111-
Glib::Checksum checksum(Glib::Checksum::Type::SHA256);
112+
Glib::Checksum checksum(Glib::Checksum::ChecksumType::CHECKSUM_SHA256);
112113

113114
std::ifstream file(path, std::ios::in | std::ios::binary);
114115
if (!file.is_open()) {
@@ -122,14 +123,14 @@ bool DiskImage::hasVerifiedChecksum(const std::filesystem::path& path)
122123

123124
while (file.read(reinterpret_cast<std::istream::char_type*>(buffer.data()),
124125
static_cast<std::streamsize>(buffer.size()))) {
125-
std::streamsize bytesRead = file.gcount();
126+
auto bytesRead = static_cast<gsize>(file.gcount());
126127

127128
checksum.update(
128129
reinterpret_cast<const unsigned char*>(buffer.data()), bytesRead);
129130
}
130131

131132
// Handle any leftover bytes after the while loop ends
132-
std::streamsize bytesRead = file.gcount();
133+
auto bytesRead = static_cast<gsize>(file.gcount());
133134
if (bytesRead > 0) {
134135
checksum.update(
135136
reinterpret_cast<const unsigned char*>(buffer.data()), bytesRead);

src/main.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#include <cctype>
77
#include <cstdlib>
88

9-
#include <glibmm/fileutils.h>
10-
#include <glibmm/keyfile.h>
11-
129
#include <CLI/CLI.hpp>
1310
#include <cloysterhpc/cloyster.h>
1411
#include <cloysterhpc/const.h>

src/services/files.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace cloyster::services::files {
1313

1414
struct KeyFile::Impl {
1515
std::filesystem::path m_path;
16-
Glib::RefPtr<Glib::KeyFile> m_keyfile;
16+
std::unique_ptr<Glib::KeyFile> m_keyfile;
1717

18-
Impl(Glib::RefPtr<Glib::KeyFile>&& keyfile, std::filesystem::path path)
18+
Impl(Glib::KeyFile&& keyfile, std::filesystem::path path)
1919
: m_path(std::move(path))
20-
, m_keyfile(std::move(keyfile)) { };
20+
, m_keyfile(std::make_unique<Glib::KeyFile>(std::move(keyfile))) { };
2121

2222
void safeToFile(const std::filesystem::path& path)
2323
{
@@ -59,7 +59,7 @@ KeyFile::KeyFile(KeyFile::Impl&& impl)
5959
}
6060

6161
KeyFile::KeyFile(const std::filesystem::path& path)
62-
: m_impl(std::make_unique<KeyFile::Impl>(Glib::KeyFile::create(), path))
62+
: m_impl(std::make_unique<KeyFile::Impl>(Glib::KeyFile(), path))
6363
{
6464
m_impl->m_path = path;
6565
m_impl->loadFromFile(path);
@@ -90,9 +90,8 @@ std::string KeyFile::getString(
9090
std::optional<std::string> KeyFile::getStringOpt(
9191
const std::string& group, const std::string& key) const
9292
{
93-
auto keyFile = m_impl->m_keyfile;
94-
if (keyFile->has_key(group, key)) {
95-
return keyFile->get_string(group, key).raw();
93+
if (m_impl->m_keyfile->has_key(group, key)) {
94+
return m_impl->m_keyfile->get_string(group, key).raw();
9695
}
9796
return std::nullopt;
9897
}

0 commit comments

Comments
 (0)