CMakeLists.txt 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #=============================================================================
  2. # Kitware Information Macro Library
  3. # Copyright 2010-2011 Kitware, Inc.
  4. #
  5. # Distributed under the OSI-approved BSD License (the "License");
  6. # see accompanying file Copyright.txt for details.
  7. #
  8. # This software is distributed WITHOUT ANY WARRANTY; without even the
  9. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. # See the License for more information.
  11. #=============================================================================
  12. # Import the KWIML directory tree into a subdirectory under a parent
  13. # project and configure the library as follows:
  14. #
  15. # set(KWIML myIML)
  16. # subdirs(KWIML)
  17. #
  18. # Optional settings are as follows:
  19. #
  20. # KWIML_HEADER_ROOT = build tree directory to hold KWIML headers.
  21. # Headers will go in a directory called "${KWIML}" under this root.
  22. # For example:
  23. #
  24. # set(KWIML_HEADER_ROOT ${PROJECT_BINARY_DIR})
  25. # include_directories(${PROJECT_BINARY_DIR})
  26. #
  27. # KWIML_INSTALL_INCLUDE_DIR = install KWIML with "make install"
  28. # Specify a value relative to the install prefix and do NOT start with '/'.
  29. # KWIML_INSTALL_INCLUDE_OPTIONS = extra header installation options
  30. # Specify options for the install(FILES) command.
  31. #
  32. # KWIML_LABELS_TEST = list of labels for KWIML tests
  33. cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR)
  34. #-----------------------------------------------------------------------------
  35. if(NOT DEFINED KWIML)
  36. if(NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
  37. message(FATAL_ERROR "Set KWIML namespace in parent directory!")
  38. endif()
  39. set(KWIML KWIML)
  40. set(KWIML_STANDALONE 1)
  41. project(KWIML)
  42. include(CTest)
  43. mark_as_advanced(BUILD_TESTING)
  44. endif()
  45. #-----------------------------------------------------------------------------
  46. get_property(KWIML_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
  47. foreach(lang ${KWIML_LANGUAGES})
  48. set(KWIML_LANGUAGE_${lang} 1)
  49. endforeach()
  50. if(NOT KWIML_LANGUAGE_C AND NOT KWIML_LANGUAGE_CXX)
  51. set(BUILD_TESTING OFF)
  52. endif()
  53. #-----------------------------------------------------------------------------
  54. if(NOT KWIML_HEADER_ROOT)
  55. set(KWIML_HEADER_ROOT "${PROJECT_BINARY_DIR}")
  56. endif()
  57. set(KWIML_HEADER_DIR "${KWIML_HEADER_ROOT}/${KWIML}")
  58. include_directories(${KWIML_HEADER_ROOT})
  59. #-----------------------------------------------------------------------------
  60. foreach(h ABI INT)
  61. set(header ${KWIML_HEADER_DIR}/${h}.h)
  62. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${h}.h.in ${header} @ONLY)
  63. if(KWIML_INSTALL_INCLUDE_DIR)
  64. install(FILES ${header}
  65. DESTINATION ${KWIML_INSTALL_INCLUDE_DIR}/${KWIML}
  66. ${KWIML_INSTALL_INCLUDE_OPTIONS})
  67. endif()
  68. endforeach()
  69. #-----------------------------------------------------------------------------
  70. if(BUILD_TESTING)
  71. add_subdirectory(test)
  72. endif()