Commit 5bcd5efb authored by Ghislain MARY's avatar Ghislain MARY

Improve generation of RPM specfile.

parent d867082b
bctoolbox.spec
......@@ -56,8 +56,6 @@ include(CMakePushCheckState)
include(GNUInstallDirs)
include(cmake/BcToolboxCMakeUtils.cmake)
add_subdirectory(build)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(NOT CPACK_GENERATOR AND NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
......@@ -179,6 +177,8 @@ if(ENABLE_TESTS AND ENABLE_TESTS_COMPONENT AND BCUNIT_FOUND)
add_subdirectory(tester)
endif()
add_subdirectory(build)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/BcToolboxConfigVersion.cmake"
......
......@@ -48,7 +48,8 @@ endif()
message("-- Package file name is ${CPACK_PACKAGE_FILE_NAME}" )
set(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rpm/bctoolbox.spec.cmake ${CMAKE_CURRENT_SOURCE_DIR}/../bctoolbox.spec)
bc_generate_rpm_specfile("rpm/bctoolbox.spec.cmake" "${PROJECT_SOURCE_DIR}/bctoolbox.spec")
include(CPack)
# -*- rpm-spec -*-
## rpmbuild options
# These 2 lines are here because we can build the RPM for flexisip, in which
# case we prefix the entire installation so that we don't break compatibility
# with the user's libs.
# To compile with bc prefix, use rpmbuild -ba --with bc [SPEC]
%define pkg_name %{?_with_bc:bc-bctoolbox}%{!?_with_bc:bctoolbox}
%{?_with_bc: %define _prefix /opt/belledonne-communications}
%define tests_component %{?_without_tests_component:0}%{?!_without_tests_component:1}
%define pkg_prefix %{?_with_bc:bc-}%{!?_with_bc:}
%define _prefix @CMAKE_INSTALL_PREFIX@
%define pkg_prefix @BC_PACKAGE_NAME_PREFIX@
# re-define some directories for older RPMBuild versions which don't. This messes up the doc/ dir
# taken from https://fedoraproject.org/wiki/Packaging:RPMMacros?rd=Packaging/RPMMacros
......@@ -24,7 +16,7 @@
Name: %{pkg_name}
Name: @CPACK_PACKAGE_NAME@
Version: @PROJECT_VERSION@
Release: %{build_number}%{?dist}
Summary: Belr is language recognition library for ABNF based protocols.
......@@ -61,7 +53,7 @@ Libraries and headers required to develop software with bctoolbox
%setup -n %{name}-%{version}%{?build_number_ext}
%build
%{expand:%%%cmake_name} . -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} -DCMAKE_PREFIX_PATH:PATH=%{_prefix} -DENABLE_TESTS=NO -DENABLE_TESTS_COMPONENT=${tests_component}
%{expand:%%%cmake_name} . -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} -DCMAKE_PREFIX_PATH:PATH=%{_prefix} @RPM_ALL_CMAKE_OPTIONS@
make %{?_smp_mflags}
%install
......@@ -96,7 +88,7 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/bctoolbox/cmake/BcToolboxTargets-noconfig.cmake
%{_datadir}/bctoolbox/cmake/BcToolboxTargets.cmake
%{_datadir}/bctoolbox/cmake/gitversion.h.in
%if %{tests_component}
%if @ENABLE_TESTS_COMPONENT@
%{_libdir}/libbctoolbox-tester.a
%{_libdir}/libbctoolbox-tester.so
%{_libdir}/pkgconfig/bctoolbox-tester.pc
......
......@@ -106,3 +106,24 @@ macro(bc_project_build_version PROJECT_VERSION PROJECT_BUILD_VERSION)
set(PROJECT_VERSION_BUILD 0)
endif()
endmacro()
macro(bc_generate_rpm_specfile SOURCE DEST)
set(BC_PACKAGE_NAME_PREFIX "" CACHE STRING "Prefix for name of package.")
get_cmake_property(_variableNames VARIABLES)
set(RPM_ALL_CMAKE_OPTIONS "")
foreach(_variableName ${_variableNames})
if(_variableName MATCHES "^ENABLE_")
if(_variableName)
set(${_variableName} 1)
else()
set(${_variableName} 0)
endif()
set(RPM_ALL_CMAKE_OPTIONS "${RPM_ALL_CMAKE_OPTIONS} -D${_variableName}=${${_variableName}}")
endif()
endforeach()
configure_file(${SOURCE} ${DEST} @ONLY)
unset(RPM_ALL_CMAKE_OPTIONS)
unset(_variableNames)
endmacro()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment