4 Commits

Author SHA1 Message Date
AndreaRigoni
e09a614fa5 refactor: add override specifier to type_name method in Core/Types.h 2026-04-03 10:14:20 +00:00
AndreaRigoni
7f6323403d merge andrea-geo: geometry/material/property system features
Merges all work from andrea-geo branch:
- Geant material management classes
- Serialization enhancements (read-only, NVP/HRP macros)
- Transform/assembly system improvements
- VTK puppet/viewport updates (orthographic toggle, voxel rendering)
- Property grouping, dynamic properties, NotifyPropertiesUpdated
- Object type identification via uLibTypeMacro
- New tests (PropertyGrouping, ReadOnly, vtkQViewport, PuppetParenting)
- Various gcompose UI fixes

Conflict resolved in CMakePresets.json: kept both 'fast' (clang/lld)
and 'mutom' (stub) presets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 08:47:32 +00:00
AndreaRigoni
a53b3051de fix EXPAT::EXPAT-NOTFOUND when building with Geant4 on conda
Geant4's G4EXPATShim creates EXPAT::EXPAT (uppercase) with
IMPORTED_LOCATION set to ${EXPAT_LIBRARY}, which is empty when EXPAT
is found via conda's config-mode package (expat::expat, lowercase).

After find_package(Geant4), patch EXPAT::EXPAT with the real library
path taken from expat::expat IMPORTED_LOCATION_NOCONFIG, falling back
to find_library if needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 08:41:00 +00:00
AndreaRigoni
c53570192f switch to Ninja+ccache, add clang/lld fast build profile
- CMakePresets.json: add 'fast' preset (clang+lld+ccache)
- .gitignore: generalize build/ to build*/, add CMakeUserPresets.json
- CMakeUserPresets.json: untrack (conan-generated, now gitignored)
- src/Core/Archives.h: remove redundant 'using basic_xml_iarchive::load_override'
  in xml_iarchive; caused ambiguous overload with clang (diamond inheritance)
- src/Core/Object.cpp: remove invalid explicit instantiations of non-template
  virtual Object::serialize (GCC extension, clang rejects)
- README.md, CLAUDE.md: document GCC and LLVM/clang build workflows

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03 08:24:50 +00:00
9 changed files with 87 additions and 28 deletions

3
.gitignore vendored
View File

@@ -1,6 +1,7 @@
CMakeFiles/
build/
build*/
.cache/
CMakeUserPresets.json
build_warnings*.log
final_build.log
cmake_configure.log

View File

@@ -12,7 +12,7 @@ export MAMBA_ROOT_PREFIX="/home/share/micromamba"
eval "$(/home/share/micromamba/bin/micromamba shell hook --shell bash)"
micromamba activate mutom
# Configure (from repo root, using Conan preset)
# Configure (from repo root, using Conan preset — uses Ninja + ccache)
cmake --preset conan-release
# Build everything
@@ -40,6 +40,18 @@ conan install . --output-folder=build --build=missing
cmake --preset conan-release
```
### Build acceleration (already configured)
- **Ninja** generator — used automatically via the conan default profile (`~/.conan2/profiles/default`)
- **ccache** — enabled via `CMAKE_CXX_COMPILER_LAUNCHER=ccache`; cached rebuilds are nearly instant (~0.3s vs ~25s cold)
- **Clang 22 + lld** profile available (`~/.conan2/profiles/fast`) but blocked by template overload ambiguities in `src/Core/Archives.h` that need fixing for full compatibility
To reconfigure with the fast profile once Archives.h is fixed:
```bash
conan install . --output-folder=build --build=missing --profile=fast
cmake -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
```
## Architecture
**uLib** is a C++ framework for Cosmic Muon Tomography (CMT), structured as layered shared libraries:

View File

@@ -169,6 +169,26 @@ if(Geant4_FOUND)
add_compile_definitions(HAVE_GEANT4)
set(HAVE_GEANT4 1)
# Workaround: Geant4's G4EXPATShim creates EXPAT::EXPAT (uppercase) with
# IMPORTED_LOCATION "${EXPAT_LIBRARY}", but EXPAT_LIBRARY is empty when using
# conda's config-mode expat package (which installs as expat::expat lowercase).
# Resolve the actual library path from expat::expat or via find_library.
if(TARGET EXPAT::EXPAT)
get_target_property(_expat_loc EXPAT::EXPAT IMPORTED_LOCATION)
if(NOT _expat_loc OR _expat_loc MATCHES "NOTFOUND|^$")
if(TARGET expat::expat)
get_target_property(_expat_loc expat::expat IMPORTED_LOCATION_NOCONFIG)
endif()
if(NOT _expat_loc OR _expat_loc MATCHES "NOTFOUND|^$")
find_library(_expat_loc NAMES expat)
endif()
if(_expat_loc)
set_target_properties(EXPAT::EXPAT PROPERTIES IMPORTED_LOCATION "${_expat_loc}")
endif()
endif()
unset(_expat_loc)
endif()
# Sanitize Geant4 targets to remove Qt5 dependencies that conflict with VTK/Qt6
if(TARGET Geant4::G4interfaces)
set_target_properties(Geant4::G4interfaces PROPERTIES

View File

@@ -12,6 +12,22 @@
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}"
}
},
{
"name": "fast",
"displayName": "Fast build: Ninja + clang + ccache",
"description": "Uses Ninja generator, clang/lld compiler, and ccache",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=lld",
"CMAKE_SHARED_LINKER_FLAGS": "-fuse-ld=lld",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"CMAKE_C_COMPILER_LAUNCHER": "ccache"
}
},
{
"name": "mutom",
"description": "",
@@ -19,4 +35,4 @@
"inherits": []
}
]
}
}

View File

@@ -1,9 +0,0 @@
{
"version": 4,
"vendor": {
"conan": {}
},
"include": [
"build/CMakePresets.json"
]
}

View File

@@ -41,7 +41,11 @@ conda activate mutom
### Configure and Build
1. **Configure Conan profile (if you haven't yet on your machine):**
#### Standard build (GCC + Ninja + ccache)
The default conan profile uses **Ninja** as the generator and **ccache** for compiler caching, dramatically speeding up incremental rebuilds.
1. **Configure Conan profile (first time only):**
```bash
conan profile detect
```
@@ -51,17 +55,39 @@ conan profile detect
conan install . --output-folder=build --build=missing
```
3. **Configure the project with CMake:**
3. **Configure with CMake:**
```bash
cmake --preset conan-release
```
*(Alternatively: `cd build && cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release`)*
4. **Build the project:**
4. **Build:**
```bash
cmake --build build -j10
cmake --build build -j$(nproc)
```
#### LLVM/Clang build (clang + lld + ccache — fastest)
A `fast` conan profile is provided that uses **clang**, **lld** (LLVM linker), and **ccache**. Install them into your environment first:
```bash
micromamba install -n mutom -y clang clangxx lld -c conda-forge
```
Then build using the `fast` profile:
```bash
conan install . --output-folder=build --build=missing --profile=fast
cmake -B build -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=build/conan_toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
```
The `fast` profile is defined at `~/.conan2/profiles/fast` and sets:
- `CMAKE_C_COMPILER=clang` / `CMAKE_CXX_COMPILER=clang++`
- `CMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld`
- `CMAKE_CXX_COMPILER_LAUNCHER=ccache`
### Make python package
```bash

View File

@@ -338,8 +338,6 @@ public:
}
}
using basic_xml_iarchive::load_override;
// Anything not an attribute should be a name value pair as nvp or hrp
typedef boost::archive::detail::common_iarchive<Archive>
detail_common_iarchive;
@@ -357,6 +355,9 @@ public:
// class_name_type can't be handled here as it depends upon the
// char type used by the stream. So require the derived implementation.
// derived in this case is xml_iarchive_impl or base ..
// Note: using base::load_override covers all basic_xml_iarchive overloads
// transitively, so a separate 'using basic_xml_iarchive::load_override'
// is redundant and creates ambiguity with clang.
using base::load_override;
void load_override(const char *str) {

View File

@@ -121,14 +121,6 @@ void Object::PropertyUpdated() { ULIB_SIGNAL_EMIT(Object::PropertyUpdated); }
template <class ArchiveT>
void Object::save_override(ArchiveT &ar, const unsigned int version) {}
// Explicitly instantiate for all uLib archives
template void Object::serialize(Archive::xml_oarchive &, const unsigned int);
template void Object::serialize(Archive::xml_iarchive &, const unsigned int);
template void Object::serialize(Archive::text_oarchive &, const unsigned int);
template void Object::serialize(Archive::text_iarchive &, const unsigned int);
template void Object::serialize(Archive::hrt_oarchive &, const unsigned int);
template void Object::serialize(Archive::hrt_iarchive &, const unsigned int);
template void Object::serialize(Archive::log_archive &, const unsigned int);
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

View File

@@ -182,7 +182,7 @@ typedef bool Bool_t; // Boolean (0=false, 1=true) (bool)
\
public: \
typedef type_info::BaseClass BaseClass; \
virtual const char *type_name() const { return type_info::name; } \
virtual const char *type_name() const override { return type_info::name; } \
/**/
/**