1 # See docs/CMake.html for instructions about how to build LLVM with CMake.
3 cmake_minimum_required(VERSION 2.8.8)
5 # FIXME: It may be removed when we use 2.8.12.
6 if(CMAKE_VERSION VERSION_LESS 2.8.12)
7 # Invalidate a couple of keywords.
8 set(cmake_2_8_12_INTERFACE)
9 set(cmake_2_8_12_PRIVATE)
11 # Use ${cmake_2_8_12_KEYWORD} intead of KEYWORD in target_link_libraries().
12 set(cmake_2_8_12_INTERFACE INTERFACE)
13 set(cmake_2_8_12_PRIVATE PRIVATE)
15 cmake_policy(SET CMP0022 NEW) # automatic when 2.8.12 is required
19 if(CMAKE_VERSION VERSION_LESS 3.1.20141117)
20 set(cmake_3_2_USES_TERMINAL)
22 set(cmake_3_2_USES_TERMINAL USES_TERMINAL)
27 # Add path for custom modules
30 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
31 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
34 set(LLVM_VERSION_MAJOR 3)
35 set(LLVM_VERSION_MINOR 6)
36 set(LLVM_VERSION_PATCH 0)
38 if (NOT PACKAGE_VERSION)
39 set(PACKAGE_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}svn")
42 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
44 option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON)
45 if ( LLVM_USE_FOLDERS )
46 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
49 include(VersionFromVCS)
51 option(LLVM_APPEND_VC_REV
52 "Append the version control system revision id to LLVM version" OFF)
54 if( LLVM_APPEND_VC_REV )
55 add_version_info_from_vcs(PACKAGE_VERSION)
58 set(PACKAGE_NAME LLVM)
59 set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
60 set(PACKAGE_BUGREPORT "http://llvm.org/bugs/")
62 set(BUG_REPORT_URL "${PACKAGE_BUGREPORT}" CACHE STRING
63 "Default URL where bug reports are to be submitted.")
66 set(CPACK_PACKAGE_INSTALL_DIRECTORY "LLVM")
67 set(CPACK_PACKAGE_VENDOR "LLVM")
68 set(CPACK_PACKAGE_VERSION_MAJOR ${LLVM_VERSION_MAJOR})
69 set(CPACK_PACKAGE_VERSION_MINOR ${LLVM_VERSION_MINOR})
70 set(CPACK_PACKAGE_VERSION_PATCH ${LLVM_VERSION_PATCH})
71 set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
72 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.TXT")
73 if(WIN32 AND NOT UNIX)
74 set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "LLVM")
75 set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_logo.bmp")
76 set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico")
77 set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\cmake\\\\nsis_icon.ico")
78 set(CPACK_NSIS_MODIFY_PATH "ON")
79 set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
80 set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
81 "ExecWait '$INSTDIR/tools/msbuild/install.bat'")
82 set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS
83 "ExecWait '$INSTDIR/tools/msbuild/uninstall.bat'")
87 # Sanity check our source directory to make sure that we are not trying to
88 # generate an in-tree build (unless on MSVC_IDE, where it is ok), and to make
89 # sure that we don't have any stray generated files lying around in the tree
90 # (which would end up getting picked up by header search, instead of the correct
92 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
93 message(FATAL_ERROR "In-source builds are not allowed.
94 CMake would overwrite the makefiles distributed with LLVM.
95 Please create a directory and run cmake from there, passing the path
96 to this source directory as the last argument.
97 This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
100 if( NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR )
102 tablegenned_files_on_include_dir
103 "${CMAKE_CURRENT_SOURCE_DIR}/include/llvm/*.gen")
105 tablegenned_files_on_lib_dir
106 "${CMAKE_CURRENT_SOURCE_DIR}/lib/Target/*.inc")
107 if( tablegenned_files_on_include_dir OR tablegenned_files_on_lib_dir)
108 message(FATAL_ERROR "Apparently there is a previous in-source build,
109 probably as the result of running `configure' and `make' on
110 ${CMAKE_CURRENT_SOURCE_DIR}.
111 This may cause problems. The suspicious files are:
112 ${tablegenned_files_on_lib_dir}
113 ${tablegenned_files_on_include_dir}
114 Please clean the source directory.")
118 string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
120 # They are used as destination of target generators.
121 set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
122 set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib)
124 # DLL platform -- put DLLs into bin.
125 set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
127 set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
130 # Each of them corresponds to llvm-config's.
131 set(LLVM_TOOLS_BINARY_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR}) # --bindir
132 set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) # --libdir
133 set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR} ) # --src-root
134 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include ) # --includedir
135 set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} ) # --prefix
137 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
138 set(LLVM_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
139 set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
157 # List of targets with JIT support:
158 set(LLVM_TARGETS_WITH_JIT X86 PowerPC AArch64 ARM Mips SystemZ)
160 set(LLVM_TARGETS_TO_BUILD "all"
161 CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
163 set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ""
164 CACHE STRING "Semicolon-separated list of experimental targets to build.")
166 option(BUILD_SHARED_LIBS
167 "Build all libraries as shared libraries instead of static" OFF)
169 option(LLVM_ENABLE_TIMESTAMPS "Enable embedding timestamp information in build" ON)
170 if(LLVM_ENABLE_TIMESTAMPS)
171 set(ENABLE_TIMESTAMPS 1)
174 option(LLVM_ENABLE_BACKTRACES "Enable embedding backtraces on crash." ON)
175 if(LLVM_ENABLE_BACKTRACES)
176 set(ENABLE_BACKTRACES 1)
179 option(LLVM_ENABLE_CRASH_OVERRIDES "Enable crash overrides." ON)
180 if(LLVM_ENABLE_CRASH_OVERRIDES)
181 set(ENABLE_CRASH_OVERRIDES 1)
184 option(LLVM_ENABLE_FFI "Use libffi to call external functions from the interpreter" OFF)
185 set(FFI_LIBRARY_DIR "" CACHE PATH "Additional directory, where CMake should search for libffi.so")
186 set(FFI_INCLUDE_DIR "" CACHE PATH "Additional directory, where CMake should search for ffi.h or ffi/ffi.h")
188 set(LLVM_TARGET_ARCH "host"
189 CACHE STRING "Set target to use for LLVM JIT or use \"host\" for automatic detection.")
191 option(LLVM_ENABLE_TERMINFO "Use terminfo database if available." ON)
193 option(LLVM_ENABLE_THREADS "Use threads if available." ON)
195 option(LLVM_ENABLE_ZLIB "Use zlib for compression/decompression if available." ON)
197 if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
198 set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
201 set(LLVM_TARGETS_TO_BUILD
202 ${LLVM_TARGETS_TO_BUILD}
203 ${LLVM_EXPERIMENTAL_TARGETS_TO_BUILD})
204 list(REMOVE_DUPLICATES LLVM_TARGETS_TO_BUILD)
206 include(AddLLVMDefinitions)
208 option(LLVM_ENABLE_PIC "Build Position-Independent Code" ON)
210 # MSVC has a gazillion warnings with this.
212 option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." OFF)
214 option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
217 option(LLVM_ENABLE_MODULES "Compile with C++ modules enabled." OFF)
218 option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF)
219 option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
220 option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
221 option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
223 if( NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
224 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" OFF)
226 option(LLVM_ENABLE_ASSERTIONS "Enable assertions" ON)
229 option(LLVM_FORCE_USE_OLD_HOST_TOOLCHAIN
230 "Set to ON to force using an old, unsupported host toolchain." OFF)
232 option(LLVM_USE_INTEL_JITEVENTS
233 "Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code"
236 if( LLVM_USE_INTEL_JITEVENTS )
237 # Verify we are on a supported platform
238 if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
240 "Intel JIT API support is available on Linux and Windows only.")
242 endif( LLVM_USE_INTEL_JITEVENTS )
244 option(LLVM_USE_OPROFILE
245 "Use opagent JIT interface to inform OProfile about JIT code" OFF)
247 # If enabled, verify we are on a platform that supports oprofile.
248 if( LLVM_USE_OPROFILE )
249 if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
250 message(FATAL_ERROR "OProfile support is available on Linux only.")
251 endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
252 endif( LLVM_USE_OPROFILE )
254 set(LLVM_USE_SANITIZER "" CACHE STRING
255 "Define the sanitizer used to build binaries and tests.")
257 option(LLVM_USE_SPLIT_DWARF
258 "Use -gsplit-dwarf when compiling llvm." OFF)
260 option(WITH_POLLY "Build LLVM with Polly" ON)
261 option(LINK_POLLY_INTO_TOOLS "Static link Polly into tools" OFF)
263 # Define an option controlling whether we should build for 32-bit on 64-bit
264 # platforms, where supported.
265 if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
266 # TODO: support other platforms and toolchains.
267 option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
270 # Define the default arguments to use with 'lit', and an option for the user to
272 set(LIT_ARGS_DEFAULT "-sv")
274 set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
276 set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit")
278 # On Win32 hosts, provide an option to specify the path to the GnuWin32 tools.
279 if( WIN32 AND NOT CYGWIN )
280 set(LLVM_LIT_TOOLS_DIR "" CACHE PATH "Path to GnuWin32 tools")
283 # Define options to control the inclusion and default build behavior for
284 # components which may not strictly be necessary (tools, examples, and tests).
286 # This is primarily to support building smaller or faster project files.
287 option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON)
288 option(LLVM_BUILD_TOOLS
289 "Build the LLVM tools. If OFF, just generate build targets." ON)
291 option(LLVM_INCLUDE_UTILS "Generate build targets for the LLVM utils." ON)
293 option(LLVM_BUILD_RUNTIME
294 "Build the LLVM runtime libraries." ON)
295 option(LLVM_BUILD_EXAMPLES
296 "Build the LLVM example programs. If OFF, just generate build targets." OFF)
297 option(LLVM_INCLUDE_EXAMPLES "Generate build targets for the LLVM examples" ON)
299 option(LLVM_BUILD_TESTS
300 "Build LLVM unit tests. If OFF, just generate build targets." OFF)
301 option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON)
303 option (LLVM_BUILD_DOCS "Build the llvm documentation." OFF)
304 option (LLVM_INCLUDE_DOCS "Generate build targets for llvm documentation." ON)
305 option (LLVM_ENABLE_DOXYGEN "Use doxygen to generate llvm API documentation." OFF)
306 option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
308 option (LLVM_BUILD_EXTERNAL_COMPILER_RT
309 "Build compiler-rt as an external project." OFF)
311 option(LLVM_BUILD_LLVM_DYLIB "Build libllvm dynamic library" OFF)
313 # All options referred to from HandleLLVMOptions have to be specified
314 # BEFORE this include, otherwise options will not be correctly set on
318 # By default, we target the host, but this can be overridden at CMake
320 set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING
321 "Default target for which LLVM will generate code." )
322 set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}")
324 include(HandleLLVMOptions)
326 # Verify that we can find a Python 2 interpreter. Python 3 is unsupported.
327 set(Python_ADDITIONAL_VERSIONS 2.7 2.6 2.5)
328 include(FindPythonInterp)
329 if( NOT PYTHONINTERP_FOUND )
331 "Unable to find Python interpreter, required for builds and testing.
333 Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
337 # LLVMBuild Integration
339 # We use llvm-build to generate all the data required by the CMake based
340 # build system in one swoop:
342 # - We generate a file (a CMake fragment) in the object root which contains
343 # all the definitions that are required by CMake.
345 # - We generate the library table used by llvm-config.
347 # - We generate the dependencies for the CMake fragment, so that we will
348 # automatically reconfigure outselves.
350 set(LLVMBUILDTOOL "${LLVM_MAIN_SRC_DIR}/utils/llvm-build/llvm-build")
351 set(LLVMCONFIGLIBRARYDEPENDENCIESINC
352 "${LLVM_BINARY_DIR}/tools/llvm-config/LibraryDependencies.inc")
353 set(LLVMBUILDCMAKEFRAG
354 "${LLVM_BINARY_DIR}/LLVMBuild.cmake")
356 # Create the list of optional components that are enabled
357 if (LLVM_USE_INTEL_JITEVENTS)
358 set(LLVMOPTIONALCOMPONENTS IntelJITEvents)
359 endif (LLVM_USE_INTEL_JITEVENTS)
360 if (LLVM_USE_OPROFILE)
361 set(LLVMOPTIONALCOMPONENTS ${LLVMOPTIONALCOMPONENTS} OProfileJIT)
362 endif (LLVM_USE_OPROFILE)
364 message(STATUS "Constructing LLVMBuild project information")
366 COMMAND ${PYTHON_EXECUTABLE} ${LLVMBUILDTOOL}
367 --native-target "${LLVM_NATIVE_ARCH}"
368 --enable-targets "${LLVM_TARGETS_TO_BUILD}"
369 --enable-optional-components "${LLVMOPTIONALCOMPONENTS}"
370 --write-library-table ${LLVMCONFIGLIBRARYDEPENDENCIESINC}
371 --write-cmake-fragment ${LLVMBUILDCMAKEFRAG}
372 OUTPUT_VARIABLE LLVMBUILDOUTPUT
373 ERROR_VARIABLE LLVMBUILDERRORS
374 OUTPUT_STRIP_TRAILING_WHITESPACE
375 ERROR_STRIP_TRAILING_WHITESPACE
376 RESULT_VARIABLE LLVMBUILDRESULT)
378 # On Win32, CMake doesn't properly handle piping the default output/error
379 # streams into the GUI console. So, we explicitly catch and report them.
380 if( NOT "${LLVMBUILDOUTPUT}" STREQUAL "")
381 message(STATUS "llvm-build output: ${LLVMBUILDOUTPUT}")
383 if( NOT "${LLVMBUILDRESULT}" STREQUAL "0" )
385 "Unexpected failure executing llvm-build: ${LLVMBUILDERRORS}")
388 # Include the generated CMake fragment. This will define properties from the
389 # LLVMBuild files in a format which is easy to consume from CMake, and will add
390 # the dependencies so that CMake will reconfigure properly when the LLVMBuild
392 include(${LLVMBUILDCMAKEFRAG})
396 # Configure all of the various header file fragments LLVM uses which depend on
397 # configuration variables.
398 set(LLVM_ENUM_TARGETS "")
399 set(LLVM_ENUM_ASM_PRINTERS "")
400 set(LLVM_ENUM_ASM_PARSERS "")
401 set(LLVM_ENUM_DISASSEMBLERS "")
402 foreach(t ${LLVM_TARGETS_TO_BUILD})
403 set( td ${LLVM_MAIN_SRC_DIR}/lib/Target/${t} )
405 list(FIND LLVM_ALL_TARGETS ${t} idx)
406 list(FIND LLVM_EXPERIMENTAL_TARGETS_TO_BUILD ${t} idy)
407 if( idx LESS 0 AND idy LESS 0 )
408 message(FATAL_ERROR "The target `${t}' does not exist.
409 It should be one of\n${LLVM_ALL_TARGETS}")
411 set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${t})\n")
414 file(GLOB asmp_file "${td}/*AsmPrinter.cpp")
416 set(LLVM_ENUM_ASM_PRINTERS
417 "${LLVM_ENUM_ASM_PRINTERS}LLVM_ASM_PRINTER(${t})\n")
419 if( EXISTS ${td}/AsmParser/CMakeLists.txt )
420 set(LLVM_ENUM_ASM_PARSERS
421 "${LLVM_ENUM_ASM_PARSERS}LLVM_ASM_PARSER(${t})\n")
423 if( EXISTS ${td}/Disassembler/CMakeLists.txt )
424 set(LLVM_ENUM_DISASSEMBLERS
425 "${LLVM_ENUM_DISASSEMBLERS}LLVM_DISASSEMBLER(${t})\n")
429 # Produce the target definition files, which provide a way for clients to easily
430 # include various classes of targets.
432 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmPrinters.def.in
433 ${LLVM_INCLUDE_DIR}/llvm/Config/AsmPrinters.def
436 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/AsmParsers.def.in
437 ${LLVM_INCLUDE_DIR}/llvm/Config/AsmParsers.def
440 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Disassemblers.def.in
441 ${LLVM_INCLUDE_DIR}/llvm/Config/Disassemblers.def
444 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/Targets.def.in
445 ${LLVM_INCLUDE_DIR}/llvm/Config/Targets.def
448 # Configure the three LLVM configuration header files.
450 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/config.h.cmake
451 ${LLVM_INCLUDE_DIR}/llvm/Config/config.h)
453 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Config/llvm-config.h.cmake
454 ${LLVM_INCLUDE_DIR}/llvm/Config/llvm-config.h)
456 ${LLVM_MAIN_INCLUDE_DIR}/llvm/Support/DataTypes.h.cmake
457 ${LLVM_INCLUDE_DIR}/llvm/Support/DataTypes.h)
459 # They are not referenced. See set_output_directory().
460 set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin )
461 set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
462 set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
464 set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
466 set(CMAKE_INSTALL_NAME_DIR "@rpath")
467 set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
469 if(NOT DEFINED CMAKE_INSTALL_RPATH)
470 set(CMAKE_INSTALL_RPATH "\$ORIGIN/../lib")
471 if (${CMAKE_SYSTEM_NAME} MATCHES FreeBSD)
472 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,origin")
473 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,origin")
475 endif(NOT DEFINED CMAKE_INSTALL_RPATH)
478 # Work around a broken bfd ld behavior. When linking a binary with a
479 # foo.so library, it will try to find any library that foo.so uses and
480 # check its symbols. This is wasteful (the check was done when foo.so
481 # was created) and can fail since it is not the dynamic linker and
482 # doesn't know how to handle search paths correctly.
483 if (UNIX AND NOT APPLE)
484 set(CMAKE_EXE_LINKER_FLAGS
485 "${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-shlib-undefined")
488 set(CMAKE_INCLUDE_CURRENT_DIR ON)
490 include_directories( ${LLVM_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR})
492 # when crosscompiling import the executable targets from a file
493 if(CMAKE_CROSSCOMPILING)
494 include(CrossCompile)
495 endif(CMAKE_CROSSCOMPILING)
497 if( ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD )
498 # On FreeBSD, /usr/local/* is not used by default. In order to build LLVM
499 # with libxml2, iconv.h, etc., we must add /usr/local paths.
500 include_directories("/usr/local/include")
501 link_directories("/usr/local/lib")
502 endif( ${CMAKE_SYSTEM_NAME} MATCHES FreeBSD )
504 if( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
505 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include llvm/Support/Solaris.h")
506 endif( ${CMAKE_SYSTEM_NAME} MATCHES SunOS )
508 # Make sure we don't get -rdynamic in every binary. For those that need it,
509 # use set_target_properties(target PROPERTIES ENABLE_EXPORTS 1)
510 set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
516 # People report that -O3 is unreliable on MinGW. The traditional
517 # build also uses -O2 for that reason:
518 llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
521 # Put this before tblgen. Else we have a circular dependence.
522 add_subdirectory(lib/Support)
523 add_subdirectory(lib/TableGen)
525 add_subdirectory(utils/TableGen)
527 add_subdirectory(include/llvm)
529 add_subdirectory(lib)
531 if( LLVM_INCLUDE_UTILS )
532 add_subdirectory(utils/FileCheck)
533 add_subdirectory(utils/PerfectShuffle)
534 add_subdirectory(utils/count)
535 add_subdirectory(utils/not)
536 add_subdirectory(utils/llvm-lit)
537 add_subdirectory(utils/yaml-bench)
539 if ( LLVM_INCLUDE_TESTS )
540 message(FATAL_ERROR "Including tests when not building utils will not work.
541 Either set LLVM_INCLUDE_UTILS to On, or set LLVM_INCLDE_TESTS to Off.")
545 if(LLVM_INCLUDE_TESTS)
546 add_subdirectory(utils/unittest)
549 add_subdirectory(projects)
552 if(NOT EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt)
557 if( LLVM_INCLUDE_TOOLS )
558 add_subdirectory(tools)
561 if( LLVM_INCLUDE_EXAMPLES )
562 add_subdirectory(examples)
565 if( LLVM_INCLUDE_TESTS )
566 add_subdirectory(test)
567 add_subdirectory(unittests)
569 # This utility is used to prevent crashing tests from calling Dr. Watson on
571 add_subdirectory(utils/KillTheDoctor)
574 # Add a global check rule now that all subdirectories have been traversed
575 # and we know the total set of lit testsuites.
576 get_property(LLVM_LIT_TESTSUITES GLOBAL PROPERTY LLVM_LIT_TESTSUITES)
577 get_property(LLVM_LIT_PARAMS GLOBAL PROPERTY LLVM_LIT_PARAMS)
578 get_property(LLVM_LIT_DEPENDS GLOBAL PROPERTY LLVM_LIT_DEPENDS)
579 get_property(LLVM_LIT_EXTRA_ARGS GLOBAL PROPERTY LLVM_LIT_EXTRA_ARGS)
580 add_lit_target(check-all
581 "Running all regression tests"
582 ${LLVM_LIT_TESTSUITES}
583 PARAMS ${LLVM_LIT_PARAMS}
584 DEPENDS ${LLVM_LIT_DEPENDS}
585 ARGS ${LLVM_LIT_EXTRA_ARGS}
589 if (LLVM_INCLUDE_DOCS)
590 add_subdirectory(docs)
593 add_subdirectory(cmake/modules)
595 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
596 install(DIRECTORY include/llvm include/llvm-c
603 PATTERN "LICENSE.TXT"
604 PATTERN ".svn" EXCLUDE
607 install(DIRECTORY ${LLVM_INCLUDE_DIR}/llvm
614 # Exclude include/llvm/CMakeFiles/intrinsics_gen.dir, matched by "*.def"
615 PATTERN "CMakeFiles" EXCLUDE
616 PATTERN "config.h" EXCLUDE
617 PATTERN ".svn" EXCLUDE