My CMake.txt file content:
cmake_minimum_required(VERSION 2.8.9)
project(Bonsole)
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
add_definitions( -DINSTALL_PATH="${INSTALL_PATH}" )
add_definitions( -DDATA_PATH="${CMAKE_INSTALL_FULL_DATADIR}/Bonsole/" )
add_definitions( -DLIB_PATH="${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" )
find_package(PkgConfig REQUIRED)
pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0 webkit2gtk-4.0 )
pkg_check_modules(DBUS REQUIRED IMPORTED_TARGET dbus-1 )
pkg_check_modules(libxslt REQUIRED IMPORTED_TARGET libxslt)
file(GLOB BONSOLE_SRC Bonsole/*.c)
file(GLOB client_library lib/client_lib/*.c lib/client_lib/error_handling/*.c )
add_library( normal SHARED lib/bonsole-backends/normal.c )
target_link_libraries( normal PkgConfig::DBUS BonsoleHelper )
add_library( console SHARED lib/bonsole-backends/console.c )
add_library( BonsoleHelper SHARED helper/polling.c helper/polling.h helper/strings.c helper/strings.h )
target_link_libraries( BonsoleHelper PkgConfig::DBUS PkgConfig::libxslt)
add_library( BonsoleClient SHARED ${client_library} )
target_link_libraries( BonsoleClient PkgConfig::libxslt )
target_link_libraries( BonsoleClient dl )
add_executable( Bonsole ${BONSOLE_SRC} )
target_link_libraries( Bonsole PUBLIC PkgConfig::GTK PkgConfig::DBUS BonsoleHelper )
target_link_libraries( BonsoleClient BonsoleHelper )
set_target_properties( BonsoleClient PROPERTIES SOVERSION 0)
set_target_properties( Bonsole PROPERTIES VERSION 0.0.4)
set_target_properties( normal PROPERTIES SOVERSION 0.0.4)
set_target_properties( BonsoleHelper PROPERTIES SOVERSION 0.0.4)
set_target_properties( console PROPERTIES SOVERSION 0.0.4)
set_target_properties(normal PROPERTIES OUTPUT_NAME "bonsole-libnormal.so-0.0.4.0")
set_target_properties(normal PROPERTIES SUFFIX "")
set_target_properties(normal PROPERTIES PREFIX "")
set_target_properties(console PROPERTIES OUTPUT_NAME "bonsole-libconsole.so.0-0.0.4")
set_target_properties(console PROPERTIES SUFFIX "")
set_target_properties(console PROPERTIES PREFIX "")
INSTALL( TARGETS Bonsole RUNTIME DESTINATION bin COMPONENT WebBasedClient)
INSTALL( TARGETS BonsoleClient LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ClientLib)
INSTALL( TARGETS BonsoleHelper LIBRARY DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} COMPONENT HelperLib)
INSTALL( TARGETS normal
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/bonsole/bonsole-backends COMPONENT WebBasedBackend)
INSTALL( TARGETS
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/bonsole/bonsole-backends COMPONENT ConsoleBackend)
INSTALL(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/data/dtd/" DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/Bonsole/dtd/ COMPONENT Schema )
INSTALL(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/data/etc/" DESTINATION etc COMPONENT Configuration )
INSTALL(DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/data/xslt/" DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/Bonsole/xsl-views COMPONENT Data)
My spec file is:
Version: 0.0.4
Release: 0.0.4
Summary: This package providces a wrapper for BonsoleRTA backends
License: GPL-3.0-or-later
BuildRequires: cmake dbus-1-devel gcc-c++ webkit2gtk3-devel gtk3-devel dbus-1-devel gcc-c++ libxslt-devel
Requires: dbus-1
Requires: BomsoleRTA-client-lib-backend
URL: https://sourceforge.net/projects/Bonsole
Source0: https://sourceforge.net/projects/bonsole/files/Sources/BonsoleRTA-GUI-client-%{version}.tar.gz
Provides: libBonsoleClient.so libBonsoleClient.so.0.%{version}
%define short_name libBonsoleClient.so
%define library_name %{short_name}-%{version}
%description
BonsoleRTA-client-lib is library needed for BonsoleRTA applications to work properly
%prep
%setup -q
%build
%cmake
%cmake_build BonsoleClient
%install
mkdir -p %{buildroot}/%{_libdir}
mkdir -p %{buildroot}/usr/share/Bonsole/xsl-views
mkdir -p %{buildroot}/usr/etc
cd build
DESTDIR=%{buildroot}/ cmake --install . --component ClientLib -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
DESTDIR=%{buildroot}/ cmake --install . --component Configuration -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
DESTDIR=%{buildroot}/ cmake --install . --component Schema -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
DESTDIR=%{buildroot}/ cmake --install . --component Data -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
mv %{buildroot}/%{_prefix}/%{_lib}/%{short_name}.0 %{buildroot}/%{_prefix}/%{_lib}/%{library_name}
install -dm 0655 data/xslt %{buildroot}/usr/share/Bonsole/xsl-views
rm /%{buildroot}/%{_prefix}/%{_lib}/libBonsoleClient.so
%post
/sbin/ldconfig
%postun
/sbin/ldconfig
%files
%{_libdir}/%{short_name}*
/usr/share/Bonsole
/usr/etc/bonsole-app-suggested.cnf
%changelog
* Thu Apr 22 2021 Sławomir Lach <slawek@lach.art.pl>
-
I known it’s maybe buggy (mixed library and configuration), but it still built on my machine and I still learn. It sems that ${CMAKE_INSTALL_FULL_DATAROOTDIR} expression was expand to empty string.