CMakeLists.txt 2.76 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#=============================================================================
# Kitware Information Macro Library
# Copyright 2010-2011 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================

# Import the KWIML directory tree into a subdirectory under a parent
# project and configure the library as follows:
#
16
17
#  set(KWIML myIML)
#  subdirs(KWIML)
18
19
20
21
22
23
24
#
# Optional settings are as follows:
#
#  KWIML_HEADER_ROOT = build tree directory to hold KWIML headers.
#    Headers will go in a directory called "${KWIML}" under this root.
#    For example:
#
25
26
#      set(KWIML_HEADER_ROOT ${PROJECT_BINARY_DIR})
#      include_directories(${PROJECT_BINARY_DIR})
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#
#  KWIML_INSTALL_INCLUDE_DIR = install KWIML with "make install"
#    Specify a value relative to the install prefix and do NOT start with '/'.
#  KWIML_INSTALL_INCLUDE_OPTIONS = extra header installation options
#    Specify options for the install(FILES) command.
#
#  KWIML_LABELS_TEST = list of labels for KWIML tests

cmake_minimum_required(VERSION 2.6.3 FATAL_ERROR)

#-----------------------------------------------------------------------------
if(NOT DEFINED KWIML)
  if(NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
    message(FATAL_ERROR "Set KWIML namespace in parent directory!")
  endif()
  set(KWIML KWIML)
  set(KWIML_STANDALONE 1)
  project(KWIML)
  include(CTest)
  mark_as_advanced(BUILD_TESTING)
endif()

#-----------------------------------------------------------------------------
get_property(KWIML_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
foreach(lang ${KWIML_LANGUAGES})
  set(KWIML_LANGUAGE_${lang} 1)
endforeach()
if(NOT KWIML_LANGUAGE_C AND NOT KWIML_LANGUAGE_CXX)
  set(BUILD_TESTING OFF)
endif()

#-----------------------------------------------------------------------------
if(NOT KWIML_HEADER_ROOT)
  set(KWIML_HEADER_ROOT "${PROJECT_BINARY_DIR}")
endif()
set(KWIML_HEADER_DIR "${KWIML_HEADER_ROOT}/${KWIML}")
include_directories(${KWIML_HEADER_ROOT})

#-----------------------------------------------------------------------------
foreach(h ABI INT)
  set(header ${KWIML_HEADER_DIR}/${h}.h)
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${h}.h.in ${header} @ONLY)
  if(KWIML_INSTALL_INCLUDE_DIR)
    install(FILES ${header}
      DESTINATION ${KWIML_INSTALL_INCLUDE_DIR}/${KWIML}
      ${KWIML_INSTALL_INCLUDE_OPTIONS})
  endif()
endforeach()

#-----------------------------------------------------------------------------
if(BUILD_TESTING)
  add_subdirectory(test)
endif()