Generalize GVN's phi construciton routine to work for things other than loads.
[llvm/msp430.git] / CMakeLists.txt
blob2072c703715d959407d318c2375df69433179fd1
1 project(LLVM)
2 cmake_minimum_required(VERSION 2.6.1)
4 set(PACKAGE_NAME llvm)
5 set(PACKAGE_VERSION svn)
6 set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu")
8 if( CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR AND NOT MSVC_IDE )
9   message(FATAL_ERROR "In-source builds are not allowed.
10 CMake would overwrite the makefiles distributed with LLVM.
11 Please create a directory and run cmake from there, passing the path
12 to this source directory as the last argument.
13 This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
14 Please delete them.")
15 endif()
17 include(FindPerl)
19 set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
20 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include)
21 set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
22 set(LLVM_TOOLS_BINARY_DIR ${LLVM_BINARY_DIR}/bin)
23 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
25 set(LLVM_ALL_TARGETS
26   Alpha
27   ARM
28   CBackend
29   CellSPU
30   CppBackend
31   IA64
32   Mips
33   MSIL
34   PIC16
35   PowerPC
36   Sparc
37   X86
38   XCore
39   )
41 # List of targets whose asmprinters need to be forced to link
42 # into executables on some platforms (i.e. Windows):
43 set(LLVM_ASMPRINTERS_FORCE_LINK X86 PowerPC)
45 if( MSVC )
46   set(LLVM_TARGETS_TO_BUILD X86
47     CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
48 else( MSVC )
49   set(LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS}
50     CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
51 endif( MSVC )
53 option(LLVM_ENABLE_THREADS "Use threads if available." ON)
55 if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
56   set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
57 endif()
59 foreach(c ${LLVM_TARGETS_TO_BUILD})
60   list(FIND LLVM_ALL_TARGETS ${c} idx)
61   if( idx LESS 0 )
62     message(FATAL_ERROR "The target `${c}' does not exists.
63     It should be one of\n${LLVM_ALL_TARGETS}")
64   endif()
65 endforeach(c)
67 set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm)
69 # Add path for custom modules
70 set(CMAKE_MODULE_PATH
71   ${CMAKE_MODULE_PATH}
72   "${LLVM_MAIN_SRC_DIR}/cmake"
73   "${LLVM_MAIN_SRC_DIR}/cmake/modules"
74   )
76 if(WIN32)
77   if(CYGWIN)
78     set(LLVM_ON_WIN32 0)
79     set(LLVM_ON_UNIX 1)
80   else(CYGWIN)
81     set(LLVM_ON_WIN32 1)
82     set(LLVM_ON_UNIX 0)
83   endif(CYGWIN)
84   set(LTDL_SHLIB_EXT ".dll")
85   set(EXEEXT ".exe")
86   # Maximum path length is 160 for non-unicode paths
87   set(MAXPATHLEN 160)
88 else(WIN32)
89   if(UNIX)
90     set(LLVM_ON_WIN32 0)
91     set(LLVM_ON_UNIX 1)
92     set(LTDL_SHLIB_EXT ".so")
93     set(EXEEXT "")
94     # FIXME: Maximum path length is currently set to 'safe' fixed value
95     set(MAXPATHLEN 2024)
96   else(UNIX)
97     MESSAGE(SEND_ERROR "Unable to determine platform")
98   endif(UNIX)
99 endif(WIN32)
101 if( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config )
102   set(HAVE_LLVM_CONFIG 1)
103 endif( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config )
105 include(config-ix)
107 option(LLVM_ENABLE_PIC "Build Position-Independent Code" OFF)
109 if( LLVM_ENABLE_PIC )
110   if( SUPPORTS_FPIC_FLAG )
111     message(STATUS "Building with -fPIC")
112     add_definitions(-fPIC)
113   else( SUPPORTS_FPIC_FLAG )
114     message(STATUS "Warning: -fPIC not supported.")
115   endif()
116 endif()
118 set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
119 set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
120 set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib )
122 # set(CMAKE_VERBOSE_MAKEFILE true)
124 add_definitions( -D__STDC_LIMIT_MACROS )
125 add_definitions( -D__STDC_CONSTANT_MACROS )
127 set(LLVM_PLO_FLAGS "" CACHE
128   STRING "Flags for creating partially linked objects.")
130 if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
131   # TODO: support other platforms and toolchains.
132   option(LLVM_BUILD_32_BITS "Build 32 bits executables and libraries." OFF)
133   if( LLVM_BUILD_32_BITS )
134     message(STATUS "Building 32 bits executables and libraries.")
135     add_definitions( -m32 )
136     list(APPEND CMAKE_EXE_LINKER_FLAGS -m32)
137     list(APPEND CMAKE_SHARED_LINKER_FLAGS -m32)
138     set( LLVM_PLO_FLAGS -melf_i386 ${LLVM_PLO_FLAGS} )
139   endif( LLVM_BUILD_32_BITS )
140 endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 )
142 if( MSVC )
143   add_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS )
144   add_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS )
145   add_definitions( -D_SCL_SECURE_NO_DEPRECATE )
146   add_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 )
147   add_definitions( -wd4355 -wd4715 )
148 endif( MSVC )
150 include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR})
152 include(AddLLVM)
153 include(AddPartiallyLinkedObject)
154 include(TableGen)
156 add_subdirectory(lib/Support)
157 add_subdirectory(lib/System)
159 # Everything else depends on Support and System:
160 set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} )
162 set(LLVM_TABLEGEN "tblgen" CACHE
163   STRING "Native TableGen executable. Saves building one when cross-compiling.")
165 add_subdirectory(utils/TableGen)
167 if( CMAKE_CROSSCOMPILING )
168   # This adds a dependency on target `tblgen', so must go after utils/TableGen
169   include( CrossCompileLLVM )
170 endif( CMAKE_CROSSCOMPILING )
172 add_subdirectory(include/llvm)
174 add_subdirectory(lib/VMCore)
175 add_subdirectory(lib/CodeGen)
176 add_subdirectory(lib/CodeGen/SelectionDAG)
177 add_subdirectory(lib/CodeGen/AsmPrinter)
178 add_subdirectory(lib/Bitcode/Reader)
179 add_subdirectory(lib/Bitcode/Writer)
180 add_subdirectory(lib/Transforms/Utils)
181 add_subdirectory(lib/Transforms/Instrumentation)
182 add_subdirectory(lib/Transforms/Scalar)
183 add_subdirectory(lib/Transforms/IPO)
184 add_subdirectory(lib/Transforms/Hello)
185 add_subdirectory(lib/Linker)
186 add_subdirectory(lib/Analysis)
187 add_subdirectory(lib/Analysis/IPA)
189 foreach(t ${LLVM_TARGETS_TO_BUILD})
190   message(STATUS "Targeting ${t}")
191   add_subdirectory(lib/Target/${t})
192   if( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
193     add_subdirectory(lib/Target/${t}/AsmPrinter)
194   endif( EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt )
195 endforeach(t)
197 add_subdirectory(lib/ExecutionEngine)
198 add_subdirectory(lib/ExecutionEngine/Interpreter)
199 add_subdirectory(lib/ExecutionEngine/JIT)
200 add_subdirectory(lib/Target)
201 add_subdirectory(lib/AsmParser)
202 add_subdirectory(lib/Debugger)
203 add_subdirectory(lib/Archive)
205 add_subdirectory(tools)
207 add_subdirectory(examples)
209 install(DIRECTORY include
210   DESTINATION .
211   PATTERN ".svn" EXCLUDE
212   PATTERN "*.cmake" EXCLUDE
213   PATTERN "*.in" EXCLUDE
214   )
216 install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include
217   DESTINATION .
218   )
220 # TODO: make and install documentation.