Procházet zdrojové kódy

ENH: File UseCTK.cmake.in, CTKConfig.cmake.in and CTKConfigVersion.cmake.in are now configured.

A directory named Utilities/LastconfigureStep has been added.
This one contains a CMakeLists.txt in charge of including the macro CTKGenerateCTKConfig.cmake

For now, CTKGenerateCTKConfig.cmake will configure UseCTK, CTKConfig and CTKConfigVersion only
for the "build tree" case.

The "install tree" case is *NOT* considered.
Jean-Christophe Fillion-Robin před 15 roky
rodič
revize
59e3828583

+ 18 - 1
CMakeLists.txt

@@ -68,7 +68,7 @@ SET(CTK_BASE_INCLUDE_DIRS CACHE INTERNAL "CTK includes" FORCE)
 
 #-----------------------------------------------------------------------------
 # CMake Macro(s)
-# 
+#
 INCLUDE(CMake/ctkMacroParseArguments.cmake)
 INCLUDE(CMake/ctkMacroListFilter.cmake)
 INCLUDE(CMake/ctkMacroBuildQtLib.cmake)
@@ -80,6 +80,10 @@ INCLUDE(CMake/ctkMacroAddCtkLibraryOptions.cmake)
 INCLUDE(CMake/ctkMacroGenerateDGraphInput.cmake)
 INCLUDE(CMake/ctkMacroGenerateProjectXml.cmake)
 
+# Used by CTKGenerateCTKConfig.cmake
+SET(CTK_CMAKE_DIR ${CTK_SOURCE_DIR}/CMake)
+SET(CTK_CMAKE_UTILITIES_DIR ${CTK_SOURCE_DIR}/Utilities/CMake)
+
 #-----------------------------------------------------------------------------
 # Patch program
 #
@@ -342,6 +346,13 @@ IF(NOT DEFINED CTK_SUPERBUILD_BINARY_DIR)
 ENDIF()
 
 #-----------------------------------------------------------------------------
+# Configure files with settings
+#
+
+CONFIGURE_FILE(${CTK_SOURCE_DIR}/UseCTK.cmake.in
+               ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake COPYONLY IMMEDIATE)
+               
+#-----------------------------------------------------------------------------
 # Set C/CXX Flags
 #
 SET(CMAKE_CXX_FLAGS ${CTK_CXX_FLAGS})
@@ -384,3 +395,9 @@ ENDFOREACH()
 # Style Checking configuration
 #
 INCLUDE(Utilities/KWStyle/KWStyle.cmake)
+
+#-----------------------------------------------------------------------------
+# The commands in this directory are intended to be executed as
+# the end of the whole configuration process, as a "last step".
+# This directory is typically the last SUBDIRS in the main CMakeLists.txt.
+ADD_SUBDIRECTORY(Utilities/LastConfigureStep)

+ 66 - 0
CTKConfig.cmake.in

@@ -0,0 +1,66 @@
+#
+# CTKConfig.cmake - CTK CMake configuration file for external projects.
+#
+# This file is configured by CTK and used by the UseCTK.cmake module
+# to load CTK's settings for an external project.
+
+@CTK_CONFIG_INSTALL_ONLY@
+
+# The CTK include file directories.
+SET(CTK_INCLUDE_DIRS "@CTK_INCLUDE_DIRS_CONFIG@")
+ 
+# The CTK library directories.
+SET(CTK_LIBRARY_DIRS "@CTK_LIBRARY_DIRS_CONFIG@")
+ 
+# The CTK binary executable directories. Note that if
+# CTK_CONFIGURATION_TYPES is set (see below) then these directories
+# will be the parent directories under which there will be a directory
+# of runtime binaries for each configuration type.
+SET(CTK_EXECUTABLE_DIRS "@CTK_EXECUTABLE_DIRS_CONFIG@")
+ 
+# The CTK runtime library directories. Note that if
+# CTK_CONFIGURATION_TYPES is set (see below) then these directories
+# will be the parent directories under which there will be a directory
+# of runtime libraries for each configuration type.
+SET(CTK_RUNTIME_LIBRARY_DIRS "@CTK_RUNTIME_LIBRARY_DIRS_CONFIG@")
+ 
+# The CTK version number
+SET(CTK_MAJOR_VERSION "@CTK_MAJOR_VERSION@")
+SET(CTK_MINOR_VERSION "@CTK_MINOR_VERSION@")
+SET(CTK_BUILD_VERSION "@CTK_BUILD_VERSION@")
+ 
+# The location of the UseCTK.cmake file.
+SET(CTK_USE_FILE "@CTK_USE_FILE@")
+ 
+# CMake extension module directory
+SET(CTK_CMAKE_DIR "@CTK_CMAKE_DIR_CONFIG@")
+SET(CTK_CMAKE_UTILITIES_DIR "@CTK_CMAKE_UTILITIES_DIR_CONFIG@")
+ 
+# TODO The list of available libraries.
+
+# TODO The list of available plugins.
+
+# TODO The list of available applications.
+
+# TODO The Doxygen configuration.
+#SET(CTK_DOXYGEN_HOME "@CTK_DOXYGEN_HOME_CONFIG@")
+ 
+# TODO Relative install paths in the CTK install tree
+#SET(CTK_INSTALL_BIN_DIR "@CTK_INSTALL_BIN_DIR@")
+#SET(CTK_INSTALL_INCLUDE_DIR "@CTK_INSTALL_INCLUDE_DIR@")
+#SET(CTK_INSTALL_LIB_DIR "@CTK_INSTALL_LIB_DIR@")
+#SET(CTK_INSTALL_PACKAGE_DIR "@CTK_INSTALL_PACKAGE_DIR@")
+ 
+# A CTK install tree always provides one build configuration. A CTK
+# build tree may provide either one or multiple build configurations
+# depending on the CMake generator used. Since CTK can be used either
+# from a build tree or an install tree it is useful for outside
+# projects to know the configurations available. If this
+# CTKConfig.cmake is in a CTK install tree CTK_CONFIGURATION_TYPES
+# will be empty and CTK_BUILD_TYPE will be set to the value of
+# CMAKE_BUILD_TYPE used to build CTK. If CTKConfig.cmake is in a CTK
+# build tree then CTK_CONFIGURATION_TYPES and CTK_BUILD_TYPE will have
+# values matching CMAKE_CONFIGURATION_TYPES and CMAKE_BUILD_TYPE for
+# that build tree (only one will ever be set).
+SET(CTK_CONFIGURATION_TYPES @CTK_CONFIGURATION_TYPES_CONFIG@)
+SET(CTK_BUILD_TYPE @CTK_BUILD_TYPE_CONFIG@)

+ 17 - 0
CTKConfigVersion.cmake.in

@@ -0,0 +1,17 @@
+#
+# This file is used by 
+#
+
+# The full CTK version number.
+SET(PACKAGE_VERSION "@_CTK_VERSION_MAJOR@.@_CTK_VERSION_MINOR@.@_CTK_VERSION_PATCH@")
+ 
+# This version is compatible only with matching major.minor versions.
+IF("@_CTK_VERSION_MAJOR@.@_CTK_VERSION_MINOR@" VERSION_EQUAL "${PACKAGE_FIND_VERSION_MAJOR}.${PACKAGE_FIND_VERSION_MINOR}")
+  # This version is compatible with equal or lesser patch versions.
+  IF(NOT "@_CTK_VERSION_PATCH@" VERSION_LESS "${PACKAGE_FIND_VERSION_PATCH}")
+    SET(PACKAGE_VERSION_COMPATIBLE 1)
+    IF("@_CTK_VERSION_PATCH@" VERSION_EQUAL "${PACKAGE_FIND_VERSION_PATCH}")
+      SET(PACKAGE_VERSION_EXACT 1)
+    ENDIF()
+  ENDIF()
+ENDIF()

+ 16 - 0
UseCTK.cmake.in

@@ -0,0 +1,16 @@
+#
+# This module is provided as CTK_USE_FILE by CTKConfig.cmake. It can
+# be INCLUDED in a project to load the needed compiler and linker
+# settings to use CTK.
+#
+ 
+IF(NOT CTK_USE_FILE_INCLUDED)
+  SET(CTK_USE_FILE_INCLUDED 1)
+  
+  # Add include directories needed to use CTK.
+  INCLUDE_DIRECTORIES(${CTK_INCLUDE_DIRS})
+ 
+  # Add link directories needed to use CTK.
+  LINK_DIRECTORIES(${CTK_LIBRARY_DIRS})
+ 
+ENDIF()

+ 14 - 0
Utilities/LastConfigureStep/CMakeLists.txt

@@ -0,0 +1,14 @@
+# The commands in this directory are intended to be executed as
+# the end of the whole configuration process, as a "last step".
+# This directory is typically the last SUBDIRS in the main CMakeLists.txt.
+# It enable the above commands to use variables that might have been configured
+# in previous SUBDIRS. This is especially important when it comes to
+# the CONFIGURE_FILE command, since in IMMEDIATE mode that command will
+# use the current values of CMake variables instead of waiting until the
+# end of CMakeLists processing, i.e. instead of waiting until some variables
+# are configured in SUBDIRS.
+
+#-----------------------------------------------------------------------------
+# Create the CTKConfig.cmake file containing the CTK configuration.
+# Since it might generate configuration file depending
+INCLUDE(CTKGenerateCTKConfig.cmake)

+ 67 - 0
Utilities/LastConfigureStep/CTKGenerateCTKConfig.cmake

@@ -0,0 +1,67 @@
+#
+# Generate the CTKConfig.cmake file in the build tree. Also configure
+# one for installation.  The file tells external projects how to use CTK.
+#
+
+# Construct version numbers for CTKConfigVersion.cmake.
+SET(_CTK_VERSION_MAJOR ${CTK_MAJOR_VERSION})
+SET(_CTK_VERSION_MINOR ${CTK_MINOR_VERSION})
+SET(_CTK_VERSION_PATCH ${CTK_BUILD_VERSION})
+# We use odd minor numbers for development versions.
+# Use a date for the development patch level.
+# IF("${_CTK_VERSION_MINOR}" MATCHES "[13579]$")
+#   INCLUDE(${CTK_SOURCE_DIR}/Utilities/kwsys/kwsysDateStamp.cmake)
+#   SET(_CTK_VERSION_PATCH
+#     "${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
+#     )
+# ENDIF()
+
+#-----------------------------------------------------------------------------
+# Settings shared between the build tree and install tree.
+
+
+#-----------------------------------------------------------------------------
+# Settings specific to the build tree.
+
+# The install-only section is empty for the build tree.
+SET(CTK_CONFIG_INSTALL_ONLY)
+
+# The "use" file.
+SET(CTK_USE_FILE ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake)
+
+# Library directory.
+SET(CTK_LIBRARY_DIRS_CONFIG ${LIBRARY_OUTPUT_PATH})
+
+# Runtime library directory.
+SET(CTK_RUNTIME_LIBRARY_DIRS_CONFIG ${LIBRARY_OUTPUT_PATH})
+
+# Binary executable directory.
+SET(CTK_EXECUTABLE_DIRS_CONFIG ${EXECUTABLE_OUTPUT_PATH})
+
+# Determine the include directories needed.
+SET(CTK_INCLUDE_DIRS_CONFIG
+  ${CTK_BASE_INCLUDE_DIRS}
+)
+
+# Executable locations.
+
+# CMake extension module directory.
+SET(CTK_CMAKE_DIR_CONFIG "${CTK_CMAKE_DIR}")
+SET(CTK_CMAKE_UTILITIES_DIR_CONFIG "${CTK_CMAKE_UTILITIES_DIR}")
+
+# Build configuration information.
+SET(CTK_CONFIGURATION_TYPES_CONFIG ${CMAKE_CONFIGURATION_TYPES})
+SET(CTK_BUILD_TYPE_CONFIG ${CMAKE_BUILD_TYPE})
+
+#-----------------------------------------------------------------------------
+# Configure CTKConfig.cmake for the build tree.
+CONFIGURE_FILE(${CTK_SOURCE_DIR}/CTKConfig.cmake.in
+               ${CTK_SUPERBUILD_BINARY_DIR}/CTKConfig.cmake @ONLY IMMEDIATE)
+CONFIGURE_FILE(${CTK_SOURCE_DIR}/CTKConfigVersion.cmake.in
+               ${CTK_SUPERBUILD_BINARY_DIR}/CTKConfigVersion.cmake @ONLY IMMEDIATE)
+
+#-----------------------------------------------------------------------------
+# Settings specific to the install tree.
+
+#-----------------------------------------------------------------------------
+# Configure CTKConfig.cmake for the install tree.