Daniel Malea | 137c4d7 | 2013-02-28 23:11:46 +0000 | [diff] [blame] | 1 | # If we are not building as a part of LLVM, build LLDB as an
|
| 2 | # standalone project, using LLVM as an external library:
|
| 3 | if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
| 4 | project(lldb)
|
| 5 | cmake_minimum_required(VERSION 2.8)
|
| 6 |
|
| 7 | set(LLDB_PATH_TO_LLVM_SOURCE "" CACHE PATH
|
| 8 | "Path to LLVM source code. Not necessary if using an installed LLVM.")
|
| 9 | set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH
|
| 10 | "Path to the directory where LLVM was built or installed.")
|
| 11 |
|
| 12 | set(LLDB_PATH_TO_CLANG_SOURCE "" CACHE PATH
|
| 13 | "Path to Clang source code. Not necessary if using an installed Clang.")
|
| 14 | set(LLDB_PATH_TO_CLANG_BUILD "" CACHE PATH
|
| 15 | "Path to the directory where Clang was built or installed.")
|
| 16 |
|
| 17 | set(LLDB_DISABLE_PYTHON 1 BOOL "Disables the Python scripting integration.")
|
| 18 |
|
| 19 | if (LLDB_PATH_TO_LLVM_SOURCE)
|
| 20 | if (NOT EXISTS "${LLDB_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake")
|
| 21 | message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_SOURCE to the root "
|
| 22 | "directory of LLVM source code.")
|
| 23 | else()
|
| 24 | get_filename_component(LLVM_MAIN_SRC_DIR ${LLDB_PATH_TO_LLVM_SOURCE}
|
| 25 | ABSOLUTE)
|
| 26 | list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
|
| 27 | endif()
|
| 28 | endif()
|
| 29 |
|
| 30 | if (LLDB_PATH_TO_CLANG_SOURCE)
|
| 31 | get_filename_component(CLANG_MAIN_SRC_DIR ${LLDB_PATH_TO_CLANG_SOURCE}
|
| 32 | ABSOLUTE)
|
| 33 | endif()
|
| 34 |
|
| 35 | list(APPEND CMAKE_MODULE_PATH "${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake")
|
| 36 |
|
| 37 | get_filename_component(PATH_TO_LLVM_BUILD ${LLDB_PATH_TO_LLVM_BUILD}
|
| 38 | ABSOLUTE)
|
| 39 |
|
| 40 | get_filename_component(PATH_TO_CLANG_BUILD ${LLDB_PATH_TO_CLANG_BUILD}
|
| 41 | ABSOLUTE)
|
| 42 |
|
| 43 | include(AddLLVM)
|
| 44 | include("${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake")
|
| 45 | include(HandleLLVMOptions)
|
| 46 |
|
| 47 | set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
|
| 48 |
|
| 49 | set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")
|
| 50 | set(LLVM_BINARY_DIR ${CMAKE_BINARY_DIR})
|
| 51 |
|
| 52 | set(CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR}/include")
|
| 53 |
|
| 54 | set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
| 55 | include_directories("${PATH_TO_LLVM_BUILD}/include"
|
| 56 | "${LLVM_MAIN_INCLUDE_DIR}"
|
| 57 | "${PATH_TO_CLANG_BUILD}/include"
|
| 58 | "${CLANG_MAIN_INCLUDE_DIR}"
|
| 59 | "${CMAKE_CURRENT_SOURCE_DIR}/source")
|
| 60 | link_directories("${PATH_TO_LLVM_BUILD}/lib"
|
| 61 | "${PATH_TO_CLANG_BUILD}/lib")
|
| 62 |
|
| 63 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
| 64 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
| 65 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
| 66 |
|
| 67 | set(LLDB_BUILT_STANDALONE 1)
|
| 68 |
|
| 69 | if (LLDB_DISABLE_PYTHON)
|
| 70 | add_definitions( -DLLDB_DISABLE_PYTHON )
|
| 71 | endif()
|
| 72 | endif()
|
| 73 |
|
| 74 | macro(add_lldb_definitions)
|
| 75 | # We don't want no semicolons on LLDB_DEFINITIONS:
|
| 76 | foreach(arg ${ARGN})
|
| 77 | set(LLDB_DEFINITIONS "${LLVM_DEFINITIONS} ${arg}")
|
| 78 | endforeach(arg)
|
| 79 | add_definitions( ${ARGN} )
|
| 80 | endmacro(add_lldb_definitions)
|
| 81 |
|
| 82 | include_directories(/usr/include/python2.7)
|
| 83 | include_directories(../clang/include)
|
| 84 | include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
|
Matt Kopec | 44ef1bf | 2013-03-21 20:52:53 +0000 | [diff] [blame] | 85 |
|
| 86 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
| 87 | if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.7")
|
| 88 | set(CMAKE_CXX_FLAGS "-std=c++0x")
|
| 89 | else()
|
| 90 | set(CMAKE_CXX_FLAGS "-std=c++11")
|
| 91 | endif()
|
| 92 | else()
|
| 93 | set(CMAKE_CXX_FLAGS "-std=c++11")
|
| 94 | endif()
|
Daniel Malea | 137c4d7 | 2013-02-28 23:11:46 +0000 | [diff] [blame] | 95 |
|
Daniel Malea | 1ce3d86 | 2013-04-17 19:27:31 +0000 | [diff] [blame^] | 96 | # Disable Clang warnings
|
| 97 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
| 98 | add_lldb_definitions(
|
| 99 | -Wno-deprecated-declarations # Suppress "deprecated auto_ptr" warnings
|
| 100 | )
|
| 101 | endif()
|
| 102 |
|
Daniel Malea | 137c4d7 | 2013-02-28 23:11:46 +0000 | [diff] [blame] | 103 | # Disable MSVC warnings
|
| 104 | if( MSVC )
|
| 105 | add_lldb_definitions(
|
| 106 | -wd4018 # Suppress 'warning C4018: '>=' : signed/unsigned mismatch'
|
| 107 | -wd4068 # Suppress 'warning C4068: unknown pragma'
|
| 108 | -wd4150 # Suppress 'warning C4150: deletion of pointer to incomplete type'
|
| 109 | -wd4521 # Suppress 'warning C4521: 'type' : multiple copy constructors specified'
|
| 110 | )
|
| 111 | endif()
|
| 112 |
|
Daniel Malea | d7982f8 | 2013-03-07 00:48:53 +0000 | [diff] [blame] | 113 | # If building on a 32-bit system, make sure off_t can store offsets > 2GB
|
| 114 | if( CMAKE_SIZEOF_VOID_P EQUAL 4 )
|
| 115 | add_lldb_definitions(
|
| 116 | -D_LARGEFILE_SOURCE
|
| 117 | -D_FILE_OFFSET_BITS=64
|
| 118 | )
|
| 119 | endif()
|
| 120 |
|
Daniel Malea | 137c4d7 | 2013-02-28 23:11:46 +0000 | [diff] [blame] | 121 | set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
| 122 | set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
| 123 |
|
| 124 | if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
| 125 | message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
|
| 126 | "the makefiles distributed with LLDB. Please create a directory and run cmake "
|
| 127 | "from there, passing the path to this source directory as the last argument. "
|
| 128 | "This process created the file `CMakeCache.txt' and the directory "
|
| 129 | "`CMakeFiles'. Please delete them.")
|
| 130 | endif()
|
| 131 |
|
| 132 | macro(add_lldb_library name)
|
| 133 | llvm_process_sources(srcs ${ARGN})
|
| 134 | if (MSVC_IDE OR XCODE)
|
| 135 | string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
|
| 136 | list(GET split_path -1 dir)
|
| 137 | file(GLOB_RECURSE headers
|
| 138 | ../../include/lldb${dir}/*.h)
|
| 139 | set(srcs ${srcs} ${headers})
|
| 140 | endif()
|
| 141 | if (MODULE)
|
| 142 | set(libkind MODULE)
|
| 143 | elseif (SHARED_LIBRARY)
|
| 144 | set(libkind SHARED)
|
| 145 | else()
|
| 146 | set(libkind STATIC)
|
| 147 | endif()
|
| 148 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
| 149 | add_library(${name} ${libkind} ${srcs})
|
| 150 | #if (LLVM_COMMON_DEPENDS)
|
| 151 | ##add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
|
| 152 | #endif()
|
| 153 |
|
| 154 | if(LLDB_USED_LIBS)
|
| 155 | target_link_libraries(${name} -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
|
| 156 | endif()
|
| 157 | target_link_libraries(${name} ${CLANG_USED_LIBS})
|
| 158 | target_link_libraries(${name} ${LLVM_USED_LIBS})
|
| 159 | llvm_config(${name} ${LLVM_LINK_COMPONENTS})
|
| 160 | target_link_libraries(${name} ${LLVM_COMMON_LIBS})
|
| 161 | link_system_libs(${name})
|
| 162 | if (LLVM_COMMON_DEPENDS)
|
| 163 | add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
|
| 164 | endif()
|
| 165 |
|
| 166 | # Hack: only some LLDB libraries depend on the clang autogenerated headers,
|
| 167 | # but it is simple enough to make all of LLDB depend on some of those
|
| 168 | # headers without negatively impacting much of anything.
|
| 169 | set (LLDB_DEPENDENCIES
|
Daniel Malea | 0856107 | 2013-03-05 21:59:12 +0000 | [diff] [blame] | 170 | libclang
|
Daniel Malea | 137c4d7 | 2013-02-28 23:11:46 +0000 | [diff] [blame] | 171 | )
|
| 172 | add_dependencies(${name} ${LLDB_DEPENDENCIES})
|
| 173 |
|
| 174 | install(TARGETS ${name}
|
| 175 | LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
| 176 | ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
|
| 177 | set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
|
| 178 | endmacro(add_lldb_library)
|
| 179 |
|
| 180 | macro(add_lldb_executable name)
|
| 181 | #add_llvm_executable(${name} ${ARGN})
|
| 182 | llvm_process_sources( ALL_FILES ${ARGN} )
|
| 183 | add_executable(${name} ${ALL_FILES})
|
| 184 | #target_link_libraries(${name} ${CLANG_USED_LIBS})
|
| 185 | #llvm_config( ${name} ${LLVM_LINK_COMPONENTS} )
|
| 186 | #link_system_libs( ${name} )
|
| 187 | #if (LLVM_COMMON_DEPENDS)
|
| 188 | #add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
|
| 189 | #endif()
|
| 190 | set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
|
| 191 | endmacro(add_lldb_executable)
|
| 192 |
|
| 193 | include_directories(BEFORE
|
| 194 | ${CMAKE_CURRENT_BINARY_DIR}/include
|
| 195 | ${CMAKE_CURRENT_SOURCE_DIR}/include
|
| 196 | )
|
| 197 |
|
| 198 | install(DIRECTORY include/
|
| 199 | DESTINATION include
|
| 200 | FILES_MATCHING
|
| 201 | PATTERN "*.h"
|
| 202 | PATTERN ".svn" EXCLUDE
|
| 203 | )
|
| 204 |
|
| 205 | #add_subdirectory(include)
|
| 206 | add_subdirectory(scripts)
|
| 207 | add_subdirectory(source)
|
| 208 | add_subdirectory(test)
|
| 209 | add_subdirectory(tools)
|