Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.6.1) |
| 2 | |
| 3 | set(PACKAGE_NAME llvm) |
| 4 | set(PACKAGE_VERSION svn) |
| 5 | set(PACKAGE_BUGREPORT "ofv@wanadoo.es") |
| 6 | #set(PACKAGE_BUGREPORT "llvmbugs@cs.uiuc.edu") |
| 7 | |
| 8 | include(FindPerl) |
| 9 | |
| 10 | set(LLVM_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}) |
| 11 | set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_SRC_DIR}/include/llvm) |
| 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 | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 16 | if( MSVC ) |
| 17 | set(LLVM_TARGETS_TO_BUILD X86 |
| 18 | CACHE STRING "Semicolon-separated list of targets to build") |
| 19 | else( MSVC ) |
| 20 | set(LLVM_TARGETS_TO_BUILD |
| 21 | Alpha ARM CBackend CellSPU CppBackend IA64 Mips MSIL PIC16 PowerPC Sparc X86 |
| 22 | CACHE STRING "Semicolon-separated list of targets to build") |
| 23 | endif( MSVC ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 24 | |
| 25 | if( NOT MSVC ) |
| 26 | set(CMAKE_CXX_LINK_EXECUTABLE "sh -c \"${CMAKE_CXX_LINK_EXECUTABLE}\"") |
| 27 | endif( NOT MSVC ) |
| 28 | |
| 29 | # TODO: Eliminate? |
| 30 | get_filename_component(llvm_include_path ${LLVM_MAIN_SRC_DIR}/include ABSOLUTE) |
| 31 | |
| 32 | #get_filename_component(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm ABSOLUTE) |
| 33 | set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm) |
| 34 | |
| 35 | # Add path for custom modules |
| 36 | set(CMAKE_MODULE_PATH |
| 37 | ${CMAKE_MODULE_PATH} |
| 38 | "${LLVM_MAIN_SRC_DIR}/cmake" |
| 39 | "${LLVM_MAIN_SRC_DIR}/cmake/modules" |
| 40 | ) |
| 41 | |
| 42 | if(WIN32) |
| 43 | set(LLVM_ON_WIN32 1) |
| 44 | set(LLVM_ON_UNIX 0) |
| 45 | set(LTDL_SHLIB_EXT ".dll") |
| 46 | set(EXEEXT ".exe") |
| 47 | # Maximum path length is 160 for non-unicode paths |
| 48 | set(MAXPATHLEN 160) |
| 49 | else(WIN32) |
| 50 | if(UNIX) |
| 51 | set(LLVM_ON_WIN32 0) |
| 52 | set(LLVM_ON_UNIX 1) |
| 53 | set(LTDL_SHLIB_EXT ".so") |
| 54 | set(EXEEXT "") |
| 55 | # FIXME: Maximum path length is currently set to 'safe' fixed value |
| 56 | set(MAXPATHLEN 2024) |
| 57 | else(UNIX) |
| 58 | MESSAGE(SEND_ERROR "Unable to determine platform") |
| 59 | endif(UNIX) |
| 60 | endif(WIN32) |
| 61 | |
| 62 | if( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config ) |
| 63 | set(HAVE_LLVM_CONFIG 1) |
| 64 | endif( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config ) |
| 65 | # find_file(HAVE_LLVM_CONFIG llvm-config ${LLVM_TOOLS_BINARY_DIR}) |
| 66 | # message(STATUS ${HAVE_LLVM_CONFIG}) |
| 67 | |
| 68 | if( MSVC ) |
| 69 | message(STATUS "Configuring using MSVC hack.") |
| 70 | include(config-w32) |
| 71 | else( MSVC ) |
| 72 | message(STATUS "Configuring traditional style.") |
| 73 | include(config-ix) |
| 74 | endif( MSVC ) |
| 75 | |
| 76 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} ) |
| 77 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 78 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 79 | |
| 80 | # set(CMAKE_VERBOSE_MAKEFILE true) |
| 81 | |
| 82 | add_definitions( -D__STDC_LIMIT_MACROS ) |
Dan Gohman | 63f9720 | 2008-10-17 01:33:43 +0000 | [diff] [blame] | 83 | add_definitions( -D__STDC_CONSTANT_MACROS ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 84 | |
| 85 | if( LLVM_ON_UNIX ) |
| 86 | add_definitions( -DLLVM_ON_UNIX ) |
| 87 | else( LLVM_ON_UNIX ) |
| 88 | add_definitions( -DLLVM_ON_WIN32 ) |
| 89 | endif( LLVM_ON_UNIX ) |
| 90 | |
| 91 | if( MSVC ) |
| 92 | add_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS ) |
| 93 | add_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS ) |
| 94 | add_definitions( -D_SCL_SECURE_NO_DEPRECATE ) |
Oscar Fuentes | a789af2 | 2008-09-24 19:27:54 +0000 | [diff] [blame] | 95 | add_definitions( -wd4146 -wd4503 -wd4996 -wd4800 -wd4244 -wd4624 ) |
| 96 | add_definitions( -wd4355 -wd4715 ) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 97 | endif( MSVC ) |
| 98 | |
| 99 | include_directories( ${LLVM_BINARY_DIR}/include ${llvm_include_path}) |
| 100 | #link_directories( d:/dev/lib ) |
| 101 | |
| 102 | #add_subdirectory(lib) |
| 103 | |
| 104 | include(AddLLVM) |
| 105 | include(AddPartiallyLinkedObject) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 106 | include(TableGen) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 107 | |
| 108 | add_subdirectory(lib/Support) |
| 109 | add_subdirectory(lib/System) |
Oscar Fuentes | 1d8e4cf | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 110 | |
| 111 | # Everything else depends on Support and System: |
| 112 | set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} ${LLVM_LIBS} ) |
| 113 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 114 | add_subdirectory(utils/TableGen) |
| 115 | |
| 116 | add_custom_command(OUTPUT ${llvm_builded_incs_dir}/Intrinsics.gen |
| 117 | COMMAND tblgen -gen-intrinsic -I ${llvm_include_path} ${llvm_include_path}/llvm/Intrinsics.td -o ${llvm_builded_incs_dir}/Intrinsics.gen |
| 118 | DEPENDS tblgen |
| 119 | COMMENT "Building intrinsics.gen...") |
| 120 | |
| 121 | add_custom_target(intrinsics_gen ALL |
| 122 | DEPENDS ${llvm_builded_incs_dir}/Intrinsics.gen) |
| 123 | |
Oscar Fuentes | 1d8e4cf | 2008-09-22 18:21:51 +0000 | [diff] [blame] | 124 | set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} intrinsics_gen ) |
| 125 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 126 | add_subdirectory(lib/VMCore) |
| 127 | add_subdirectory(lib/CodeGen) |
| 128 | add_subdirectory(lib/CodeGen/SelectionDAG) |
| 129 | add_subdirectory(lib/CodeGen/AsmPrinter) |
| 130 | add_subdirectory(lib/Bitcode/Reader) |
| 131 | add_subdirectory(lib/Bitcode/Writer) |
| 132 | add_subdirectory(lib/Transforms/Utils) |
| 133 | add_subdirectory(lib/Transforms/Instrumentation) |
| 134 | add_subdirectory(lib/Transforms/Scalar) |
| 135 | add_subdirectory(lib/Transforms/IPO) |
| 136 | add_subdirectory(lib/Transforms/Hello) |
| 137 | add_subdirectory(lib/Linker) |
| 138 | add_subdirectory(lib/Analysis) |
| 139 | add_subdirectory(lib/Analysis/IPA) |
Oscar Fuentes | e1ad087 | 2008-09-26 04:40:32 +0000 | [diff] [blame] | 140 | |
| 141 | foreach(t ${LLVM_TARGETS_TO_BUILD}) |
| 142 | message(STATUS "Targeting ${t}") |
| 143 | add_subdirectory(lib/Target/${t}) |
| 144 | if( EXISTS ${CMAKE_SOURCE_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt ) |
| 145 | add_subdirectory(lib/Target/${t}/AsmPrinter) |
| 146 | endif( EXISTS ${CMAKE_SOURCE_DIR}/lib/Target/${t}/AsmPrinter/CMakeLists.txt ) |
| 147 | endforeach(t) |
| 148 | |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 149 | add_subdirectory(lib/ExecutionEngine) |
| 150 | add_subdirectory(lib/ExecutionEngine/Interpreter) |
| 151 | add_subdirectory(lib/ExecutionEngine/JIT) |
| 152 | add_subdirectory(lib/Target) |
| 153 | add_subdirectory(lib/AsmParser) |
| 154 | add_subdirectory(lib/Debugger) |
Oscar Fuentes | 3d01fc7 | 2008-09-22 01:08:49 +0000 | [diff] [blame] | 155 | add_subdirectory(lib/Archive) |
| 156 | |
| 157 | add_subdirectory(tools) |
| 158 | |
| 159 | add_subdirectory(examples) |
Oscar Fuentes | 1dc9716 | 2008-10-22 02:56:07 +0000 | [diff] [blame^] | 160 | |
| 161 | install(DIRECTORY include |
| 162 | DESTINATION . |
| 163 | PATTERN ".svn" EXCLUDE |
| 164 | PATTERN "*.cmake" EXCLUDE |
| 165 | PATTERN "*.in" EXCLUDE |
| 166 | ) |
| 167 | |
| 168 | install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include |
| 169 | DESTINATION . |
| 170 | ) |
| 171 | |
| 172 | # TODO: make and install documentation. |