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}) | |
if (PARAM_STATIC) | |
set(lldb_library_keyword ${cmake_2_8_12_INTERFACE}) | |
else () | |
set(lldb_library_keyword ${cmake_2_8_12_PUBLIC}) | |
endif () | |
if(LLDB_USED_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(${name} ${lldb_library_keyword} | |
-Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group) | |
else() | |
target_link_libraries(${name} ${lldb_library_keyword} ${LLDB_USED_LIBS}) | |
endif() | |
endif() | |
target_link_libraries(${name} ${lldb_library_keyword} ${CLANG_USED_LIBS}) | |
target_link_libraries(${name} ${lldb_library_keyword} ${LLVM_USED_LIBS}) | |
llvm_config(${name} ${LLVM_LINK_COMPONENTS}) | |
target_link_libraries(${name} ${lldb_library_keyword} ${LLVM_COMMON_LIBS}) | |
install(TARGETS ${name} | |
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX} | |
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX}) | |
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) |