2015-03-19 00:56:24 +08:00
|
|
|
function(lldb_link_common_libs name targetkind)
|
|
|
|
if (NOT LLDB_USED_LIBS)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${targetkind} MATCHES "SHARED")
|
[cmake] Make dependencies of lldb libraries private, take 2
Summary:
The dependencies of our libraries (only liblldb, really) we marked as public, which caused all
their dependencies to be repeated when linking any executables to them. This is a problem because
then all the .a files could end up being linked twice, once to liblldb and once
again to to the executable linking against liblldb (lldb, lldb-mi). As it turns out,
our build actually depends on this behavior:
- on windows, lldb does not have getopt, so it pulls it from inside liblldb, even
though getopt is not a part of the exported interface of liblldb (maybe some of
the bsd variants have this problem as well)
- lldb-mi uses llvm, which again is not exported by liblldb
This change does not actually fix these problems (that is going to be a hard
one), but it does make them explicit by moving this magic from add_lldb_library
to the places the executable targets are defined. That way, I can link the
additional .a files only on targets that really need it, and the other targets
can build cleanly and make sure we don't regress further. It also fixes the
LLVM_LINK_LLVM_DYLIB build on linux.
Reviewers: zturner, beanz
Subscribers: ki.stfu, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D25680
llvm-svn: 284466
2016-10-18 18:26:57 +08:00
|
|
|
set(LINK_KEYWORD PRIVATE)
|
2015-03-19 00:56:24 +08:00
|
|
|
endif()
|
2015-07-17 23:26:27 +08:00
|
|
|
|
2015-03-19 00:56:24 +08:00
|
|
|
if(${targetkind} MATCHES "SHARED" OR ${targetkind} MATCHES "EXE")
|
2015-07-17 23:26:27 +08:00
|
|
|
if (LLDB_LINKER_SUPPORTS_GROUPS)
|
2015-03-19 00:56:24 +08:00
|
|
|
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)
|
|
|
|
|
2016-12-16 06:01:17 +08:00
|
|
|
function(add_lldb_library name)
|
2015-07-17 23:26:27 +08:00
|
|
|
# only supported parameters to this macro are the optional
|
2015-03-19 00:56:24 +08:00
|
|
|
# MODULE;SHARED;STATIC library type and source files
|
|
|
|
cmake_parse_arguments(PARAM
|
|
|
|
"MODULE;SHARED;STATIC;OBJECT"
|
|
|
|
""
|
2016-11-19 07:31:53 +08:00
|
|
|
"DEPENDS"
|
2015-03-19 00:56:24 +08:00
|
|
|
${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_OBJECT)
|
|
|
|
set(libkind OBJECT)
|
|
|
|
else ()
|
2015-06-04 11:12:37 +08:00
|
|
|
# PARAM_STATIC or library type unspecified. BUILD_SHARED_LIBS
|
|
|
|
# does not control the kind of libraries created for LLDB,
|
|
|
|
# only whether or not they link to shared/static LLVM/Clang
|
|
|
|
# libraries.
|
|
|
|
set(libkind STATIC)
|
2015-03-19 00:56:24 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
#PIC not needed on Win
|
2016-12-15 23:00:41 +08:00
|
|
|
if (NOT WIN32)
|
2015-03-19 00:56:24 +08:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (PARAM_OBJECT)
|
|
|
|
add_library(${name} ${libkind} ${srcs})
|
|
|
|
else()
|
2015-07-17 23:26:27 +08:00
|
|
|
if (PARAM_SHARED)
|
|
|
|
if (LLDB_LINKER_SUPPORTS_GROUPS)
|
[cmake] Make dependencies of lldb libraries private, take 2
Summary:
The dependencies of our libraries (only liblldb, really) we marked as public, which caused all
their dependencies to be repeated when linking any executables to them. This is a problem because
then all the .a files could end up being linked twice, once to liblldb and once
again to to the executable linking against liblldb (lldb, lldb-mi). As it turns out,
our build actually depends on this behavior:
- on windows, lldb does not have getopt, so it pulls it from inside liblldb, even
though getopt is not a part of the exported interface of liblldb (maybe some of
the bsd variants have this problem as well)
- lldb-mi uses llvm, which again is not exported by liblldb
This change does not actually fix these problems (that is going to be a hard
one), but it does make them explicit by moving this magic from add_lldb_library
to the places the executable targets are defined. That way, I can link the
additional .a files only on targets that really need it, and the other targets
can build cleanly and make sure we don't regress further. It also fixes the
LLVM_LINK_LLVM_DYLIB build on linux.
Reviewers: zturner, beanz
Subscribers: ki.stfu, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D25680
llvm-svn: 284466
2016-10-18 18:26:57 +08:00
|
|
|
llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
|
|
|
|
-Wl,--start-group ${LLDB_USED_LIBS} -Wl,--end-group
|
|
|
|
-Wl,--start-group ${CLANG_USED_LIBS} -Wl,--end-group
|
2016-11-19 07:31:53 +08:00
|
|
|
DEPENDS ${PARAM_DEPENDS}
|
[cmake] Make dependencies of lldb libraries private, take 2
Summary:
The dependencies of our libraries (only liblldb, really) we marked as public, which caused all
their dependencies to be repeated when linking any executables to them. This is a problem because
then all the .a files could end up being linked twice, once to liblldb and once
again to to the executable linking against liblldb (lldb, lldb-mi). As it turns out,
our build actually depends on this behavior:
- on windows, lldb does not have getopt, so it pulls it from inside liblldb, even
though getopt is not a part of the exported interface of liblldb (maybe some of
the bsd variants have this problem as well)
- lldb-mi uses llvm, which again is not exported by liblldb
This change does not actually fix these problems (that is going to be a hard
one), but it does make them explicit by moving this magic from add_lldb_library
to the places the executable targets are defined. That way, I can link the
additional .a files only on targets that really need it, and the other targets
can build cleanly and make sure we don't regress further. It also fixes the
LLVM_LINK_LLVM_DYLIB build on linux.
Reviewers: zturner, beanz
Subscribers: ki.stfu, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D25680
llvm-svn: 284466
2016-10-18 18:26:57 +08:00
|
|
|
)
|
2015-07-17 23:26:27 +08:00
|
|
|
else()
|
[cmake] Make dependencies of lldb libraries private, take 2
Summary:
The dependencies of our libraries (only liblldb, really) we marked as public, which caused all
their dependencies to be repeated when linking any executables to them. This is a problem because
then all the .a files could end up being linked twice, once to liblldb and once
again to to the executable linking against liblldb (lldb, lldb-mi). As it turns out,
our build actually depends on this behavior:
- on windows, lldb does not have getopt, so it pulls it from inside liblldb, even
though getopt is not a part of the exported interface of liblldb (maybe some of
the bsd variants have this problem as well)
- lldb-mi uses llvm, which again is not exported by liblldb
This change does not actually fix these problems (that is going to be a hard
one), but it does make them explicit by moving this magic from add_lldb_library
to the places the executable targets are defined. That way, I can link the
additional .a files only on targets that really need it, and the other targets
can build cleanly and make sure we don't regress further. It also fixes the
LLVM_LINK_LLVM_DYLIB build on linux.
Reviewers: zturner, beanz
Subscribers: ki.stfu, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D25680
llvm-svn: 284466
2016-10-18 18:26:57 +08:00
|
|
|
llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
|
|
|
|
${LLDB_USED_LIBS} ${CLANG_USED_LIBS}
|
2016-11-19 07:31:53 +08:00
|
|
|
DEPENDS ${PARAM_DEPENDS}
|
[cmake] Make dependencies of lldb libraries private, take 2
Summary:
The dependencies of our libraries (only liblldb, really) we marked as public, which caused all
their dependencies to be repeated when linking any executables to them. This is a problem because
then all the .a files could end up being linked twice, once to liblldb and once
again to to the executable linking against liblldb (lldb, lldb-mi). As it turns out,
our build actually depends on this behavior:
- on windows, lldb does not have getopt, so it pulls it from inside liblldb, even
though getopt is not a part of the exported interface of liblldb (maybe some of
the bsd variants have this problem as well)
- lldb-mi uses llvm, which again is not exported by liblldb
This change does not actually fix these problems (that is going to be a hard
one), but it does make them explicit by moving this magic from add_lldb_library
to the places the executable targets are defined. That way, I can link the
additional .a files only on targets that really need it, and the other targets
can build cleanly and make sure we don't regress further. It also fixes the
LLVM_LINK_LLVM_DYLIB build on linux.
Reviewers: zturner, beanz
Subscribers: ki.stfu, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D25680
llvm-svn: 284466
2016-10-18 18:26:57 +08:00
|
|
|
)
|
2015-07-17 23:26:27 +08:00
|
|
|
endif()
|
[cmake] Make dependencies of lldb libraries private, take 2
Summary:
The dependencies of our libraries (only liblldb, really) we marked as public, which caused all
their dependencies to be repeated when linking any executables to them. This is a problem because
then all the .a files could end up being linked twice, once to liblldb and once
again to to the executable linking against liblldb (lldb, lldb-mi). As it turns out,
our build actually depends on this behavior:
- on windows, lldb does not have getopt, so it pulls it from inside liblldb, even
though getopt is not a part of the exported interface of liblldb (maybe some of
the bsd variants have this problem as well)
- lldb-mi uses llvm, which again is not exported by liblldb
This change does not actually fix these problems (that is going to be a hard
one), but it does make them explicit by moving this magic from add_lldb_library
to the places the executable targets are defined. That way, I can link the
additional .a files only on targets that really need it, and the other targets
can build cleanly and make sure we don't regress further. It also fixes the
LLVM_LINK_LLVM_DYLIB build on linux.
Reviewers: zturner, beanz
Subscribers: ki.stfu, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D25680
llvm-svn: 284466
2016-10-18 18:26:57 +08:00
|
|
|
else()
|
2016-11-19 07:31:53 +08:00
|
|
|
llvm_add_library(${name} ${libkind} ${srcs} DEPENDS ${PARAM_DEPENDS})
|
2015-07-07 20:24:33 +08:00
|
|
|
endif()
|
2015-03-19 00:56:24 +08:00
|
|
|
|
2015-06-29 19:03:21 +08:00
|
|
|
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
|
|
|
|
if (PARAM_SHARED)
|
2016-09-22 05:02:16 +08:00
|
|
|
set(out_dir lib${LLVM_LIBDIR_SUFFIX})
|
|
|
|
if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
|
|
|
|
set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
|
|
|
|
endif()
|
2015-06-29 19:03:21 +08:00
|
|
|
install(TARGETS ${name}
|
2016-12-16 06:01:17 +08:00
|
|
|
COMPONENT ${name}
|
2015-06-29 19:03:21 +08:00
|
|
|
RUNTIME DESTINATION bin
|
2016-09-22 05:02:16 +08:00
|
|
|
LIBRARY DESTINATION ${out_dir}
|
|
|
|
ARCHIVE DESTINATION ${out_dir})
|
2015-06-29 19:03:21 +08:00
|
|
|
else()
|
|
|
|
install(TARGETS ${name}
|
2016-12-16 06:01:17 +08:00
|
|
|
COMPONENT ${name}
|
2015-06-29 19:03:21 +08:00
|
|
|
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
|
|
|
|
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
|
|
|
|
endif()
|
2016-12-16 06:01:17 +08:00
|
|
|
if (NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
add_custom_target(install-${name}
|
|
|
|
DEPENDS ${name}
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=${name}
|
|
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
|
|
|
endif()
|
2015-03-19 00:56:24 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2016-08-20 05:00:40 +08:00
|
|
|
# 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.
|
2016-09-23 05:08:27 +08:00
|
|
|
get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
|
|
|
|
if(CLANG_TABLEGEN_TARGETS)
|
|
|
|
add_dependencies(${name} ${CLANG_TABLEGEN_TARGETS})
|
|
|
|
endif()
|
2015-03-19 00:56:24 +08:00
|
|
|
|
|
|
|
set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
|
2016-12-16 06:01:17 +08:00
|
|
|
endfunction(add_lldb_library)
|
2015-03-19 00:56:24 +08:00
|
|
|
|
2016-12-16 06:01:17 +08:00
|
|
|
function(add_lldb_executable name)
|
|
|
|
cmake_parse_arguments(ARG "INCLUDE_IN_FRAMEWORK;GENERATE_INSTALL" "" "" ${ARGN})
|
[cmake] Make dependencies of lldb libraries private, take 2
Summary:
The dependencies of our libraries (only liblldb, really) we marked as public, which caused all
their dependencies to be repeated when linking any executables to them. This is a problem because
then all the .a files could end up being linked twice, once to liblldb and once
again to to the executable linking against liblldb (lldb, lldb-mi). As it turns out,
our build actually depends on this behavior:
- on windows, lldb does not have getopt, so it pulls it from inside liblldb, even
though getopt is not a part of the exported interface of liblldb (maybe some of
the bsd variants have this problem as well)
- lldb-mi uses llvm, which again is not exported by liblldb
This change does not actually fix these problems (that is going to be a hard
one), but it does make them explicit by moving this magic from add_lldb_library
to the places the executable targets are defined. That way, I can link the
additional .a files only on targets that really need it, and the other targets
can build cleanly and make sure we don't regress further. It also fixes the
LLVM_LINK_LLVM_DYLIB build on linux.
Reviewers: zturner, beanz
Subscribers: ki.stfu, lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D25680
llvm-svn: 284466
2016-10-18 18:26:57 +08:00
|
|
|
add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
|
2016-09-22 05:02:16 +08:00
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
FOLDER "lldb executables")
|
|
|
|
|
2016-12-16 06:01:17 +08:00
|
|
|
set(install_dir bin)
|
2016-09-22 05:02:16 +08:00
|
|
|
if(LLDB_BUILD_FRAMEWORK)
|
|
|
|
if(ARG_INCLUDE_IN_FRAMEWORK)
|
|
|
|
string(REGEX REPLACE "[^/]+" ".." _dots ${LLDB_FRAMEWORK_INSTALL_DIR})
|
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:liblldb>/Resources
|
|
|
|
BUILD_WITH_INSTALL_RPATH On
|
|
|
|
INSTALL_RPATH "@loader_path/../../../../${_dots}/${LLDB_FRAMEWORK_INSTALL_DIR}")
|
|
|
|
else()
|
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
BUILD_WITH_INSTALL_RPATH On
|
|
|
|
INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
|
2016-12-16 06:01:17 +08:00
|
|
|
if(ARG_GENERATE_INSTALL)
|
|
|
|
install(TARGETS ${name}
|
|
|
|
COMPONENT ${name}
|
|
|
|
RUNTIME DESTINATION ${install_dir})
|
|
|
|
if (NOT CMAKE_CONFIGURATION_TYPES)
|
|
|
|
add_custom_target(install-${name}
|
|
|
|
DEPENDS ${name}
|
|
|
|
COMMAND "${CMAKE_COMMAND}"
|
|
|
|
-DCMAKE_INSTALL_COMPONENT=${name}
|
|
|
|
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
|
|
|
|
endif()
|
|
|
|
endif()
|
2016-09-22 05:02:16 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
2016-12-16 06:01:17 +08:00
|
|
|
|
|
|
|
if(ARG_INCLUDE_IN_FRAMEWORK AND LLDB_BUILD_FRAMEWORK)
|
|
|
|
add_llvm_tool_symlink(${name} ${name} ALWAYS_GENERATE SKIP_INSTALL
|
|
|
|
OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
|
|
|
|
endif()
|
|
|
|
endfunction(add_lldb_executable)
|
|
|
|
|
|
|
|
function(add_lldb_tool name)
|
|
|
|
add_lldb_executable(${name} GENERATE_INSTALL ${ARGN})
|
|
|
|
endfunction()
|
2015-10-14 22:52:15 +08:00
|
|
|
|
|
|
|
# Support appending linker flags to an existing target.
|
|
|
|
# This will preserve the existing linker flags on the
|
|
|
|
# target, if there are any.
|
|
|
|
function(lldb_append_link_flags target_name new_link_flags)
|
|
|
|
# Retrieve existing linker flags.
|
|
|
|
get_target_property(current_link_flags ${target_name} LINK_FLAGS)
|
|
|
|
|
|
|
|
# If we had any linker flags, include them first in the new linker flags.
|
|
|
|
if(current_link_flags)
|
|
|
|
set(new_link_flags "${current_link_flags} ${new_link_flags}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Now set them onto the target.
|
|
|
|
set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags})
|
|
|
|
endfunction()
|