Moving to CMake

1) Easier for maintainer to troubleshoot [same person maintains
upstream]
2) Gives us the benefit of setting SOVERSION for dependent packages
3) Added -python package
4) Split out -utilities
This commit is contained in:
Greg Hellings 2014-12-09 14:15:31 -06:00
parent 781f92f6c0
commit 7c8af64b36
3 changed files with 267 additions and 20 deletions

16
install_swig_destdir.diff Normal file
View File

@ -0,0 +1,16 @@
diff --git a/bindings/swig/python/CMakeLists.txt b/bindings/swig/python/CMakeLists.txt
index b661654..f608d50 100644
--- a/bindings/swig/python/CMakeLists.txt
+++ b/bindings/swig/python/CMakeLists.txt
@@ -45,9 +45,9 @@ ADD_CUSTOM_TARGET(swordswig ALL
# Allow user installation to custom directory
IF(SWORD_PYTHON_INSTALL_DIR)
- SET(SETUP_ARGS "--home=${SWORD_PYTHON_INSTALL_DIR}")
+ SET(SETUP_ARGS "--home=${SWORD_PYTHON_INSTALL_DIR} --root \$ENV{DESTDIR}")
ELSE(SWORD_PYTHON_INSTALL_DIR)
- SET(SETUP_ARGS "--home=${CMAKE_INSTALL_PREFIX}")
+ SET(SETUP_ARGS "--root \$ENV{DESTDIR}")
ENDIF(SWORD_PYTHON_INSTALL_DIR)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/install.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/install.cmake")

159
standard_cmake_args.diff Normal file
View File

@ -0,0 +1,159 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 785e14b..d945a2a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -119,10 +119,10 @@ ENDIF(LIBSWORD_LIBRARY_TYPE MATCHES ".*Static.*" OR NOT LIBSWORD_LIBRARY_TYPE)
################################################################################################
# Some random user settings
#
-
-IF(NOT SWORD_GLOBAL_CONF_DIR STREQUAL "")
- ADD_DEFINITIONS(-DGLOBCONFPATH="${SWORD_GLOBAL_CONF_DIR}/sword.conf")
-ENDIF(NOT SWORD_GLOBAL_CONF_DIR STREQUAL "")
+ADD_DEFINITIONS(-DGLOBCONFPATH="${SYSCONF_INSTALL_DIR}/sword.conf")
+SET(CONFFILE "[Install]
+DataPath=${SHARE_INSTALL_PREFIX}/sword")
+FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sword.conf" "${CONFFILE}")
###############################################################################################
diff --git a/cmake/install.cmake b/cmake/install.cmake
index fd79545..f71f6a0 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -3,34 +3,39 @@
#
MESSAGE(STATUS "\n-- CONFIGURING INSTALLATION DESTINATIONS")
# Configuration files, of course
-SET(prefix "${PREFIX}")
-SET(exec_prefix "${PREFIX}")
-SET(libdir "${LIBDIR}")
-SET(includedir "${INCLUDEDIR}")
# Install the library
IF(BUILDING_SHARED)
INSTALL(TARGETS sword
- DESTINATION "${LIBDIR}")
+ RUNTIME DESTINATION "${BINDIR}"
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
ENDIF(BUILDING_SHARED)
IF(BUILDING_STATIC)
INSTALL(TARGETS sword_static
- DESTINATION "${LIBDIR}")
+ RUNTIME DESTINATION "${BINDIR}"
+ LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
+ ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
ENDIF(BUILDING_STATIC)
# Install the locales
INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/locales.d
- DESTINATION "${PREFIX}/share/sword")
+ DESTINATION "${SHARE_INSTALL_PREFIX}/sword")
# Install the headers
INSTALL(FILES ${SWORD_INSTALL_HEADERS}
- DESTINATION "${INCLUDEDIR}/sword")
+ DESTINATION "${INCLUDE_INSTALL_DIR}/sword")
+# Install sysconf file
+INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/sword.conf"
+ DESTINATION "${SYSCONF_INSTALL_DIR}")
+# Create the mods.d
+INSTALL(DIRECTORY DESTINATION "${SHARE_INSTALL_PREFIX}/sword/mods.d")
IF(SWORD_INTERNAL_REGEX)
INSTALL(FILES ${INTERNAL_REGEX_HEADER}
- DESTINATION "${INCLUDEDIR}/sword")
+ DESTINATION "${INCLUDE_INSTALL_DIR}/sword")
ENDIF(SWORD_INTERNAL_REGEX)
-MESSAGE(STATUS "Destination: ${PREFIX}")
+MESSAGE(STATUS "Destination: ${CMAKE_INSTALL_PREFIX}")
SET(VERSION ${SWORD_VERSION})
IF(WITH_CURL)
@@ -53,4 +58,4 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sword.pc.in ${CMAKE_CURRENT_BINARY_DI
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/swversion.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/swversion.h @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/sword.pc
- DESTINATION "${LIBDIR}/pkgconfig")
+ DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
diff --git a/cmake/options.cmake b/cmake/options.cmake
index 3e07128..4ca7b19 100644
--- a/cmake/options.cmake
+++ b/cmake/options.cmake
@@ -1,3 +1,27 @@
+# Borrowed
+#
+# This macro implements some very special logic how to deal with the cache.
+# By default the various install locations inherit their value from their "parent" variable
+# so if you set CMAKE_INSTALL_PREFIX, then EXEC_INSTALL_PREFIX, PLUGIN_INSTALL_DIR will
+# calculate their value by appending subdirs to CMAKE_INSTALL_PREFIX .
+# This would work completely without using the cache.
+# But if somebody wants e.g. a different EXEC_INSTALL_PREFIX this value has to go into
+# the cache, otherwise it will be forgotten on the next cmake run.
+# Once a variable is in the cache, it doesn't depend on its "parent" variables
+# anymore and you can only change it by editing it directly.
+# this macro helps in this regard, because as long as you don't set one of the
+# variables explicitely to some location, it will always calculate its value from its
+# parents. So modifying CMAKE_INSTALL_PREFIX later on will have the desired effect.
+# But once you decide to set e.g. EXEC_INSTALL_PREFIX to some special location
+# this will go into the cache and it will no longer depend on CMAKE_INSTALL_PREFIX.
+macro(_SET_FANCY _var _value _comment)
+ if (NOT DEFINED ${_var})
+ set(${_var} ${_value})
+ else()
+ set(${_var} "${${_var}}" CACHE STRING "${_comment}")
+ endif()
+endmacro(_SET_FANCY)
+
# A list of the options that the library supports
SET(SWORD_PYTHON_INSTALL_DIR "" CACHE STRING "Directory where the Python bindings will be installed. Defaults to default Python path.")
@@ -10,17 +34,17 @@ ELSE(APPLE)
SET(SWORD_INSTALL_DIR "/usr/local")
ENDIF(APPLE)
-IF(CMAKE_INSTALL_PREFIX)
- SET(PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE STRING "Directory into which to install architecture-dependent files. Defaults to ${SWORD_INSTALL_DIR}.")
-ELSE(CMAKE_INSTALL_PREFIX)
- SET(PREFIX "${SWORD_INSTALL_DIR}" CACHE STRING "Directory into which to install architecture-dependent files. Defaults to ${SWORD_INSTALL_DIR}")
-ENDIF(CMAKE_INSTALL_PREFIX)
+_SET_FANCY(CMAKE_INSTALL_PREFIX "${SWORD_INSTALL_DIR}" "Directory into which to install architecture-dependent files. Defaults to ${SWORD_INSTALL_DIR}.")
+
+_SET_FANCY(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" "Object code library install directory. Defaults to ${SWORD_INSTALL_DIR}/lib")
+
+_SET_FANCY(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" "C Header files install directory. Defaults to ${SWORD_INSTALL_DIR}/include.")
-SET(LIBDIR "${PREFIX}/lib" CACHE STRING "Object code library install directory. Defaults to ${SWORD_INSTALL_DIR}/lib")
+SET(BINDIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE STRING "Directory to install binary executable files. Defaults to ${SWORD_INSTALL_DIR}/bin.")
-SET(INCLUDEDIR "${PREFIX}/include" CACHE STRING "C Header files install directory. Defaults to ${SWORD_INSTALL_DIR}/include.")
+_SET_FANCY(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc" "Directory to install global config files. Defaults to ${SWORD_INSTALL_DIR}/etc.")
-SET(BINDIR "${PREFIX}/bin" CACHE STRING "Directory to install binary executable files. Defaults to ${SWORD_INSTALL_DIR}/bin.")
+_SET_FANCY(SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share" "Directory to install global data files. Defaults to ${SWORD_INSTALL_DIR}/share.")
# Post-processing of variables
MACRO(PROCESS_VERSION LEVEL VALUE)
diff --git a/utilities/CMakeLists.txt b/utilities/CMakeLists.txt
index 169bda4..e7bd82d 100644
--- a/utilities/CMakeLists.txt
+++ b/utilities/CMakeLists.txt
@@ -88,7 +88,7 @@ ENDIF(BUILDING_SHARED)
#
FOREACH(UTIL ${install_UTILITIES})
INSTALL(TARGETS ${UTIL}
- DESTINATION ${BINDIR}
+ RUNTIME DESTINATION "${BINDIR}"
COMPONENT utilities
)
ENDFOREACH(UTIL ${install_UTILITIES})
@@ -113,7 +113,7 @@ ELSE(BUILDING_SHARED)
TARGET_LINK_LIBRARIES(diatheke sword_static)
ENDIF(BUILDING_SHARED)
INSTALL(TARGETS diatheke
- DESTINATION ${BINDIR}
+ DESTINATION "${BINDIR}"
COMPONENT utilities
)

View File

@ -1,18 +1,24 @@
%define soversion 1.7
Name: sword
Version: 1.7.3.900
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Free Bible Software Project
License: GPLv2
URL: http://www.crosswire.org/sword/
Source0: http://www.crosswire.org/ftpmirror/pub/sword/source/v1.7/sword-%{version}.tar.gz
BuildRequires: cmake
BuildRequires: openssl-devel
BuildRequires: curl-devel
BuildRequires: zlib-devel
BuildRequires: libidn-devel
BuildRequires: libicu-devel icu
BuildRequires: clucene-core-devel
BuildRequires: cppunit-devel
BuildRequires: libcurl-devel
BuildRequires: icu
BuildRequires: libicu-devel
BuildRequires: libidn-devel
BuildRequires: openssl-devel
BuildRequires: zlib-devel
BuildRequires: swig
BuildRequires: python-devel
Patch0: install_swig_destdir.diff
Patch1: standard_cmake_args.diff
%description
The SWORD Project is the CrossWire Bible Society's free Bible software
@ -23,25 +29,60 @@ also create Bible study software for all readers, students, scholars,
and translators of the Bible, and have a growing collection of over 200
texts in over 50 languages.
%package devel
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%package devel
Summary: Development files for the sword project
Group: Development/Libraries
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: pkgconfig
Requires: curl-devel clucene-core-devel libicu-devel
%description devel
This package contains libraries and header files for
developing applications that use %{name}.
%description devel
This package contains the development headers and libraries for the
sword API. You need this package if you plan on compiling software
that uses the sword API, such as Gnomesword or Bibletime.
%package utils
Summary: Utilities for the sword project
Group: System Enivonment/Libraries
Requires: %{name}%{?_isa} = %{version}-%{release}
%description utils
This package contains the pre-built utilities for use with the SWORD
Project. The SWORD Project developers encourage you to use the latest
development version of the utilities rather than those released with
a packaged release as updates to the utilities do not affect the
release schedule of the library. However, these utilities were the
latest at the time of the current library release.
%package python
Summary: Python bindings for Sword
Requires: %{name}%{?_isa} = %{version}-%{release}
Requires: python
%description python
Python bindings for The SWORD Library.
%prep
%setup -q
%patch0 -p1 -b .swigdest
%patch1 -p1 -b .cmakeargs
%build
%configure --disable-static --with-icu --with-clucene=%{_prefix}
sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
mkdir build
pushd build
%cmake -DLIBSWORD_LIBRARY_TYPE=Shared \
-DSWORD_BINDINGS="Python" \
-DBUILD_UTILITIES="Yes" \
-DLIBSWORD_SOVERSION=%{soversion} \
-DLIBDIR=%{_libdir} \
..
make %{?_smp_mflags}
%install
pushd build
%make_install
popd
mkdir -p %{buildroot}%{_datadir}/sword/modules
find %{buildroot} -type f -name "*.la" -delete -print
@ -51,12 +92,12 @@ find %{buildroot} -type f -name "*.la" -delete -print
%postun -p /sbin/ldconfig
%files
%doc AUTHORS COPYING ChangeLog LICENSE NEWS README
%doc AUTHORS COPYING ChangeLog INSTALL LICENSE NEWS README
%doc samples doc
# Re-enable after upstream includes it with CMake builds
%config(noreplace) %{_sysconfdir}/sword.conf
%{_bindir}/*
%{_datadir}/sword/
%{_libdir}/libsword-%{version}.so
%{_libdir}/libsword.so.%{soversion}
%{_datadir}/sword
%files devel
%doc CODINGSTYLE
@ -64,7 +105,38 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_libdir}/libsword.so
%{_libdir}/pkgconfig/sword.pc
%files utils
%{_bindir}/vs2osisref
%{_bindir}/vs2osisreftxt
%{_bindir}/mod2vpl
%{_bindir}/imp2ld
%{_bindir}/diatheke
%{_bindir}/mkfastmod
%{_bindir}/mod2zmod
%{_bindir}/xml2gbs
%{_bindir}/imp2vs
%{_bindir}/installmgr
%{_bindir}/osis2mod
%{_bindir}/tei2mod
%{_bindir}/vpl2mod
%{_bindir}/mod2imp
%{_bindir}/addld
%{_bindir}/imp2gbs
%{_bindir}/mod2osis
%{_bindir}/emptyvss
%files python
%{python2_sitearch}/Sword.py
%{python2_sitearch}/Sword.pyc
%{python2_sitearch}/Sword.pyo
%{python2_sitearch}/_Sword.so
%{python2_sitearch}/sword-%{version}-py2.7.egg-info
%changelog
* Mon Dec 08 2014 Greg Hellings <greg.hellings@gmail.com> - 1.7.3.900-2
- Changed to CMake
- Added Python bindings
* Wed Dec 03 2014 Greg Hellings <greg.hellings@gmail.com> - 1.7.3.900-1
- Upstream pre-release version bump