aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAlex Merry <alex.merry@kde.org>2014-04-16 14:28:56 +0100
committerAlex Merry <alex.merry@kde.org>2014-04-25 10:36:14 +0100
commit23829defe0455cf57518ee29fee2988054ed51b7 (patch)
tree8be6345b79e125945e97aea22f8174c71be23a6d /modules
parent283aeda90db966de58f3c3ecdc1ce64f44ab849b (diff)
downloadextra-cmake-modules-23829defe0455cf57518ee29fee2988054ed51b7.tar.gz
extra-cmake-modules-23829defe0455cf57518ee29fee2988054ed51b7.tar.bz2
ECMGeneratePriFile: Allow lib and include install dirs to be overridden
Rather than blindly using ${LIB_INSTALL_DIR} and ${INCLUDE_INSTALL_DIR} (which assume the inclusion of KDEInstallDirs), this checks whether they exist, also checks for ${CMAKE_INSTALL_LIBDIR} and ${CMAKE_INSTALL_INCLUDEDIR} (set by GNUInstallDirs), provides hard-coded defaults and allows arguments to be used to override the values. This should make it useful to projects that aren't KDE Frameworks. REVIEW: 117593
Diffstat (limited to 'modules')
-rw-r--r--modules/ECMGeneratePriFile.cmake61
1 files changed, 45 insertions, 16 deletions
diff --git a/modules/ECMGeneratePriFile.cmake b/modules/ECMGeneratePriFile.cmake
index bff2961f..34001d6c 100644
--- a/modules/ECMGeneratePriFile.cmake
+++ b/modules/ECMGeneratePriFile.cmake
@@ -20,7 +20,9 @@
# ecm_generate_pri_file(BASE_NAME <baseName>
# LIB_NAME <libName>
# [DEPS "<dep> [<dep> [...]]"]
-# [FILENAME_VAR <filename_variable>])
+# [FILENAME_VAR <filename_variable>]
+# [INCLUDE_INSTALL_DIR <dir>]
+# [LIB_INSTALL_DIR <dir>])
#
# If your CMake project produces a Qt-based library, you may expect there to be
# applications that wish to use it that use a qmake-based build system, rather
@@ -28,14 +30,10 @@
# library convenient for them, in much the same way that CMake config files make
# things convenient for CMake-based applications.
#
-# ecm_generate_pri_file() generates just such a file. It depends on a few
-# variables being set:
-#
-# * ``PROJECT_VERSION_STRING``: typically set by :module:`ECMSetupVersion`,
-# although the project() command in CMake 3.0.0 and later can also set this.
-# * ``INCLUDE_INSTALL_DIR``: this must be relative to ``CMAKE_INSTALL_PREFIX``,
-# and includes are assumed to be install in the <baseName> subdirectory.
-# * ``LIB_INSTALL_DIR``: this must be relative to ``CMAKE_INSTALL_PREFIX``.
+# ecm_generate_pri_file() generates just such a file. It requires the
+# ``PROJECT_VERSION_STRING`` variable to be set. This is typically set by
+# :module:`ECMSetupVersion`, although the project() command in CMake 3.0.0 and
+# later can also set this.
#
# BASE_NAME specifies the name qmake project (.pro) files should use to refer to
# the library (eg: KArchive). LIB_NAME is the name of the actual library to
@@ -45,6 +43,14 @@
# for QtCore). FILENAME_VAR specifies the name of a variable to store the path
# to the generated file in.
#
+# INCLUDE_INSTALL_DIR is the path (relative to ``CMAKE_INSTALL_PREFIX``) that
+# include files will be installed to. It defaults to
+# ``${INCLUDE_INSTALL_DIR}/<baseName>`` if the ``INCLUDE_INSTALL_DIR`` variable
+# is set. If that variable is not set, the ``CMAKE_INSTALL_INCLUDEDIR`` variable
+# is used instead, and if neither are set ``include`` is used. LIB_INSTALL_DIR
+# operates similarly for the installation location for libraries; it defaults to
+# ``${LIB_INSTALL_DIR}``, ``${CMAKE_INSTALL_LIBDIR}`` or ``lib``, in that order.
+#
# Example usage:
#
# .. code-block:: cmake
@@ -80,7 +86,7 @@ set(ECM_MKSPECS_INSTALL_DIR mkspecs/modules CACHE PATH "The directory where mksp
function(ECM_GENERATE_PRI_FILE)
set(options )
- set(oneValueArgs BASE_NAME LIB_NAME DEPS FILENAME_VAR)
+ set(oneValueArgs BASE_NAME LIB_NAME DEPS FILENAME_VAR INCLUDE_INSTALL_DIR LIB_INSTALL_DIR)
set(multiValueArgs )
cmake_parse_arguments(EGPF "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
@@ -98,6 +104,24 @@ function(ECM_GENERATE_PRI_FILE)
if(NOT PROJECT_VERSION_STRING)
message(FATAL_ERROR "Required variable PROJECT_VERSION_STRING not set before ECM_GENERATE_PRI_FILE() call. Did you call ecm_setup_version?")
endif()
+ if(NOT EGPF_INCLUDE_INSTALL_DIR)
+ if(INCLUDE_INSTALL_DIR)
+ set(EGPF_INCLUDE_INSTALL_DIR "${INCLUDE_INSTALL_DIR}/${EGPF_BASE_NAME}")
+ elseif(CMAKE_INSTALL_INCLUDEDIR)
+ set(EGPF_INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/${EGPF_BASE_NAME}")
+ else()
+ set(EGPF_INCLUDE_INSTALL_DIR "include/${EGPF_BASE_NAME}")
+ endif()
+ endif()
+ if(NOT EGPF_LIB_INSTALL_DIR)
+ if(LIB_INSTALL_DIR)
+ set(EGPF_LIB_INSTALL_DIR "${LIB_INSTALL_DIR}")
+ elseif(CMAKE_INSTALL_LIBDIR)
+ set(EGPF_LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
+ else()
+ set(EGPF_LIB_INSTALL_DIR "lib")
+ endif()
+ endif()
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" PROJECT_VERSION_MAJOR "${PROJECT_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" PROJECT_VERSION_MINOR "${PROJECT_VERSION_STRING}")
@@ -106,9 +130,16 @@ function(ECM_GENERATE_PRI_FILE)
set(PRI_TARGET_BASENAME ${EGPF_BASE_NAME})
set(PRI_TARGET_LIBNAME ${EGPF_LIB_NAME})
set(PRI_TARGET_QTDEPS ${EGPF_DEPS})
- # FIXME: Default value for INCLUDE_INSTALL_DIR, argument to override?
- # What about absolute paths?
- set(PRI_TARGET_INCLUDES "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}/${PRI_TARGET_BASENAME}")
+ if(IS_ABSOLUTE "${EGPF_INCLUDE_INSTALL_DIR}")
+ set(PRI_TARGET_INCLUDES "${EGPF_INCLUDE_INSTALL_DIR}")
+ else()
+ set(PRI_TARGET_INCLUDES "${CMAKE_INSTALL_PREFIX}/${EGPF_INCLUDE_INSTALL_DIR}")
+ endif()
+ if(IS_ABSOLUTE "${EGPF_LIB_INSTALL_DIR}")
+ set(PRI_TARGET_LIBS "${EGPF_LIB_INSTALL_DIR}")
+ else()
+ set(PRI_TARGET_LIBS "${CMAKE_INSTALL_PREFIX}/${EGPF_LIB_INSTALL_DIR}")
+ endif()
set(PRI_TARGET_DEFINES "")
set(PRI_FILENAME ${CMAKE_CURRENT_BINARY_DIR}/qt_${PRI_TARGET_BASENAME}.pri)
@@ -116,8 +147,6 @@ function(ECM_GENERATE_PRI_FILE)
set(${EGPF_FILENAME_VAR} ${PRI_FILENAME} PARENT_SCOPE)
endif()
- # FIXME: Default value for LIB_INSTALL_DIR, argument to override?
- # What about absolute paths?
file(GENERATE
OUTPUT ${PRI_FILENAME}
CONTENT
@@ -129,7 +158,7 @@ QT.@PRI_TARGET_BASENAME@.name = @PRI_TARGET_LIBNAME@
QT.@PRI_TARGET_BASENAME@.defines = @PRI_TARGET_DEFINES@
QT.@PRI_TARGET_BASENAME@.includes = @PRI_TARGET_INCLUDES@
QT.@PRI_TARGET_BASENAME@.private_includes =
-QT.@PRI_TARGET_BASENAME@.libs = @CMAKE_INSTALL_PREFIX@/@LIB_INSTALL_DIR@
+QT.@PRI_TARGET_BASENAME@.libs = @PRI_TARGET_LIBS@
QT.@PRI_TARGET_BASENAME@.depends = @PRI_TARGET_QTDEPS@
"
)