source: castxml/trunk/fuentes/CMakeLists.txt @ 6513

Last change on this file since 6513 was 6513, checked in by mabarracus, 2 years ago

Initial port to lliurex from ubuntu

File size: 3.6 KB
Line 
1#=============================================================================
2# Copyright Kitware, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#=============================================================================
16cmake_minimum_required(VERSION 2.8.5)
17project(CastXML)
18
19include(src/Version.cmake)
20
21include(CTest)
22
23# Build tree locations.
24set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CastXML_BINARY_DIR}/bin")
25set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CastXML_BINARY_DIR}/lib")
26set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CastXML_BINARY_DIR}/lib")
27
28# Install tree locations.
29if(NOT CastXML_INSTALL_RUNTIME_DIR)
30  set(CastXML_INSTALL_RUNTIME_DIR bin)
31endif()
32if(NOT CastXML_INSTALL_DATA_DIR)
33  set(CastXML_INSTALL_DATA_DIR share/castxml)
34endif()
35if(NOT CastXML_INSTALL_DOC_DIR)
36  set(CastXML_INSTALL_DOC_DIR share/doc/castxml)
37endif()
38if(NOT CastXML_INSTALL_MAN_DIR)
39  set(CastXML_INSTALL_MAN_DIR man)
40endif()
41
42if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
43  if(NOT LLVM_ENABLE_EH)
44    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
45  endif()
46  if(NOT LLVM_ENABLE_RTTI)
47    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
48  endif()
49  if(CYGWIN OR MINGW)
50    # Use GNU extensions on Windows as LLVM upstream does.
51    set(std_cxx11 "-std=gnu++11")
52  else()
53    set(std_cxx11 "-std=c++11")
54  endif()
55  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${std_cxx11}")
56endif()
57
58set(KWSYS_NAMESPACE cxsys)
59set(KWSYS_USE_Process 1)
60set(KWSYS_HEADER_ROOT ${CastXML_BINARY_DIR}/src)
61add_subdirectory(src/kwsys)
62include_directories(${KWSYS_HEADER_ROOT})
63
64find_package(LLVM REQUIRED)
65
66if(DEFINED LLVM_BUILD_BINARY_DIR)
67  message(FATAL_ERROR
68    "LLVM_DIR refers to a LLVM/Clang build directory:\n"
69    "  ${LLVM_DIR}\n"
70    "CastXML must be built against a LLVM/Clang install tree as "
71    "specified in\n"
72    "  ${CastXML_SOURCE_DIR}/README.rst")
73endif()
74
75add_definitions(${LLVM_DEFINITIONS})
76include_directories(${LLVM_INCLUDE_DIRS})
77link_directories(${LLVM_LIBRARY_DIRS})
78if(NOT DEFINED LLVM_VERSION_PATCH)
79  set(LLVM_VERSION_PATCH 0)
80endif()
81
82set(CLANG_RESOURCE_DIR "" CACHE PATH "Clang resource directory")
83if(NOT CLANG_RESOURCE_DIR)
84  set(v ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH})
85  set(tried "")
86  foreach(d ${LLVM_LIBRARY_DIRS})
87    if(IS_DIRECTORY "${d}/clang/${v}/include")
88      set(CLANG_RESOURCE_DIR ${d}/clang/${v})
89      break()
90    endif()
91    set(tried "${tried}\n  ${d}/clang/${v}")
92  endforeach()
93  if(NOT CLANG_RESOURCE_DIR)
94    if(tried)
95      set(tried "  Tried:${tried}")
96    endif()
97    message(FATAL_ERROR "Could not find CLANG_RESOURCE_DIR.${tried}"
98      "\n"
99      "Please set CLANG_RESOURCE_DIR to the Clang SDK directory containing "
100      "\"include/stddef.h\", typically of the form \"<prefix>/lib/clang/${v}\"."
101      )
102  endif()
103  unset(tried)
104endif()
105
106install(DIRECTORY ${CLANG_RESOURCE_DIR}/include
107  DESTINATION "${CastXML_INSTALL_DATA_DIR}/clang"
108  )
109
110add_subdirectory(src)
111
112if(BUILD_TESTING)
113  add_subdirectory(test)
114endif()
115
116add_subdirectory(doc)
117
118install(DIRECTORY share/castxml/ DESTINATION "${CastXML_INSTALL_DATA_DIR}")
119
120install(FILES
121  "LICENSE"
122  "NOTICE"
123  DESTINATION "${CastXML_INSTALL_DOC_DIR}"
124  )
Note: See TracBrowser for help on using the repository browser.