Oscar Fuentes | 67410b3 | 2011-02-03 20:57:53 +0000 | [diff] [blame] | 1 | # If we are not building as a part of LLVM, build Clang as an |
| 2 | # standalone project, using LLVM as an external library: |
| 3 | if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR ) |
| 4 | project(Clang) |
| 5 | cmake_minimum_required(VERSION 2.8) |
| 6 | |
| 7 | set(CLANG_PATH_TO_LLVM_SOURCE "" CACHE PATH |
| 8 | "Path to LLVM source code. Not necessary if using an installed LLVM.") |
| 9 | set(CLANG_PATH_TO_LLVM_BUILD "" CACHE PATH |
| 10 | "Path to the directory where LLVM was built or installed.") |
| 11 | |
| 12 | if( CLANG_PATH_TO_LLVM_SOURCE ) |
| 13 | if( NOT EXISTS "${CLANG_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake" ) |
| 14 | message(FATAL_ERROR "Please set CLANG_PATH_TO_LLVM_SOURCE to the root directory of LLVM source code.") |
| 15 | else() |
| 16 | get_filename_component(LLVM_MAIN_SRC_DIR ${CLANG_PATH_TO_LLVM_SOURCE} |
| 17 | ABSOLUTE) |
| 18 | list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") |
| 19 | endif() |
| 20 | endif() |
| 21 | |
Hans Wennborg | e90340a | 2013-08-23 18:05:24 +0000 | [diff] [blame] | 22 | if (EXISTS "${CLANG_PATH_TO_LLVM_BUILD}/bin/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") |
| 23 | set (PATH_TO_LLVM_CONFIG "${CLANG_PATH_TO_LLVM_BUILD}/bin/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") |
| 24 | elseif (EXISTS "${CLANG_PATH_TO_LLVM_BUILD}/bin/Debug/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") |
| 25 | # Looking for bin/Debug/llvm-config is a complete hack. How can we get |
Douglas Gregor | 17031a2 | 2011-07-14 23:42:32 +0000 | [diff] [blame] | 26 | # around this? |
Hans Wennborg | e90340a | 2013-08-23 18:05:24 +0000 | [diff] [blame] | 27 | set (PATH_TO_LLVM_CONFIG "${CLANG_PATH_TO_LLVM_BUILD}/bin/Debug/llvm-config${CMAKE_EXECUTABLE_SUFFIX}") |
| 28 | else() |
| 29 | message(FATAL_ERROR "Please set CLANG_PATH_TO_LLVM_BUILD to a directory containing a LLVM build.") |
Oscar Fuentes | 67410b3 | 2011-02-03 20:57:53 +0000 | [diff] [blame] | 30 | endif() |
| 31 | |
| 32 | list(APPEND CMAKE_MODULE_PATH "${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake") |
| 33 | |
| 34 | get_filename_component(PATH_TO_LLVM_BUILD ${CLANG_PATH_TO_LLVM_BUILD} |
| 35 | ABSOLUTE) |
| 36 | |
Hans Wennborg | 885e36e | 2013-08-24 00:22:23 +0000 | [diff] [blame] | 37 | option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF) |
| 38 | |
Oscar Fuentes | 67410b3 | 2011-02-03 20:57:53 +0000 | [diff] [blame] | 39 | include(AddLLVM) |
| 40 | include(TableGen) |
Oscar Fuentes | 5ec8a4d | 2011-04-10 16:17:31 +0000 | [diff] [blame] | 41 | include("${CLANG_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake") |
Oscar Fuentes | 67410b3 | 2011-02-03 20:57:53 +0000 | [diff] [blame] | 42 | include(HandleLLVMOptions) |
| 43 | |
| 44 | set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}") |
| 45 | |
| 46 | set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include") |
| 47 | set(LLVM_BINARY_DIR ${CMAKE_BINARY_DIR}) |
| 48 | |
Oscar Fuentes | b641f08 | 2011-02-14 20:14:11 +0000 | [diff] [blame] | 49 | set(CMAKE_INCLUDE_CURRENT_DIR ON) |
Oscar Fuentes | 67410b3 | 2011-02-03 20:57:53 +0000 | [diff] [blame] | 50 | include_directories("${PATH_TO_LLVM_BUILD}/include" "${LLVM_MAIN_INCLUDE_DIR}") |
Oscar Fuentes | 67410b3 | 2011-02-03 20:57:53 +0000 | [diff] [blame] | 51 | link_directories("${PATH_TO_LLVM_BUILD}/lib") |
| 52 | |
Hans Wennborg | ecc0df5 | 2013-08-23 18:20:47 +0000 | [diff] [blame] | 53 | exec_program("${PATH_TO_LLVM_CONFIG} --bindir" OUTPUT_VARIABLE LLVM_BINARY_DIR) |
| 54 | set(LLVM_TABLEGEN_EXE "${LLVM_BINARY_DIR}/llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}") |
Oscar Fuentes | 67410b3 | 2011-02-03 20:57:53 +0000 | [diff] [blame] | 55 | |
Chandler Carruth | 9224fb8 | 2012-07-02 20:52:55 +0000 | [diff] [blame] | 56 | # Define the default arguments to use with 'lit', and an option for the user |
| 57 | # to override. |
| 58 | set(LIT_ARGS_DEFAULT "-sv") |
| 59 | if (MSVC OR XCODE) |
| 60 | set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") |
| 61 | endif() |
| 62 | set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") |
| 63 | |
Oscar Fuentes | 67410b3 | 2011-02-03 20:57:53 +0000 | [diff] [blame] | 64 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) |
| 65 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) |
| 66 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) |
| 67 | |
Jeffrey Yasskin | 718b01d | 2011-02-15 07:54:28 +0000 | [diff] [blame] | 68 | set( CLANG_BUILT_STANDALONE 1 ) |
Douglas Gregor | a34173e | 2012-12-18 19:39:40 +0000 | [diff] [blame] | 69 | |
| 70 | find_package(LibXml2) |
| 71 | if (LIBXML2_FOUND) |
| 72 | set(CLANG_HAVE_LIBXML 1) |
| 73 | endif () |
Oscar Fuentes | 67410b3 | 2011-02-03 20:57:53 +0000 | [diff] [blame] | 74 | endif() |
Douglas Gregor | 34d9ffa | 2009-09-16 21:59:05 +0000 | [diff] [blame] | 75 | |
Oscar Fuentes | 2100fe9 | 2011-02-03 22:48:20 +0000 | [diff] [blame] | 76 | set(CLANG_RESOURCE_DIR "" CACHE STRING |
| 77 | "Relative directory from the Clang binary to its resource files.") |
| 78 | |
| 79 | set(C_INCLUDE_DIRS "" CACHE STRING |
| 80 | "Colon separated list of directories clang will search for headers.") |
| 81 | |
Sebastian Pop | 4762a2d | 2012-04-16 04:16:43 +0000 | [diff] [blame] | 82 | set(GCC_INSTALL_PREFIX "" CACHE PATH "Directory where gcc is installed." ) |
| 83 | set(DEFAULT_SYSROOT "" CACHE PATH |
| 84 | "Default <path> to all compiler invocations for --sysroot=<path>." ) |
| 85 | |
Oscar Fuentes | f752d5b | 2011-05-20 15:57:59 +0000 | [diff] [blame] | 86 | set(CLANG_VENDOR "" CACHE STRING |
| 87 | "Vendor-specific text for showing with version information.") |
| 88 | |
| 89 | if( CLANG_VENDOR ) |
| 90 | add_definitions( -DCLANG_VENDOR="${CLANG_VENDOR} " ) |
| 91 | endif() |
| 92 | |
Michael Gottesman | a8c0e4f | 2013-08-15 19:22:33 +0000 | [diff] [blame] | 93 | set(CLANG_REPOSITORY_STRING "" CACHE STRING |
| 94 | "Vendor-specific text for showing the repository the source is taken from.") |
| 95 | |
| 96 | if(CLANG_REPOSITORY_STRING) |
| 97 | add_definitions(-DCLANG_REPOSITORY_STRING="${CLANG_REPOSITORY_STRING}") |
| 98 | endif() |
| 99 | |
Michael Gottesman | f353511 | 2013-08-15 19:22:36 +0000 | [diff] [blame] | 100 | set(CLANG_VENDOR_UTI "org.llvm.clang" CACHE STRING |
| 101 | "Vendor-specific uti.") |
| 102 | |
Daniel Dunbar | 91ee77a | 2009-09-17 00:07:10 +0000 | [diff] [blame] | 103 | set(CLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 104 | set(CLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 105 | |
Chandler Carruth | 63e9c0d | 2010-04-17 20:12:02 +0000 | [diff] [blame] | 106 | if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE ) |
| 107 | message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite " |
| 108 | "the makefiles distributed with LLVM. Please create a directory and run cmake " |
| 109 | "from there, passing the path to this source directory as the last argument. " |
| 110 | "This process created the file `CMakeCache.txt' and the directory " |
| 111 | "`CMakeFiles'. Please delete them.") |
| 112 | endif() |
| 113 | |
| 114 | if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR ) |
| 115 | file(GLOB_RECURSE |
| 116 | tablegenned_files_on_include_dir |
| 117 | "${CLANG_SOURCE_DIR}/include/clang/*.inc") |
| 118 | if( tablegenned_files_on_include_dir ) |
| 119 | message(FATAL_ERROR "Apparently there is a previous in-source build, " |
| 120 | "probably as the result of running `configure' and `make' on " |
| 121 | "${CLANG_SOURCE_DIR}. This may cause problems. The suspicious files are:\n" |
| 122 | "${tablegenned_files_on_include_dir}\nPlease clean the source directory.") |
| 123 | endif() |
| 124 | endif() |
| 125 | |
Daniel Dunbar | c4b8e92 | 2010-06-25 23:34:47 +0000 | [diff] [blame] | 126 | # Compute the Clang version from the LLVM version. |
Michael J. Spencer | 5a7f349 | 2010-09-10 21:13:16 +0000 | [diff] [blame] | 127 | string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION |
Daniel Dunbar | c4b8e92 | 2010-06-25 23:34:47 +0000 | [diff] [blame] | 128 | ${PACKAGE_VERSION}) |
Douglas Gregor | 34d9ffa | 2009-09-16 21:59:05 +0000 | [diff] [blame] | 129 | message(STATUS "Clang version: ${CLANG_VERSION}") |
Douglas Gregor | 7f7b748 | 2009-08-23 05:28:29 +0000 | [diff] [blame] | 130 | |
Daniel Dunbar | a510767 | 2010-06-25 17:33:46 +0000 | [diff] [blame] | 131 | string(REGEX REPLACE "([0-9]+)\\.[0-9]+(\\.[0-9]+)?" "\\1" CLANG_VERSION_MAJOR |
| 132 | ${CLANG_VERSION}) |
| 133 | string(REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" CLANG_VERSION_MINOR |
| 134 | ${CLANG_VERSION}) |
| 135 | if (${CLANG_VERSION} MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+") |
| 136 | set(CLANG_HAS_VERSION_PATCHLEVEL 1) |
| 137 | string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" CLANG_VERSION_PATCHLEVEL |
| 138 | ${CLANG_VERSION}) |
| 139 | else() |
| 140 | set(CLANG_HAS_VERSION_PATCHLEVEL 0) |
| 141 | endif() |
| 142 | |
| 143 | # Configure the Version.inc file. |
| 144 | configure_file( |
| 145 | ${CMAKE_CURRENT_SOURCE_DIR}/include/clang/Basic/Version.inc.in |
| 146 | ${CMAKE_CURRENT_BINARY_DIR}/include/clang/Basic/Version.inc) |
| 147 | |
Douglas Gregor | 9df3faf | 2009-09-18 14:47:57 +0000 | [diff] [blame] | 148 | # Add appropriate flags for GCC |
Oscar Fuentes | c5cd252 | 2011-05-11 13:53:30 +0000 | [diff] [blame] | 149 | if (LLVM_COMPILER_IS_GCC_COMPATIBLE) |
Richard Smith | 19258e8 | 2013-04-22 14:51:21 +0000 | [diff] [blame] | 150 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-common -Woverloaded-virtual -Wcast-qual -fno-strict-aliasing") |
| 151 | |
| 152 | # Enable -pedantic for Clang even if it's not enabled for LLVM. |
| 153 | if (NOT LLVM_ENABLE_PEDANTIC) |
| 154 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wno-long-long") |
| 155 | endif () |
Jordan Rose | 549a292 | 2013-03-02 00:49:47 +0000 | [diff] [blame] | 156 | |
| 157 | check_cxx_compiler_flag("-Werror -Wnested-anon-types" CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG) |
| 158 | if( CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG ) |
| 159 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-nested-anon-types" ) |
| 160 | endif() |
Douglas Gregor | 9df3faf | 2009-09-18 14:47:57 +0000 | [diff] [blame] | 161 | endif () |
| 162 | |
Douglas Gregor | eb5dc49 | 2010-06-08 19:23:49 +0000 | [diff] [blame] | 163 | if (APPLE) |
Andy Gibbs | 39bdd4f | 2013-06-12 20:02:59 +0000 | [diff] [blame] | 164 | set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-flat_namespace -Wl,-undefined -Wl,suppress") |
Douglas Gregor | eb5dc49 | 2010-06-08 19:23:49 +0000 | [diff] [blame] | 165 | endif () |
| 166 | |
Oscar Fuentes | 2100fe9 | 2011-02-03 22:48:20 +0000 | [diff] [blame] | 167 | configure_file( |
| 168 | ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake |
| 169 | ${CLANG_BINARY_DIR}/include/clang/Config/config.h) |
| 170 | |
Oscar Fuentes | c8da1ec | 2011-02-20 22:06:32 +0000 | [diff] [blame] | 171 | include(LLVMParseArguments) |
| 172 | |
| 173 | function(clang_tablegen) |
| 174 | # Syntax: |
| 175 | # clang_tablegen output-file [tablegen-arg ...] SOURCE source-file |
| 176 | # [[TARGET cmake-target-name] [DEPENDS extra-dependency ...]] |
| 177 | # |
| 178 | # Generates a custom command for invoking tblgen as |
| 179 | # |
| 180 | # tblgen source-file -o=output-file tablegen-arg ... |
| 181 | # |
| 182 | # and, if cmake-target-name is provided, creates a custom target for |
| 183 | # executing the custom command depending on output-file. It is |
| 184 | # possible to list more files to depend after DEPENDS. |
| 185 | |
| 186 | parse_arguments( CTG "SOURCE;TARGET;DEPENDS" "" ${ARGN} ) |
| 187 | |
| 188 | if( NOT CTG_SOURCE ) |
| 189 | message(FATAL_ERROR "SOURCE source-file required by clang_tablegen") |
| 190 | endif() |
| 191 | |
| 192 | set( LLVM_TARGET_DEFINITIONS ${CTG_SOURCE} ) |
Peter Collingbourne | 51d7777 | 2011-10-06 13:03:08 +0000 | [diff] [blame] | 193 | tablegen( CLANG ${CTG_DEFAULT_ARGS} ) |
Oscar Fuentes | c8da1ec | 2011-02-20 22:06:32 +0000 | [diff] [blame] | 194 | |
| 195 | list( GET CTG_DEFAULT_ARGS 0 output_file ) |
| 196 | if( CTG_TARGET ) |
| 197 | add_custom_target( ${CTG_TARGET} DEPENDS ${output_file} ${CTG_DEPENDS} ) |
Oscar Fuentes | a3f787c | 2011-02-20 22:06:44 +0000 | [diff] [blame] | 198 | set_target_properties( ${CTG_TARGET} PROPERTIES FOLDER "Clang tablegenning") |
Oscar Fuentes | c8da1ec | 2011-02-20 22:06:32 +0000 | [diff] [blame] | 199 | endif() |
| 200 | endfunction(clang_tablegen) |
| 201 | |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 202 | macro(add_clang_library name) |
Oscar Fuentes | 9917401 | 2011-01-03 17:00:02 +0000 | [diff] [blame] | 203 | llvm_process_sources(srcs ${ARGN}) |
Ted Kremenek | bf5de3f | 2009-03-25 20:34:07 +0000 | [diff] [blame] | 204 | if(MSVC_IDE OR XCODE) |
Jordan Rose | 340d0d3 | 2012-10-23 21:54:03 +0000 | [diff] [blame] | 205 | # Add public headers |
| 206 | file(RELATIVE_PATH lib_path |
| 207 | ${CLANG_SOURCE_DIR}/lib/ |
| 208 | ${CMAKE_CURRENT_SOURCE_DIR} |
| 209 | ) |
| 210 | if(NOT lib_path MATCHES "^[.][.]") |
| 211 | file( GLOB_RECURSE headers |
| 212 | ${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.h |
| 213 | ${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.def |
| 214 | ) |
| 215 | set_source_files_properties(${headers} PROPERTIES HEADER_FILE_ONLY ON) |
| 216 | |
| 217 | file( GLOB_RECURSE tds |
| 218 | ${CLANG_SOURCE_DIR}/include/clang/${lib_path}/*.td |
| 219 | ) |
| 220 | source_group("TableGen descriptions" FILES ${tds}) |
| 221 | set_source_files_properties(${tds}} PROPERTIES HEADER_FILE_ONLY ON) |
| 222 | |
| 223 | set(srcs ${srcs} ${headers} ${tds}) |
| 224 | endif() |
Ted Kremenek | bf5de3f | 2009-03-25 20:34:07 +0000 | [diff] [blame] | 225 | endif(MSVC_IDE OR XCODE) |
Douglas Gregor | eb5dc49 | 2010-06-08 19:23:49 +0000 | [diff] [blame] | 226 | if (MODULE) |
| 227 | set(libkind MODULE) |
| 228 | elseif (SHARED_LIBRARY) |
Douglas Gregor | ac47bc7 | 2009-09-25 06:35:15 +0000 | [diff] [blame] | 229 | set(libkind SHARED) |
| 230 | else() |
| 231 | set(libkind) |
| 232 | endif() |
| 233 | add_library( ${name} ${libkind} ${srcs} ) |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 234 | if( LLVM_COMMON_DEPENDS ) |
| 235 | add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} ) |
| 236 | endif( LLVM_COMMON_DEPENDS ) |
Oscar Fuentes | fb767c8 | 2011-03-29 20:51:00 +0000 | [diff] [blame] | 237 | |
Oscar Fuentes | fb767c8 | 2011-03-29 20:51:00 +0000 | [diff] [blame] | 238 | llvm_config( ${name} ${LLVM_LINK_COMPONENTS} ) |
| 239 | target_link_libraries( ${name} ${LLVM_COMMON_LIBS} ) |
| 240 | link_system_libs( ${name} ) |
| 241 | |
Hans Wennborg | 885e36e | 2013-08-24 00:22:23 +0000 | [diff] [blame] | 242 | if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang") |
| 243 | install(TARGETS ${name} |
| 244 | LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} |
| 245 | ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} |
| 246 | RUNTIME DESTINATION bin) |
| 247 | endif() |
| 248 | |
Oscar Fuentes | a3f787c | 2011-02-20 22:06:44 +0000 | [diff] [blame] | 249 | set_target_properties(${name} PROPERTIES FOLDER "Clang libraries") |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 250 | endmacro(add_clang_library) |
| 251 | |
| 252 | macro(add_clang_executable name) |
Oscar Fuentes | 9917401 | 2011-01-03 17:00:02 +0000 | [diff] [blame] | 253 | add_llvm_executable( ${name} ${ARGN} ) |
Oscar Fuentes | a3f787c | 2011-02-20 22:06:44 +0000 | [diff] [blame] | 254 | set_target_properties(${name} PROPERTIES FOLDER "Clang executables") |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 255 | endmacro(add_clang_executable) |
| 256 | |
Oscar Fuentes | 617508f | 2011-03-17 19:03:04 +0000 | [diff] [blame] | 257 | include_directories(BEFORE |
Douglas Gregor | a393e9e | 2009-03-16 23:06:59 +0000 | [diff] [blame] | 258 | ${CMAKE_CURRENT_BINARY_DIR}/include |
Oscar Fuentes | 617508f | 2011-03-17 19:03:04 +0000 | [diff] [blame] | 259 | ${CMAKE_CURRENT_SOURCE_DIR}/include |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 260 | ) |
| 261 | |
Hans Wennborg | 885e36e | 2013-08-24 00:22:23 +0000 | [diff] [blame] | 262 | if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY) |
| 263 | install(DIRECTORY include/ |
| 264 | DESTINATION include |
| 265 | FILES_MATCHING |
| 266 | PATTERN "*.def" |
| 267 | PATTERN "*.h" |
| 268 | PATTERN "config.h" EXCLUDE |
| 269 | PATTERN ".svn" EXCLUDE |
| 270 | ) |
Chris Lattner | bc6ec75 | 2008-11-11 18:39:10 +0000 | [diff] [blame] | 271 | |
Hans Wennborg | 885e36e | 2013-08-24 00:22:23 +0000 | [diff] [blame] | 272 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/ |
| 273 | DESTINATION include |
| 274 | FILES_MATCHING |
| 275 | PATTERN "CMakeFiles" EXCLUDE |
| 276 | PATTERN "*.inc" |
| 277 | ) |
| 278 | endif() |
| 279 | |
| 280 | install(DIRECTORY include/clang-c |
Kovarththanan Rajaratnam | ec700a6 | 2010-04-01 14:24:41 +0000 | [diff] [blame] | 281 | DESTINATION include |
| 282 | FILES_MATCHING |
Hans Wennborg | 885e36e | 2013-08-24 00:22:23 +0000 | [diff] [blame] | 283 | PATTERN "*.h" |
| 284 | PATTERN ".svn" EXCLUDE |
Kovarththanan Rajaratnam | ec700a6 | 2010-04-01 14:24:41 +0000 | [diff] [blame] | 285 | ) |
| 286 | |
Dylan Noblesmith | cc8a945 | 2012-02-14 15:54:49 +0000 | [diff] [blame] | 287 | add_definitions( -D_GNU_SOURCE ) |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 288 | |
Jordan Rose | e638503 | 2013-08-22 15:50:02 +0000 | [diff] [blame] | 289 | option(CLANG_ENABLE_ARCMT "Build ARCMT." ON) |
| 290 | option(CLANG_ENABLE_REWRITER "Build rewriter." ON) |
| 291 | option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON) |
Roman Divacky | ff62d64 | 2013-05-29 21:09:18 +0000 | [diff] [blame] | 292 | |
| 293 | if (NOT CLANG_ENABLE_REWRITER AND CLANG_ENABLE_ARCMT) |
| 294 | message(FATAL_ERROR "Cannot disable rewriter while enabling ARCMT") |
| 295 | endif() |
| 296 | |
| 297 | if (NOT CLANG_ENABLE_REWRITER AND CLANG_ENABLE_STATIC_ANALYZER) |
| 298 | message(FATAL_ERROR "Cannot disable rewriter while enabling static analyzer") |
| 299 | endif() |
| 300 | |
Jordan Rose | e638503 | 2013-08-22 15:50:02 +0000 | [diff] [blame] | 301 | if (NOT CLANG_ENABLE_STATIC_ANALYZER AND CLANG_ENABLE_ARCMT) |
| 302 | message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT") |
| 303 | endif() |
| 304 | |
Roman Divacky | ff62d64 | 2013-05-29 21:09:18 +0000 | [diff] [blame] | 305 | if(CLANG_ENABLE_ARCMT) |
| 306 | add_definitions(-DCLANG_ENABLE_ARCMT) |
| 307 | endif() |
| 308 | if(CLANG_ENABLE_REWRITER) |
| 309 | add_definitions(-DCLANG_ENABLE_REWRITER) |
| 310 | endif() |
| 311 | if(CLANG_ENABLE_STATIC_ANALYZER) |
| 312 | add_definitions(-DCLANG_ENABLE_STATIC_ANALYZER) |
| 313 | endif() |
NAKAMURA Takumi | 68f22af | 2012-12-13 16:24:59 +0000 | [diff] [blame] | 314 | |
Douglas Gregor | 8435bf9 | 2011-02-25 19:24:02 +0000 | [diff] [blame] | 315 | # Clang version information |
| 316 | set(CLANG_EXECUTABLE_VERSION |
| 317 | "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}" CACHE STRING |
| 318 | "Version number that will be placed into the clang executable, in the form XX.YY") |
| 319 | set(LIBCLANG_LIBRARY_VERSION |
| 320 | "${CLANG_VERSION_MAJOR}.${CLANG_VERSION_MINOR}" CACHE STRING |
| 321 | "Version number that will be placed into the libclang library , in the form XX.YY") |
| 322 | mark_as_advanced(CLANG_EXECUTABLE_VERSION LIBCLANG_LIBRARY_VERSION) |
| 323 | |
Jordan Rose | 17e95c8 | 2013-09-12 16:17:41 +0000 | [diff] [blame] | 324 | option(CLANG_ALWAYS_CHECK_VC_REV "Always keep revision number up-to-date." OFF) |
| 325 | |
Peter Collingbourne | 51d7777 | 2011-10-06 13:03:08 +0000 | [diff] [blame] | 326 | add_subdirectory(utils/TableGen) |
Douglas Gregor | 8435bf9 | 2011-02-25 19:24:02 +0000 | [diff] [blame] | 327 | |
Douglas Gregor | a393e9e | 2009-03-16 23:06:59 +0000 | [diff] [blame] | 328 | add_subdirectory(include) |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 329 | add_subdirectory(lib) |
Daniel Dunbar | cbcd98b | 2009-03-24 02:52:57 +0000 | [diff] [blame] | 330 | add_subdirectory(tools) |
Michael J. Spencer | 48263ba | 2010-12-16 03:28:42 +0000 | [diff] [blame] | 331 | add_subdirectory(runtime) |
Oscar Fuentes | d2f4e5e | 2008-10-26 00:56:18 +0000 | [diff] [blame] | 332 | |
NAKAMURA Takumi | e3120ae | 2012-07-27 06:17:48 +0000 | [diff] [blame] | 333 | option(CLANG_BUILD_EXAMPLES "Build CLANG example programs by default." OFF) |
| 334 | add_subdirectory(examples) |
| 335 | |
Jordan Rose | 3092d9d | 2013-02-08 01:42:37 +0000 | [diff] [blame] | 336 | option(CLANG_INCLUDE_TESTS |
| 337 | "Generate build targets for the Clang unit tests." |
Jordan Rose | 6bbaa77 | 2013-02-08 07:28:25 +0000 | [diff] [blame] | 338 | ${LLVM_INCLUDE_TESTS}) |
Jordan Rose | 3092d9d | 2013-02-08 01:42:37 +0000 | [diff] [blame] | 339 | |
| 340 | if( CLANG_INCLUDE_TESTS ) |
Michael Gottesman | 7758bb5 | 2013-08-20 07:09:54 +0000 | [diff] [blame] | 341 | add_subdirectory(test) |
Jordan Rose | 3092d9d | 2013-02-08 01:42:37 +0000 | [diff] [blame] | 342 | add_subdirectory(unittests) |
Jeffrey Yasskin | 718b01d | 2011-02-15 07:54:28 +0000 | [diff] [blame] | 343 | endif() |
NAKAMURA Takumi | 792f975 | 2011-02-16 03:07:15 +0000 | [diff] [blame] | 344 | |
Michael Gottesman | 1ab6c6c | 2013-08-28 20:29:40 +0000 | [diff] [blame] | 345 | option(CLANG_INCLUDE_DOCS "Generate build targets for the Clang docs." |
| 346 | ${LLVM_INCLUDE_DOCS}) |
| 347 | if( CLANG_INCLUDE_DOCS ) |
| 348 | add_subdirectory(docs) |
| 349 | endif() |
| 350 | |
NAKAMURA Takumi | 792f975 | 2011-02-16 03:07:15 +0000 | [diff] [blame] | 351 | # Workaround for MSVS10 to avoid the Dialog Hell |
| 352 | # FIXME: This could be removed with future version of CMake. |
| 353 | if( CLANG_BUILT_STANDALONE AND MSVC_VERSION EQUAL 1600 ) |
| 354 | set(CLANG_SLN_FILENAME "${CMAKE_CURRENT_BINARY_DIR}/Clang.sln") |
| 355 | if( EXISTS "${CLANG_SLN_FILENAME}" ) |
| 356 | file(APPEND "${CLANG_SLN_FILENAME}" "\n# This should be regenerated!\n") |
| 357 | endif() |
| 358 | endif() |
Chad Rosier | fc61427 | 2011-08-02 20:44:34 +0000 | [diff] [blame] | 359 | |
| 360 | set(BUG_REPORT_URL "http://llvm.org/bugs/" CACHE STRING |
| 361 | "Default URL where bug reports are to be submitted.") |
Michael Gottesman | f65456f | 2013-08-20 07:41:18 +0000 | [diff] [blame] | 362 | |
Michael Gottesman | 54b0012 | 2013-08-27 04:40:12 +0000 | [diff] [blame] | 363 | set(CLANG_ORDER_FILE "" CACHE FILEPATH |
| 364 | "Order file to use when compiling clang in order to improve startup time.") |