CTKGenerateCTKConfig.cmake 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. ###########################################################################
  2. #
  3. # Library: CTK
  4. #
  5. # Copyright (c) Kitware Inc.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0.txt
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. ###########################################################################
  20. ###########################################################################
  21. #
  22. # Program: Visualization Toolkit
  23. # Module: vtkGenerateVTKConfig.cmake
  24. #
  25. # Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  26. #
  27. # All rights reserved.
  28. # See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
  29. #
  30. # This software is distributed WITHOUT ANY WARRANTY; without even
  31. # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  32. # PURPOSE. See the above copyright notice for more information.
  33. #
  34. ###########################################################################
  35. #
  36. # Generate the CTKConfig.cmake file in the build tree. Also configure
  37. # one for installation. The file tells external projects how to use CTK.
  38. #
  39. include(ctkFunctionGeneratePluginUseFile)
  40. #-----------------------------------------------------------------------------
  41. # Settings specific to the build tree.
  42. # The install-only section is empty for the build tree.
  43. set(CTK_CONFIG_INSTALL_ONLY)
  44. # The "use" file.
  45. set(CTK_USE_FILE ${CTK_SUPERBUILD_BINARY_DIR}/UseCTK.cmake)
  46. # Generate list of target to exports
  47. set(CTK_TARGETS_TO_EXPORT ${CTK_LIBRARIES} ${CTK_PLUGIN_LIBRARIES})
  48. # Append CTK PythonQt static libraries
  49. if(NOT CTK_BUILD_SHARED_LIBS)
  50. foreach(lib ${CTK_WRAPPED_LIBRARIES_PYTHONQT})
  51. list(APPEND CTK_TARGETS_TO_EXPORT ${lib}PythonQt)
  52. endforeach()
  53. endif()
  54. # Export targets so they can be imported by a project using CTK
  55. # as an external library
  56. export(TARGETS ${CTK_TARGETS_TO_EXPORT} FILE ${CTK_SUPERBUILD_BINARY_DIR}/CTKExports.cmake)
  57. # Generate a file containing plugin specific variables
  58. set(CTK_PLUGIN_USE_FILE "${CTK_SUPERBUILD_BINARY_DIR}/CTKPluginUseFile.cmake")
  59. ctkFunctionGeneratePluginUsefile(${CTK_PLUGIN_USE_FILE})
  60. # Write a set of variables containing library specific include and library directories
  61. set(CTK_LIBRARY_INCLUDE_DIRS_CONFIG)
  62. foreach(lib ${CTK_LIBRARIES})
  63. set(${lib}_INCLUDE_DIRS ${${lib}_SOURCE_DIR} ${${lib}_BINARY_DIR})
  64. ctkFunctionGetIncludeDirs(${lib}_INCLUDE_DIRS ${lib})
  65. set(CTK_LIBRARY_INCLUDE_DIRS_CONFIG "${CTK_LIBRARY_INCLUDE_DIRS_CONFIG}
  66. set(${lib}_INCLUDE_DIRS \"${${lib}_INCLUDE_DIRS}\")")
  67. ctkFunctionGetLibraryDirs(${lib}_LIBRARY_DIRS ${lib})
  68. set(CTK_LIBRARY_LIBRARY_DIRS_CONFIG "${CTK_LIBRARY_LIBRARY_DIRS_CONFIG}
  69. set(${lib}_LIBRARY_DIRS \"${${lib}_LIBRARY_DIRS}\")")
  70. endforeach()
  71. # Determine the include directories needed.
  72. set(CTK_INCLUDE_DIRS_CONFIG
  73. ${CTK_BASE_INCLUDE_DIRS}
  74. )
  75. set(CTKTesting_CMAKE_DIR_CONFIG "${CTKTesting_SOURCE_DIR}/CMake")
  76. # Consider "headeronly" libraries
  77. set(headeronly_libs CTKTesting)
  78. foreach(lib ${headeronly_libs})
  79. set(${lib}_INCLUDE_DIRS ${${lib}_SOURCE_DIR} ${${lib}_BINARY_DIR})
  80. ctkFunctionGetIncludeDirs(${lib}_INCLUDE_DIRS ${lib})
  81. set(CTK_LIBRARY_INCLUDE_DIRS_CONFIG "${CTK_LIBRARY_INCLUDE_DIRS_CONFIG}
  82. set(${lib}_INCLUDE_DIRS \"${${lib}_INCLUDE_DIRS}\")")
  83. set(CTK_INCLUDE_DIRS_CONFIG ${CTK_INCLUDE_DIRS_CONFIG} ${${lib}_INCLUDE_DIRS})
  84. endforeach()
  85. # Library directory.
  86. set(CTK_LIBRARY_DIRS_CONFIG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
  87. # Plug-in output directory
  88. if(WIN32)
  89. set(_plugin_output_type "RUNTIME")
  90. else()
  91. set(_plugin_output_type "LIBRARY")
  92. endif()
  93. if(DEFINED CTK_PLUGIN_${_plugin_output_type}_OUTPUT_DIRECTORY)
  94. if(IS_ABSOLUTE "${CTK_PLUGIN_${_plugin_output_type}_OUTPUT_DIRECTORY}")
  95. set(CTK_PLUGIN_LIBRARIES_DIR_CONFIG "${CTK_PLUGIN_${_plugin_output_type}_OUTPUT_DIRECTORY}")
  96. else()
  97. set(CTK_PLUGIN_LIBRARIES_DIR_CONFIG "${CMAKE_${_plugin_output_type}_OUTPUT_DIRECTORY}/${CTK_PLUGIN_${_plugin_output_type}_OUTPUT_DIRECTORY}")
  98. endif()
  99. else()
  100. set(CTK_PLUGIN_LIBRARIES_DIR_CONFIG "${CMAKE_${_plugin_output_type}_OUTPUT_DIRECTORY}/plugins")
  101. endif()
  102. # External project libraries.
  103. set(CTK_EXTERNAL_LIBRARIES_CONFIG ${CTK_EXTERNAL_LIBRARIES})
  104. # External project library directory.
  105. set(CTK_EXTERNAL_LIBRARY_DIRS_CONFIG ${CTK_EXTERNAL_LIBRARY_DIRS})
  106. # Runtime library directory.
  107. set(CTK_RUNTIME_LIBRARY_DIRS_CONFIG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  108. # Binary executable directory.
  109. set(CTK_EXECUTABLE_DIRS_CONFIG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  110. # QtDesigner plugins directory
  111. set(CTK_QTDESIGNERPLUGINS_DIR_CONFIG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
  112. # CTK external projects variables
  113. string(REPLACE "^" ";" CTK_SUPERBUILD_EP_VARNAMES "${CTK_SUPERBUILD_EP_VARNAMES}")
  114. set(CTK_SUPERBUILD_EP_VARS_CONFIG)
  115. foreach(varname ${CTK_SUPERBUILD_EP_VARNAMES})
  116. set(CTK_SUPERBUILD_EP_VARS_CONFIG
  117. "${CTK_SUPERBUILD_EP_VARS_CONFIG}
  118. set(CTK_${varname} \"${${varname}}\")")
  119. endforeach()
  120. # CMake extension module directory.
  121. set(CTK_CMAKE_DIR_CONFIG ${CTK_CMAKE_DIR})
  122. set(CTK_CMAKE_UTILITIES_DIR_CONFIG ${CTK_CMAKE_UTILITIES_DIR})
  123. # Build configuration information.
  124. set(CTK_CONFIGURATION_TYPES_CONFIG ${CMAKE_CONFIGURATION_TYPES})
  125. set(CTK_BUILD_TYPE_CONFIG ${CMAKE_BUILD_TYPE})
  126. #-----------------------------------------------------------------------------
  127. # Configure CTKConfig.cmake for the build tree.
  128. configure_file(${CTK_SOURCE_DIR}/CMake/CTKConfig.cmake.in
  129. ${CTK_SUPERBUILD_BINARY_DIR}/CTKConfig.cmake @ONLY IMMEDIATE)
  130. configure_file(${CTK_SOURCE_DIR}/CMake/CTKConfigVersion.cmake.in
  131. ${CTK_SUPERBUILD_BINARY_DIR}/CTKConfigVersion.cmake @ONLY IMMEDIATE)
  132. configure_file(${CTK_SOURCE_DIR}/CMake/ctkConfig.h.in
  133. ${CTK_CONFIG_H_INCLUDE_DIR}/ctkConfig.h @ONLY IMMEDIATE)
  134. #-----------------------------------------------------------------------------
  135. # Settings specific to the install tree.
  136. #-----------------------------------------------------------------------------
  137. # Configure CTKConfig.cmake for the install tree.