diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 22e39ff20985..65c5b2ab9689 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -236,7 +236,15 @@ else () endif () macro(add_lldb_library name) - llvm_process_sources(srcs ${ARGN}) + # only supported parameters to this macro are the optional + # MODULE;SHARED;STATIC library type and source files + cmake_parse_arguments(PARAM + "MODULE;SHARED;STATIC" + "" + "" + ${ARGN}) + llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS}) + if (MSVC_IDE OR XCODE) string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR}) list(GET split_path -1 dir) @@ -244,13 +252,17 @@ macro(add_lldb_library name) ../../include/lldb${dir}/*.h) set(srcs ${srcs} ${headers}) endif() - if (MODULE) + if (PARAM_MODULE) set(libkind MODULE) - elseif (SHARED_LIBRARY) + elseif (PARAM_SHARED) set(libkind SHARED) - else() + elseif (PARAM_STATIC) set(libkind STATIC) + else () + # library type unspecified - controlled by BUILD_SHARED_LIBS + unset(libkind) endif() + #PIC not needed on Win if (NOT MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") diff --git a/lldb/cmake/LLDBDependencies.cmake b/lldb/cmake/LLDBDependencies.cmake index e80b3716621d..0308f12d2975 100644 --- a/lldb/cmake/LLDBDependencies.cmake +++ b/lldb/cmake/LLDBDependencies.cmake @@ -18,14 +18,12 @@ set( LLDB_USED_LIBS lldbPluginDynamicLoaderPosixDYLD lldbPluginDynamicLoaderHexagonDYLD - lldbPluginObjectFileMachO lldbPluginObjectFileELF lldbPluginObjectFileJIT lldbPluginSymbolVendorELF lldbPluginObjectContainerBSDArchive lldbPluginObjectContainerMachOArchive lldbPluginProcessGDBRemote - lldbPluginProcessMachCore lldbPluginProcessUtility lldbPluginPlatformGDB lldbPluginPlatformFreeBSD @@ -33,7 +31,6 @@ set( LLDB_USED_LIBS lldbPluginPlatformLinux lldbPluginPlatformPOSIX lldbPluginPlatformWindows - lldbPluginObjectFileMachO lldbPluginObjectContainerMachOArchive lldbPluginObjectContainerBSDArchive lldbPluginPlatformMacOSX @@ -106,6 +103,8 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" ) set_source_files_properties(${LLDB_VERS_GENERATED_FILE} PROPERTIES GENERATED 1) list(APPEND LLDB_USED_LIBS lldbPluginDynamicLoaderDarwinKernel + lldbPluginObjectFileMachO + lldbPluginProcessMachCore lldbPluginProcessMacOSXKernel lldbPluginSymbolVendorMacOSX lldbPluginSystemRuntimeMacOSX @@ -165,6 +164,7 @@ set( LLVM_LINK_COMPONENTS mcdisassembler executionengine option + support ) if ( NOT LLDB_DISABLE_PYTHON ) diff --git a/lldb/source/CMakeLists.txt b/lldb/source/CMakeLists.txt index 8c2ea91ef31b..b972edfa41ef 100644 --- a/lldb/source/CMakeLists.txt +++ b/lldb/source/CMakeLists.txt @@ -30,6 +30,7 @@ endif () if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows" ) add_subdirectory(API) endif () + add_subdirectory(Breakpoint) add_subdirectory(Commands) add_subdirectory(Core) @@ -44,8 +45,6 @@ add_subdirectory(Utility) include(../cmake/LLDBDependencies.cmake) -set(SHARED_LIBRARY 1) - if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) add_definitions( -DEXPORT_LIBLLDB ) endif() @@ -56,7 +55,7 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) # On Non-Windows, the corresponding file list is maintained in # source\API\CMakeLists.txt. When editing this list, do not forget to make a # corresponding change in that file as well (when appropriate). -add_lldb_library(liblldb +add_lldb_library(liblldb SHARED lldb.cpp lldb-log.cpp API/SBAddress.cpp diff --git a/lldb/tools/lldb-gdbserver/CMakeLists.txt b/lldb/tools/lldb-gdbserver/CMakeLists.txt index 1dc2e1c373fd..e38e69dffa1c 100644 --- a/lldb/tools/lldb-gdbserver/CMakeLists.txt +++ b/lldb/tools/lldb-gdbserver/CMakeLists.txt @@ -17,26 +17,33 @@ include_directories(../../source) include(../../cmake/LLDBDependencies.cmake) -# have to include lldb and lldb-log files since those are not libraries and llgs depends on them -add_lldb_executable(lldb-gdbserver - lldb-gdbserver.cpp - ../../source/lldb-log.cpp - ../../source/lldb.cpp - ) +if ( BUILD_SHARED_LIBS ) + add_lldb_executable(lldb-gdbserver + lldb-gdbserver.cpp + ) -# The Darwin linker doesn't understand --start-group/--end-group. -if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") - target_link_libraries(lldb-gdbserver - -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group) + target_link_libraries(lldb-gdbserver liblldb) else() - target_link_libraries(lldb-gdbserver ${LLDB_USED_LIBS}) -endif() -target_link_libraries(lldb-gdbserver ${CLANG_USED_LIBS}) -llvm_config(lldb-gdbserver ${LLVM_LINK_COMPONENTS}) + # have to include lldb and lldb-log files since those are not libraries and llgs depends on them + add_lldb_executable(lldb-gdbserver + lldb-gdbserver.cpp + ../../source/lldb-log.cpp + ../../source/lldb.cpp + ) -target_link_libraries(lldb-gdbserver ${LLDB_SYSTEM_LIBS}) + # The Darwin linker doesn't understand --start-group/--end-group. + if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") + target_link_libraries(lldb-gdbserver + -Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group) + else() + target_link_libraries(lldb-gdbserver ${LLDB_USED_LIBS}) + endif() + target_link_libraries(lldb-gdbserver ${CLANG_USED_LIBS}) + llvm_config(lldb-gdbserver ${LLVM_LINK_COMPONENTS}) + + target_link_libraries(lldb-gdbserver ${LLDB_SYSTEM_LIBS}) +endif() set_target_properties(lldb-gdbserver PROPERTIES VERSION ${LLDB_VERSION}) - install(TARGETS lldb-gdbserver RUNTIME DESTINATION bin) diff --git a/lldb/tools/lldb-mi/CMakeLists.txt b/lldb/tools/lldb-mi/CMakeLists.txt index cc4347f01f46..9bdca83384e0 100644 --- a/lldb/tools/lldb-mi/CMakeLists.txt +++ b/lldb/tools/lldb-mi/CMakeLists.txt @@ -164,7 +164,7 @@ add_lldb_executable(lldb-mi ) endif () -target_link_libraries(lldb-mi liblldb) +target_link_libraries(lldb-mi liblldb pthread) # TODO: why isn't this done by add_lldb_executable? #target_link_libraries(lldb-mi ${LLDB_USED_LIBS}) #llvm_config(lldb-mi ${LLVM_LINK_COMPONENTS})