Cedric Venet | 1d083f4 | 2008-10-30 21:22:00 +0000 | [diff] [blame] | 1 | project(LLVM) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 2 | cmake_minimum_required(VERSION 2.6.1) |
| 3 | |
| 4 | set(PACKAGE_NAME llvm) |
| 5 | set(PACKAGE_VERSION svn) |
Oscar Fuentes | f7e73b9 | 2008-10-25 03:49:35 +0000 | [diff] [blame] | 6 | set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu") |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 7 | |
| 8 | include(FindPerl) |
| 9 | |
| 10 | set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
Oscar Fuentes | 980e842 | 2008-10-29 02:33:15 +0000 | [diff] [blame] | 11 | set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 12 | set(LLVM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
| 13 | set(LLVM_TOOLS_BINARY_DIR ${LLVM_BINARY_DIR}/bin) |
| 14 | set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples) |
| 15 | |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 16 | set(LLVM_ALL_TARGETS |
| 17 | Alpha |
| 18 | ARM |
| 19 | CBackend |
| 20 | CellSPU |
| 21 | CppBackend |
| 22 | IA64 |
| 23 | Mips |
| 24 | MSIL |
| 25 | PIC16 |
| 26 | PowerPC |
| 27 | Sparc |
| 28 | X86 |
| 29 | XCore |
| 30 | ) |
| 31 | |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 32 | if( MSVC ) |
| 33 | set(LLVM_TARGETS_TO_BUILD X86 |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 34 | CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 35 | else( MSVC ) |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 36 | set(LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} |
| 37 | CACHE STRING "Semicolon-separated list of targets to build, or \"all\".") |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 38 | endif( MSVC ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 39 | |
Oscar Fuentes | 4f21c13 | 2008-11-10 01:47:07 +0000 | [diff] [blame] | 40 | if( LLVM_TARGETS_TO_BUILD STREQUAL "all" ) |
| 41 | set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} ) |
| 42 | endif() |
| 43 | |
| 44 | foreach(c ${LLVM_TARGETS_TO_BUILD}) |
| 45 | list(FIND LLVM_ALL_TARGETS ${c} idx) |
| 46 | if( idx LESS 0 ) |
| 47 | message(FATAL_ERROR "The target `${c}' does not exists. |
| 48 | It should be one of\n${LLVM_ALL_TARGETS}") |
| 49 | endif() |
| 50 | endforeach(c) |
| 51 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 52 | set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm) |
| 53 | |
| 54 | # Add path for custom modules |
| 55 | set(CMAKE_MODULE_PATH |
| 56 | ${CMAKE_MODULE_PATH} |
| 57 | "${LLVM_MAIN_SRC_DIR}/cmake" |
| 58 | "${LLVM_MAIN_SRC_DIR}/cmake/modules" |
| 59 | ) |
| 60 | |
| 61 | if(WIN32) |
Oscar Fuentes | 4fd38b8 | 2008-10-30 17:15:54 +0000 | [diff] [blame] | 62 | if(CYGWIN) |
| 63 | set(LLVM_ON_WIN32 0) |
| 64 | set(LLVM_ON_UNIX 1) |
| 65 | else(CYGWIN) |
| 66 | set(LLVM_ON_WIN32 1) |
| 67 | set(LLVM_ON_UNIX 0) |
| 68 | endif(CYGWIN) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 69 | set(LTDL_SHLIB_EXT ".dll") |
| 70 | set(EXEEXT ".exe") |
| 71 | # Maximum path length is 160 for non-unicode paths |
| 72 | set(MAXPATHLEN 160) |
| 73 | else(WIN32) |
| 74 | if(UNIX) |
| 75 | set(LLVM_ON_WIN32 0) |
| 76 | set(LLVM_ON_UNIX 1) |
| 77 | set(LTDL_SHLIB_EXT ".so") |
| 78 | set(EXEEXT "") |
| 79 | # FIXME: Maximum path length is currently set to 'safe' fixed value |
| 80 | set(MAXPATHLEN 2024) |
| 81 | else(UNIX) |
| 82 | MESSAGE(SEND_ERROR "Unable to determine platform") |
| 83 | endif(UNIX) |
| 84 | endif(WIN32) |
| 85 | |
| 86 | if( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config ) |
| 87 | set(HAVE_LLVM_CONFIG 1) |
| 88 | endif( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config ) |
| 89 | # find_file(HAVE_LLVM_CONFIG llvm-config ${LLVM_TOOLS_BINARY_DIR}) |
| 90 | # message(STATUS ${HAVE_LLVM_CONFIG}) |
| 91 | |
Oscar Fuentes | de98db3 | 2008-10-25 03:29:36 +0000 | [diff] [blame] | 92 | include(config-ix) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 93 | |
| 94 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} ) |
| 95 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 96 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 97 | |
| 98 | # set(CMAKE_VERBOSE_MAKEFILE true) |
| 99 | |
| 100 | add_definitions( -D__STDC_LIMIT_MACROS ) |
Oscar Fuentes | 0a48698 | 2008-10-30 17:21:37 +0000 | [diff] [blame] | 101 | add_definitions( -D__STDC_CONSTANT_MACROS ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 102 | |
Oscar Fuentes | b0c5699 | 2008-11-04 03:27:24 +0000 | [diff] [blame] | 103 | set(LLVM_PLO_FLAGS "" CACHE |
| 104 | STRING "Flags for creating partially linked objects.") |
| 105 | |
| 106 | if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) |
| 107 | # TODO: support other platforms and toolchains. |
| 108 | option(BUILD_32_BITS "Build 32 bits executables and libraries." OFF) |
| 109 | if( BUILD_32_BITS ) |
| 110 | message(STATUS "Building 32 bits executables and libraries.") |
| 111 | add_definitions( -m32 ) |
| 112 | set( CMAKE_EXE_LINKER_FLAGS "-m32 ${CMAKE_EXE_LINKER_FLAGS}" ) |
| 113 | set( CMAKE_LINK_LIBRARY_FLAG "-m32 ${CMAKE_LINK_LIBRARY_FLAG}" ) |
| 114 | set( LLVM_PLO_FLAGS -melf_i386 ${LLVM_PLO_FLAGS} ) |
| 115 | endif( BUILD_32_BITS ) |
| 116 | endif( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32 ) |
| 117 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 118 | if( MSVC ) |
| 119 | add_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS ) |
| 120 | add_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS ) |
| 121 | add_definitions( -D_SCL_SECURE_NO_DEPRECATE ) |
Oscar Fuentes | a789af2 | 2008-09-24 19:27:54 +0000 | [diff] [blame] | 122 | add_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 ) |
| 123 | add_definitions( -wd4355 -wd4715 ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 124 | endif( MSVC ) |
| 125 | |
Oscar Fuentes | 980e842 | 2008-10-29 02:33:15 +0000 | [diff] [blame] | 126 | include_directories( ${LLVM_BINARY_DIR}/include ${LLVM_MAIN_INCLUDE_DIR}) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 127 | #link_directories( d:/dev/lib ) |
| 128 | |
| 129 | #add_subdirectory(lib) |
| 130 | |
| 131 | include(AddLLVM) |
| 132 | include(AddPartiallyLinkedObject) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 133 | include(TableGen) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 134 | |
| 135 | add_subdirectory(lib/Support) |
| 136 | add_subdirectory(lib/System) |
Oscar Fuentes | 1d8e4cf | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 137 | |
| 138 | # Everything else depends on Support and System: |
| 139 | set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} ) |
| 140 | |
Oscar Fuentes | 3ab40ca | 2008-11-09 18:53:19 +0000 | [diff] [blame] | 141 | set(LLVM_TABLEGEN "tblgen" CACHE |
Oscar Fuentes | 41bdedf | 2008-11-10 02:35:55 +0000 | [diff] [blame] | 142 | STRING "Native TableGen executable. Saves building one when cross-compiling.") |
Oscar Fuentes | 3ab40ca | 2008-11-09 18:53:19 +0000 | [diff] [blame] | 143 | |
Oscar Fuentes | 02516ba | 2008-11-10 01:32:14 +0000 | [diff] [blame] | 144 | add_subdirectory(utils/TableGen) |
| 145 | |
Oscar Fuentes | 3ab40ca | 2008-11-09 18:53:19 +0000 | [diff] [blame] | 146 | if( CMAKE_CROSSCOMPILING ) |
Oscar Fuentes | 02516ba | 2008-11-10 01:32:14 +0000 | [diff] [blame] | 147 | # This adds a dependency on target `tblgen', so must go after utils/TableGen |
Oscar Fuentes | 3ab40ca | 2008-11-09 18:53:19 +0000 | [diff] [blame] | 148 | include( CrossCompileLLVM ) |
| 149 | endif( CMAKE_CROSSCOMPILING ) |
| 150 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 151 | add_custom_command(OUTPUT ${llvm_builded_incs_dir}/Intrinsics.gen |
Oscar Fuentes | 3ab40ca | 2008-11-09 18:53:19 +0000 | [diff] [blame] | 152 | COMMAND ${LLVM_TABLEGEN} -gen-intrinsic -I ${LLVM_MAIN_INCLUDE_DIR} ${LLVM_MAIN_INCLUDE_DIR}/llvm/Intrinsics.td -o ${llvm_builded_incs_dir}/Intrinsics.gen |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 153 | DEPENDS tblgen |
| 154 | COMMENT "Building intrinsics.gen...") |
| 155 | |
| 156 | add_custom_target(intrinsics_gen ALL |
| 157 | DEPENDS ${llvm_builded_incs_dir}/Intrinsics.gen) |
| 158 | |
Oscar Fuentes | 1d8e4cf | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 159 | set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} intrinsics_gen ) |
| 160 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 161 | add_subdirectory(lib/VMCore) |
| 162 | add_subdirectory(lib/CodeGen) |
| 163 | add_subdirectory(lib/CodeGen/SelectionDAG) |
| 164 | add_subdirectory(lib/CodeGen/AsmPrinter) |
| 165 | add_subdirectory(lib/Bitcode/Reader) |
| 166 | add_subdirectory(lib/Bitcode/Writer) |
| 167 | add_subdirectory(lib/Transforms/Utils) |
| 168 | add_subdirectory(lib/Transforms/Instrumentation) |
| 169 | add_subdirectory(lib/Transforms/Scalar) |
| 170 | add_subdirectory(lib/Transforms/IPO) |
| 171 | add_subdirectory(lib/Transforms/Hello) |
| 172 | add_subdirectory(lib/Linker) |
| 173 | add_subdirectory(lib/Analysis) |
| 174 | add_subdirectory(lib/Analysis/IPA) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 175 | |
| 176 | foreach(t ${LLVM_TARGETS_TO_BUILD}) |
| 177 | message(STATUS "Targeting ${t}") |
| 178 | add_subdirectory(lib/Target/${t}) |
| 179 | if( EXISTS ${CMAKE_SOURCE_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt ) |
| 180 | add_subdirectory(lib/Target/${t}/AsmPrinter) |
| 181 | endif( EXISTS ${CMAKE_SOURCE_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt ) |
| 182 | endforeach(t) |
| 183 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 184 | add_subdirectory(lib/ExecutionEngine) |
| 185 | add_subdirectory(lib/ExecutionEngine/Interpreter) |
| 186 | add_subdirectory(lib/ExecutionEngine/JIT) |
| 187 | add_subdirectory(lib/Target) |
| 188 | add_subdirectory(lib/AsmParser) |
| 189 | add_subdirectory(lib/Debugger) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 190 | add_subdirectory(lib/Archive) |
| 191 | |
| 192 | add_subdirectory(tools) |
| 193 | |
| 194 | add_subdirectory(examples) |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame] | 195 | |
| 196 | install(DIRECTORY include |
| 197 | DESTINATION . |
| 198 | PATTERN ".svn" EXCLUDE |
| 199 | PATTERN "*.cmake" EXCLUDE |
| 200 | PATTERN "*.in" EXCLUDE |
| 201 | ) |
| 202 | |
| 203 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include |
| 204 | DESTINATION . |
| 205 | ) |
| 206 | |
| 207 | # TODO: make and install documentation. |