|
| 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 | + |
| 16 | +# TODO: Support user-specified targets: |
| 17 | +set(LLVM_TARGETS_TO_BUILD X86) |
| 18 | + |
| 19 | +if( NOT MSVC ) |
| 20 | + set(CMAKE_CXX_LINK_EXECUTABLE "sh -c \"${CMAKE_CXX_LINK_EXECUTABLE}\"") |
| 21 | +endif( NOT MSVC ) |
| 22 | + |
| 23 | +# TODO: Eliminate? |
| 24 | +get_filename_component(llvm_include_path ${LLVM_MAIN_SRC_DIR}/include ABSOLUTE) |
| 25 | + |
| 26 | +#get_filename_component(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm ABSOLUTE) |
| 27 | +set(llvm_builded_incs_dir ${LLVM_BINARY_DIR}/include/llvm) |
| 28 | + |
| 29 | +# Add path for custom modules |
| 30 | +set(CMAKE_MODULE_PATH |
| 31 | + ${CMAKE_MODULE_PATH} |
| 32 | + "${LLVM_MAIN_SRC_DIR}/cmake" |
| 33 | + "${LLVM_MAIN_SRC_DIR}/cmake/modules" |
| 34 | + ) |
| 35 | + |
| 36 | +if(WIN32) |
| 37 | + set(LLVM_ON_WIN32 1) |
| 38 | + set(LLVM_ON_UNIX 0) |
| 39 | + set(LTDL_SHLIB_EXT ".dll") |
| 40 | + set(EXEEXT ".exe") |
| 41 | + # Maximum path length is 160 for non-unicode paths |
| 42 | + set(MAXPATHLEN 160) |
| 43 | +else(WIN32) |
| 44 | + if(UNIX) |
| 45 | + set(LLVM_ON_WIN32 0) |
| 46 | + set(LLVM_ON_UNIX 1) |
| 47 | + set(LTDL_SHLIB_EXT ".so") |
| 48 | + set(EXEEXT "") |
| 49 | + # FIXME: Maximum path length is currently set to 'safe' fixed value |
| 50 | + set(MAXPATHLEN 2024) |
| 51 | + else(UNIX) |
| 52 | + MESSAGE(SEND_ERROR "Unable to determine platform") |
| 53 | + endif(UNIX) |
| 54 | +endif(WIN32) |
| 55 | + |
| 56 | +if( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config ) |
| 57 | + set(HAVE_LLVM_CONFIG 1) |
| 58 | +endif( EXISTS ${LLVM_TOOLS_BINARY_DIR}/llvm-config ) |
| 59 | +# find_file(HAVE_LLVM_CONFIG llvm-config ${LLVM_TOOLS_BINARY_DIR}) |
| 60 | +# message(STATUS ${HAVE_LLVM_CONFIG}) |
| 61 | + |
| 62 | +if( MSVC ) |
| 63 | + message(STATUS "Configuring using MSVC hack.") |
| 64 | + include(config-w32) |
| 65 | +else( MSVC ) |
| 66 | + message(STATUS "Configuring traditional style.") |
| 67 | + include(config-ix) |
| 68 | +endif( MSVC ) |
| 69 | + |
| 70 | +set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} ) |
| 71 | +set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 72 | +set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib ) |
| 73 | + |
| 74 | +# set(CMAKE_VERBOSE_MAKEFILE true) |
| 75 | + |
| 76 | +add_definitions( -D__STDC_LIMIT_MACROS ) |
| 77 | + |
| 78 | +if( LLVM_ON_UNIX ) |
| 79 | + add_definitions( -DLLVM_ON_UNIX ) |
| 80 | +else( LLVM_ON_UNIX ) |
| 81 | + add_definitions( -DLLVM_ON_WIN32 ) |
| 82 | +endif( LLVM_ON_UNIX ) |
| 83 | + |
| 84 | +if( MSVC ) |
| 85 | + add_definitions( -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS ) |
| 86 | + add_definitions( -D_SCL_SECURE_NO_WARNINGS -DCRT_NONSTDC_NO_WARNINGS ) |
| 87 | + add_definitions( -D_SCL_SECURE_NO_DEPRECATE ) |
| 88 | +endif( MSVC ) |
| 89 | + |
| 90 | +include_directories( ${LLVM_BINARY_DIR}/include ${llvm_include_path}) |
| 91 | +#link_directories( d:/dev/lib ) |
| 92 | + |
| 93 | +#add_subdirectory(lib) |
| 94 | + |
| 95 | +include(AddLLVM) |
| 96 | +include(AddPartiallyLinkedObject) |
| 97 | + |
| 98 | +add_subdirectory(lib/Support) |
| 99 | +add_subdirectory(lib/System) |
| 100 | +add_subdirectory(utils/TableGen) |
| 101 | + |
| 102 | +add_custom_command(OUTPUT ${llvm_builded_incs_dir}/Intrinsics.gen |
| 103 | + COMMAND tblgen -gen-intrinsic -I ${llvm_include_path} ${llvm_include_path}/llvm/Intrinsics.td -o ${llvm_builded_incs_dir}/Intrinsics.gen |
| 104 | + DEPENDS tblgen |
| 105 | + COMMENT "Building intrinsics.gen...") |
| 106 | + |
| 107 | +add_custom_target(intrinsics_gen ALL |
| 108 | + DEPENDS ${llvm_builded_incs_dir}/Intrinsics.gen) |
| 109 | + |
| 110 | +add_subdirectory(lib/VMCore) |
| 111 | +add_subdirectory(lib/CodeGen) |
| 112 | +add_subdirectory(lib/CodeGen/SelectionDAG) |
| 113 | +add_subdirectory(lib/CodeGen/AsmPrinter) |
| 114 | +add_subdirectory(lib/Bitcode/Reader) |
| 115 | +add_subdirectory(lib/Bitcode/Writer) |
| 116 | +add_subdirectory(lib/Transforms/Utils) |
| 117 | +add_subdirectory(lib/Transforms/Instrumentation) |
| 118 | +add_subdirectory(lib/Transforms/Scalar) |
| 119 | +add_subdirectory(lib/Transforms/IPO) |
| 120 | +add_subdirectory(lib/Transforms/Hello) |
| 121 | +add_subdirectory(lib/Linker) |
| 122 | +add_subdirectory(lib/Analysis) |
| 123 | +add_subdirectory(lib/Analysis/IPA) |
| 124 | +add_subdirectory(lib/Target/X86) |
| 125 | +add_subdirectory(lib/Target/X86/AsmPrinter) |
| 126 | +add_subdirectory(lib/ExecutionEngine) |
| 127 | +add_subdirectory(lib/ExecutionEngine/Interpreter) |
| 128 | +add_subdirectory(lib/ExecutionEngine/JIT) |
| 129 | +add_subdirectory(lib/Target) |
| 130 | +add_subdirectory(lib/AsmParser) |
| 131 | +add_subdirectory(lib/Debugger) |
| 132 | +# TODO: lib/Target/CBackEnd |
| 133 | +add_subdirectory(lib/Archive) |
| 134 | + |
| 135 | +add_subdirectory(tools) |
| 136 | + |
| 137 | +add_subdirectory(examples) |
0 commit comments