Store the version in version.cpp and group the library under src/core

libdpm-core.so's version was reaching the source as a compile-line
definition, with a fallback in two translation units that would have let
the library build and report 0.0.0 if the build ever stopped supplying
it. The version is a literal in src/core/version.cpp, the file named for
it, alongside dpm_core_version() which returns it and the parser for the
X.Y.Z strings modules report.

The library's sources and its version script move to src/core, leaving
src/cli, src/bundled-modules, and the documentation source beside it.
This commit is contained in:
2026-08-15 22:57:46 -04:00
parent d3f134aabf
commit b641318663
5 changed files with 16 additions and 23 deletions

View File

@@ -8,9 +8,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
# libdpm-core.so — the library (C ABI)
# ---------------------------------------------------------------------
add_library(dpm-core SHARED
src/context.cpp
src/modules.cpp
src/version.cpp
src/core/context.cpp
src/core/modules.cpp
src/core/version.cpp
)
target_include_directories(dpm-core PUBLIC
@@ -18,10 +18,6 @@ target_include_directories(dpm-core PUBLIC
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(dpm-core PRIVATE
DPM_CORE_VERSION_STR="${PROJECT_VERSION}"
)
# The public C API is the library's entire exported surface; internals
# stay hidden. The version script pins the export list and versions the
# symbols.
@@ -30,10 +26,10 @@ target_compile_options(dpm-core PRIVATE
-fvisibility-inlines-hidden
)
target_link_options(dpm-core PRIVATE
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/libdpm-core.map
-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/core/libdpm-core.map
)
set_property(TARGET dpm-core APPEND PROPERTY
LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/libdpm-core.map
LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/core/libdpm-core.map
)
target_link_libraries(dpm-core PRIVATE ${CMAKE_DL_LIBS})