[sword-svn] r3300 - in trunk: . cmake utilities
greg.hellings at crosswire.org
greg.hellings at crosswire.org
Tue Dec 9 22:52:08 MST 2014
Author: greg.hellings
Date: 2014-12-09 22:52:08 -0700 (Tue, 09 Dec 2014)
New Revision: 3300
Modified:
trunk/CMakeLists.txt
trunk/cmake/install.cmake
trunk/cmake/options.cmake
trunk/utilities/CMakeLists.txt
Log:
Vastly improve CMake standards compliance
Honor standard CMake options to configure library,
include files, data files, etc.
Install /etc/sword.conf file from CMake
Clean up option defaults
Modified: trunk/CMakeLists.txt
===================================================================
--- trunk/CMakeLists.txt 2014-12-10 05:52:00 UTC (rev 3299)
+++ trunk/CMakeLists.txt 2014-12-10 05:52:08 UTC (rev 3300)
@@ -1,10 +1,6 @@
# TODO: write FindICU (icu-config only for 2.2 and up) -- currently taken from another CMake system
# limit pkg-config version to >= 0.14, demo, utilities, doc, tests
-# use SYSCONF_INSTALL_DIR
-# use LIB_INSTALL_DIR
-# use INCLUDE_INSTALL_DIR
# use BUILD_SHARED_LIBS
-# actually install sword.conf when asked
# convince perl swig bindings to build properly
#
# NOTES: Defaults to build type of Shared
@@ -16,9 +12,6 @@
# of their own GPLv2 license and all copyright is transferred to them for
# all posterity and eternity, wherever such transfer is possible. Where it is
# not, then this file is released under the GPLv2 by myself.
-#
-#
-# A CMake port of the SWORD build system... we hope
PROJECT(libsword CXX C)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
SET(SWORD_VERSION 1.7.3)
@@ -117,12 +110,12 @@
################################################################################################
# Some random user settings
#
+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}")
-IF(NOT SWORD_GLOBAL_CONF_DIR STREQUAL "")
- ADD_DEFINITIONS(-DGLOBCONFPATH="${SWORD_GLOBAL_CONF_DIR}/sword.conf")
-ENDIF(NOT SWORD_GLOBAL_CONF_DIR STREQUAL "")
-
###############################################################################################
# This allows the user to set a SONAME for the library. This allows packagers and those who
# care about that sort of thing to be happy and have all their SONAMES set properly.
Modified: trunk/cmake/install.cmake
===================================================================
--- trunk/cmake/install.cmake 2014-12-10 05:52:00 UTC (rev 3299)
+++ trunk/cmake/install.cmake 2014-12-10 05:52:08 UTC (rev 3300)
@@ -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)
@@ -49,8 +54,12 @@
SET(SHAREDLIB_FALSE "#")
ENDIF(LIBSWORD_LIBRARY_TYPE STREQUAL "Static")
# The @ONLY restricts it because our ${variable} which are left there as part of pkg-config
+SET(prefix ${CMAKE_INSTALL_PREFIX})
+SET(libdir ${LIB_INSTALL_DIR})
+SET(exec_prefix ${BINDIR})
+SET(includedir ${INCLUDE_INSTALL_DIR})
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sword.pc.in ${CMAKE_CURRENT_BINARY_DIR}/sword.pc @ONLY)
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")
Modified: trunk/cmake/options.cmake
===================================================================
--- trunk/cmake/options.cmake 2014-12-10 05:52:00 UTC (rev 3299)
+++ trunk/cmake/options.cmake 2014-12-10 05:52:08 UTC (rev 3300)
@@ -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,18 +34,18 @@
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(LIBDIR "${PREFIX}/lib" CACHE STRING "Object code library install directory. Defaults to ${SWORD_INSTALL_DIR}/lib")
+_SET_FANCY(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" "Object code library install directory. Defaults to ${SWORD_INSTALL_DIR}/lib")
-SET(INCLUDEDIR "${PREFIX}/include" CACHE STRING "C Header files install directory. Defaults to ${SWORD_INSTALL_DIR}/include.")
+_SET_FANCY(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" "C Header files install directory. Defaults to ${SWORD_INSTALL_DIR}/include.")
-SET(BINDIR "${PREFIX}/bin" CACHE STRING "Directory to install binary executable files. Defaults to ${SWORD_INSTALL_DIR}/bin.")
+SET(BINDIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE STRING "Directory to install binary executable files. Defaults to ${SWORD_INSTALL_DIR}/bin.")
+_SET_FANCY(SYSCONF_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/etc" "Directory to install global config files. Defaults to ${SWORD_INSTALL_DIR}/etc.")
+
+_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)
SET(SWORD_VERSION_${LEVEL} ${VALUE})
Modified: trunk/utilities/CMakeLists.txt
===================================================================
--- trunk/utilities/CMakeLists.txt 2014-12-10 05:52:00 UTC (rev 3299)
+++ trunk/utilities/CMakeLists.txt 2014-12-10 05:52:08 UTC (rev 3300)
@@ -88,7 +88,7 @@
#
FOREACH(UTIL ${install_UTILITIES})
INSTALL(TARGETS ${UTIL}
- DESTINATION ${BINDIR}
+ RUNTIME DESTINATION "${BINDIR}"
COMPONENT utilities
)
ENDFOREACH(UTIL ${install_UTILITIES})
@@ -113,7 +113,7 @@
TARGET_LINK_LIBRARIES(diatheke sword_static)
ENDIF(BUILDING_SHARED)
INSTALL(TARGETS diatheke
- DESTINATION ${BINDIR}
+ DESTINATION "${BINDIR}"
COMPONENT utilities
)
More information about the sword-cvs
mailing list