forked from OSchip/llvm-project
96 lines
2.9 KiB
CMake
96 lines
2.9 KiB
CMake
function(lldb_link_common_libs name targetkind)
|
|
if (NOT LLDB_USED_LIBS)
|
|
return()
|
|
endif()
|
|
|
|
set(COMPILER_SUPPORTS_GROUPS OFF)
|
|
if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
|
|
# The Darwin linker doesn't understand --start-group/--end-group.
|
|
set(COMPILER_SUPPORTS_GROUPS ON)
|
|
endif()
|
|
|
|
if(${targetkind} MATCHES "SHARED")
|
|
set(LINK_KEYWORD ${cmake_2_8_12_PUBLIC})
|
|
endif()
|
|
|
|
if(${targetkind} MATCHES "SHARED" OR ${targetkind} MATCHES "EXE")
|
|
if (COMPILER_SUPPORTS_GROUPS)
|
|
target_link_libraries(${name} ${LINK_KEYWORD}
|
|
-Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group)
|
|
else()
|
|
target_link_libraries(${name} ${LINK_KEYWORD} ${LLDB_USED_LIBS})
|
|
endif()
|
|
endif()
|
|
endfunction(lldb_link_common_libs)
|
|
|
|
macro(add_lldb_library name)
|
|
# only supported parameters to this macro are the optional
|
|
# MODULE;SHARED;STATIC library type and source files
|
|
cmake_parse_arguments(PARAM
|
|
"MODULE;SHARED;STATIC;OBJECT"
|
|
""
|
|
""
|
|
${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)
|
|
file(GLOB_RECURSE headers
|
|
../../include/lldb${dir}/*.h)
|
|
set(srcs ${srcs} ${headers})
|
|
endif()
|
|
if (PARAM_MODULE)
|
|
set(libkind MODULE)
|
|
elseif (PARAM_SHARED)
|
|
set(libkind SHARED)
|
|
elseif (PARAM_STATIC)
|
|
set(libkind STATIC)
|
|
elseif (PARAM_OBJECT)
|
|
set(libkind OBJECT)
|
|
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")
|
|
endif()
|
|
|
|
if (PARAM_OBJECT)
|
|
add_library(${name} ${libkind} ${srcs})
|
|
else()
|
|
llvm_add_library(${name} ${libkind} ${srcs})
|
|
|
|
lldb_link_common_libs(${name} "${libkind}")
|
|
|
|
|
|
target_link_libraries(${name} ${cmake_2_8_12_PUBLIC} ${CLANG_USED_LIBS})
|
|
llvm_config(${name} ${LLVM_LINK_COMPONENTS})
|
|
|
|
if (PARAM_SHARED)
|
|
install(TARGETS ${name}
|
|
RUNTIME DESTINATION bin
|
|
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
|
|
else()
|
|
install(TARGETS ${name}
|
|
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
|
|
endif()
|
|
endif()
|
|
|
|
# Hack: only some LLDB libraries depend on the clang autogenerated headers,
|
|
# but it is simple enough to make all of LLDB depend on some of those
|
|
# headers without negatively impacting much of anything.
|
|
add_dependencies(${name} libclang)
|
|
|
|
set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
|
|
endmacro(add_lldb_library)
|
|
|
|
macro(add_lldb_executable name)
|
|
add_llvm_executable(${name} ${ARGN})
|
|
set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
|
|
endmacro(add_lldb_executable)
|