From rauty at altlinux.org Tue Nov 10 07:18:20 2026 From: rauty at altlinux.org (Ajrat Makhmutov) Date: Wed Nov 11 08:57:54 2026 Subject: [studxml-users] [PATCH 0/1] Linux CMake build with system Expat and pkg-config metadata Message-ID: <20261110121953.3325953-1-rauty@altlinux.org> I am packaging libstudxml for ALT Linux for use by Scilab. Scilab's Autotools build needs pkg-config metadata describing the installed library's public include paths, compiler definitions and dependencies. This patch adds an alternative Linux CMake build using system Expat and the bundled private Genx implementation. It preserves the native build2 workflow and the libstudxml-1.1.so SONAME. I tested it on ALT Linux x86_64: package build, upstream parser and serializer tests, all five XML roundtrip tests against the installed library, and a CMake add_subdirectory consumer. Would you consider supporting this alternative build path? Best regards, Ajrat Makhmutov In-Reply-To: From rauty at altlinux.org Tue Nov 10 07:18:21 2026 From: rauty at altlinux.org (Ajrat Makhmutov) Date: Wed Nov 11 08:57:54 2026 Subject: [studxml-users] [PATCH] build: Add Linux CMake build with system Expat and pkg-config metadata In-Reply-To: <20261110121953.3325953-1-rauty@altlinux.org> References: <20261110121953.3325953-1-rauty@altlinux.org> Message-ID: <20261110121953.3325953-2-rauty@altlinux.org> Linux distributions need a build path using their packaged Expat. Scilab's Autotools build also needs the public include paths, compiler definitions and transitive dependencies of the installed library. Keeping this information with libstudxml avoids duplicating its build requirements in each consumer. --- CMakeLists.txt | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ INSTALL | 10 ++++++++ buildfile | 3 ++- libstudxml.pc.in | 11 +++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt create mode 100644 libstudxml.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..98c2df7 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,64 @@ +cmake_minimum_required(VERSION 3.20) + +file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/manifest" release_version REGEX "^version: ") +if(NOT release_version MATCHES "^version: ([0-9]+\\.[0-9]+\\.[0-9]+)$") + message(FATAL_ERROR "The CMake build requires a stable release version in manifest") +endif() +project(libstudxml VERSION "${CMAKE_MATCH_1}" LANGUAGES C CXX) + +if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") + message(FATAL_ERROR "The libstudxml CMake build supports only Linux; use build2 on other platforms") +endif() + +include(GNUInstallDirs) +find_package(EXPAT 2.1 REQUIRED) + +set(LIBSTUDXML_ABI_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}") +math(EXPR libstudxml.version.project_number + "${PROJECT_VERSION_MAJOR} * 100000000000000 + ${PROJECT_VERSION_MINOR} * 1000000000 + ${PROJECT_VERSION_PATCH} * 10000") +set(libstudxml.version.project "${PROJECT_VERSION}") +set(libstudxml.version.project_id "${PROJECT_VERSION}") +set(libstudxml.version.major "${PROJECT_VERSION_MAJOR}") +set(libstudxml.version.minor "${PROJECT_VERSION_MINOR}") +set(libstudxml.version.patch "${PROJECT_VERSION_PATCH}") +set(libstudxml.version.pre_release false) +set(libstudxml.version.snapshot_sn 0) +set(libstudxml.version.snapshot_id "") +file(READ "${CMAKE_CURRENT_SOURCE_DIR}/libstudxml/version.hxx.in" version_header) +string(REGEX REPLACE "\\$([a-z_.]+)\\$" "@\\1@" version_header "${version_header}") +string(CONFIGURE "${version_header}" version_header @ONLY) +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/libstudxml") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/libstudxml/version.hxx" "${version_header}") + +file(GLOB_RECURSE STUDXML_SOURCES CONFIGURE_DEPENDS "libstudxml/*.cxx") +add_library(studxml SHARED ${STUDXML_SOURCES} + libstudxml/details/genx/genx.c + libstudxml/details/genx/char-props.c) +set_target_properties(studxml PROPERTIES OUTPUT_NAME "studxml-${LIBSTUDXML_ABI_VERSION}") +target_compile_features(studxml PUBLIC cxx_std_11) +target_compile_definitions(studxml + PUBLIC LIBSTUDXML_EXTERNAL_EXPAT + PRIVATE LIBSTUDXML_SHARED_BUILD + INTERFACE LIBSTUDXML_SHARED) +target_include_directories(studxml PUBLIC + $ + $ + $) +target_link_libraries(studxml PUBLIC EXPAT::EXPAT) +add_custom_command(TARGET studxml POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E create_symlink + "$" "$/libstudxml.so" + VERBATIM) + +if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + configure_file(libstudxml.pc.in libstudxml.pc @ONLY) + install(TARGETS studxml LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(FILES "$/libstudxml.so" DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(DIRECTORY libstudxml/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libstudxml + FILES_MATCHING PATTERN "*.hxx" PATTERN "*.ixx" PATTERN "*.txx" PATTERN "*.h" + PATTERN "version.hxx" EXCLUDE PATTERN "expat" EXCLUDE) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libstudxml/version.hxx" + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libstudxml) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libstudxml.pc" + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() diff --git a/INSTALL b/INSTALL index 7f65e33..8acd618 100644 --- a/INSTALL +++ b/INSTALL @@ -4,3 +4,13 @@ $ bpkg build libstudxml But if you don't want to use the package manager, then you can also build it manually using the standard build2 build system. + +On Linux, an alternative CMake build uses system Expat (2.1 or later) and +requires a C++11 compiler: + +$ cmake -S . -B cmake-build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr +$ cmake --build cmake-build +$ cmake --install cmake-build + +This builds a shared library with the private Genx implementation and +installs headers and libstudxml.pc for pkg-config consumers. diff --git a/buildfile b/buildfile index 46857d8..8e94bc6 100644 --- a/buildfile +++ b/buildfile @@ -1,7 +1,8 @@ # file : buildfile # license : MIT; see accompanying LICENSE file -./: {*/ -build/} doc{INSTALL NEWS README} legal{LICENSE} manifest +./: {*/ -build/} doc{INSTALL NEWS README} legal{LICENSE} manifest \ + file{CMakeLists.txt libstudxml.pc.in} # Don't install examples, tests or the INSTALL file. # diff --git a/libstudxml.pc.in b/libstudxml.pc.in new file mode 100644 index 0000000..c1d21b8 --- /dev/null +++ b/libstudxml.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@CMAKE_INSTALL_FULL_LIBDIR@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: libstudxml +Description: Streaming XML pull parser and serializer for C++ +Version: @PROJECT_VERSION@ +Requires: expat >= 2.1.0 +Libs: -L${libdir} -lstudxml +Cflags: -I${includedir} -DLIBSTUDXML_EXTERNAL_EXPAT -DLIBSTUDXML_SHARED -- 2.50.1 From boris at codesynthesis.com Wed Nov 11 09:03:03 2026 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Nov 11 09:03:16 2026 Subject: [studxml-users] [PATCH 0/1] Linux CMake build with system Expat and pkg-config metadata In-Reply-To: <20261110121953.3325953-1-rauty@altlinux.org> References: <20261110121953.3325953-1-rauty@altlinux.org> Message-ID: Ajrat Makhmutov writes: > This patch adds an alternative Linux CMake build [...] > > Would you consider supporting this alternative build path? Unfortunately, not: I have no bandwidth (nor interest) to maintain CMake support long-term. The best I can offer is for you to create a PR (or issue) with the patch that I will keep open, so others can easily find it if they are also interested in CMake. You can do it on the GitHub mirror of the repository: https://github.com/codesynthesis-com/libstudxml From rauty at altlinux.org Wed Nov 11 09:16:50 2026 From: rauty at altlinux.org (Ajrat Makhmutov) Date: Wed Nov 11 09:17:10 2026 Subject: [studxml-users] [PATCH 0/1] Linux CMake build with system Expat and pkg-config metadata In-Reply-To: References: <20261110121953.3325953-1-rauty@altlinux.org> Message-ID: Ok! Thank you for the quick response, I?ll do it! 11.11.2026 17:03, Boris Kolpackov ?????: > Ajrat Makhmutov writes: > >> This patch adds an alternative Linux CMake build [...] >> >> Would you consider supporting this alternative build path? > Unfortunately, not: I have no bandwidth (nor interest) to maintain > CMake support long-term. > > The best I can offer is for you to create a PR (or issue) with the > patch that I will keep open, so others can easily find it if they are > also interested in CMake. You can do it on the GitHub mirror of the > repository: > > https://github.com/codesynthesis-com/libstudxml