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
|
2017-02-01 06:12:59 +08:00
|
|
|
"MODULE;SHARED;STATIC;OBJECT;PLUGIN"
|
2015-03-19 00:56:24 +08:00
|
|
|
""
|
2017-12-08 02:57:09 +08:00
|
|
|
"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS"
|
2015-03-19 00:56:24 +08:00
|
|
|
${ARGN})
|
|
|
|
llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
|
2017-02-01 00:59:46 +08:00
|
|
|
list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
|
2015-03-19 00:56:24 +08:00
|
|
|
|
2017-02-01 06:12:59 +08:00
|
|
|
if(PARAM_PLUGIN)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name})
|
|
|
|
endif()
|
|
|
|
|
2015-03-19 00:56:24 +08:00
|
|
|
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
|
2017-12-08 02:57:09 +08:00
|
|
|
# FIXME: Setting CMAKE_CXX_FLAGS here is a no-op, use target_compile_options
|
|
|
|
# or omit this logic instead.
|
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()
|
2017-02-01 00:59:46 +08:00
|
|
|
llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
|
|
|
|
${PARAM_LINK_LIBS}
|
|
|
|
DEPENDS ${PARAM_DEPENDS})
|
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)
|
2018-07-28 07:38:58 +08:00
|
|
|
set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
|
2018-08-02 01:21:18 +08:00
|
|
|
# The framework that is generated will install with install-liblldb
|
|
|
|
# because we enable CMake's framework support. CMake will copy all the
|
|
|
|
# headers and resources for us.
|
|
|
|
add_dependencies(install-lldb-framework install-${name})
|
|
|
|
add_dependencies(install-lldb-framework-stripped install-${name}-stripped)
|
2016-09-22 05:02:16 +08:00
|
|
|
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)
|
2017-12-12 08:47:07 +08:00
|
|
|
add_llvm_install_targets(install-${name}
|
2018-08-02 01:21:18 +08:00
|
|
|
DEPENDS $<TARGET_FILE:${name}>
|
2017-12-13 09:14:27 +08:00
|
|
|
COMPONENT ${name})
|
2018-08-02 01:21:18 +08:00
|
|
|
|
|
|
|
# install-liblldb{,-stripped} is the actual target that will install the
|
|
|
|
# framework, so it must rely on the framework being fully built first.
|
|
|
|
if (LLDB_BUILD_FRAMEWORK AND ${name} STREQUAL "liblldb")
|
|
|
|
add_dependencies(install-${name} lldb-framework)
|
2018-10-31 18:41:12 +08:00
|
|
|
add_dependencies(install-${name}-stripped lldb-framework)
|
2018-08-02 01:21:18 +08:00
|
|
|
endif()
|
2016-12-16 06:01:17 +08:00
|
|
|
endif()
|
2015-03-19 00:56:24 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-08-02 01:21:18 +08:00
|
|
|
|
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.
|
2017-07-28 23:39:49 +08:00
|
|
|
add_dependencies(${name} clang-tablegen-targets)
|
2015-03-19 00:56:24 +08:00
|
|
|
|
2017-12-08 02:57:09 +08:00
|
|
|
# Add in any extra C++ compilation flags for this library.
|
|
|
|
target_compile_options(${name} PRIVATE ${PARAM_EXTRA_CXXFLAGS})
|
|
|
|
|
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)
|
2017-02-01 00:59:46 +08:00
|
|
|
cmake_parse_arguments(ARG
|
2018-06-19 02:27:16 +08:00
|
|
|
"INCLUDE_IN_SUITE;GENERATE_INSTALL"
|
[CMake] Streamline code signing for debugserver #2
Summary:
Major fixes after D54476 (use Diff1 as base for comparison to see only recent changes):
* In standalone builds target directory for debugserver must be LLDB's bin, not LLVM's bin
* Default identity for code signing must not force-override LLVM_CODESIGNING_IDENTITY globally
We have a lot of cases, make them explicit:
* ID used for code signing (debugserver and in tests):
** `LLDB_CODESIGN_IDENTITY` if set explicitly, or otherwise
** `LLVM_CODESIGNING_IDENTITY` if set explicitly, or otherwise
** `lldb_codesign` as the default
* On Darwin we have a debugserver target that:
* On other systems, the debugserver target is not defined, which is equivalent to **[3A]**
Common configurations on Darwin:
* **[1A]** `cmake -GNinja ../llvm` builds debugserver from source and signs with `lldb_codesign`, no code signing for other binaries (prints status: //lldb debugserver: /path/to/bin/debugserver//)
* **[1A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- -DLLDB_CODESIGN_IDENTITY=lldb_codesign ../llvm` builds debugserver from source and signs with `lldb_codesign`, ad-hoc code signing for other binaries (prints status: //lldb debugserver: /path/to/bin/debugserver//)
* **[2A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- -DLLDB_USE_SYSTEM_DEBUGSERVER=ON ../llvm` copies debugserver from system, ad-hoc code signing for other binaries (prints status: //Copy system debugserver from: /path/to/system/debugserver//)
* **[2B]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- ../llvm` same, but prints additional warning: //Cannot code sign debugserver with identity '-'. Will fall back to system's debugserver. Pass -DLLDB_CODESIGN_IDENTITY=lldb_codesign to override the LLVM value for debugserver.//
* **[3A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- -DLLDB_NO_DEBUGSERVER=ON ../llvm` debugserver not available (prints status: //lldb debugserver will not be available)//
Reviewers: JDevlieghere, beanz, davide, vsk, aprantl, labath
Reviewed By: JDevlieghere, labath
Subscribers: mgorny, #lldb, lldb-commits
Differential Revision: https://reviews.llvm.org/D55013
llvm-svn: 350388
2019-01-04 20:46:30 +08:00
|
|
|
"ENTITLEMENTS"
|
2017-02-01 00:59:46 +08:00
|
|
|
"LINK_LIBS;LINK_COMPONENTS"
|
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
|
|
|
list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
|
[CMake] Streamline code signing for debugserver #2
Summary:
Major fixes after D54476 (use Diff1 as base for comparison to see only recent changes):
* In standalone builds target directory for debugserver must be LLDB's bin, not LLVM's bin
* Default identity for code signing must not force-override LLVM_CODESIGNING_IDENTITY globally
We have a lot of cases, make them explicit:
* ID used for code signing (debugserver and in tests):
** `LLDB_CODESIGN_IDENTITY` if set explicitly, or otherwise
** `LLVM_CODESIGNING_IDENTITY` if set explicitly, or otherwise
** `lldb_codesign` as the default
* On Darwin we have a debugserver target that:
* On other systems, the debugserver target is not defined, which is equivalent to **[3A]**
Common configurations on Darwin:
* **[1A]** `cmake -GNinja ../llvm` builds debugserver from source and signs with `lldb_codesign`, no code signing for other binaries (prints status: //lldb debugserver: /path/to/bin/debugserver//)
* **[1A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- -DLLDB_CODESIGN_IDENTITY=lldb_codesign ../llvm` builds debugserver from source and signs with `lldb_codesign`, ad-hoc code signing for other binaries (prints status: //lldb debugserver: /path/to/bin/debugserver//)
* **[2A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- -DLLDB_USE_SYSTEM_DEBUGSERVER=ON ../llvm` copies debugserver from system, ad-hoc code signing for other binaries (prints status: //Copy system debugserver from: /path/to/system/debugserver//)
* **[2B]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- ../llvm` same, but prints additional warning: //Cannot code sign debugserver with identity '-'. Will fall back to system's debugserver. Pass -DLLDB_CODESIGN_IDENTITY=lldb_codesign to override the LLVM value for debugserver.//
* **[3A]** `cmake -GNinja -DLLVM_CODESIGNING_IDENTITY=- -DLLDB_NO_DEBUGSERVER=ON ../llvm` debugserver not available (prints status: //lldb debugserver will not be available)//
Reviewers: JDevlieghere, beanz, davide, vsk, aprantl, labath
Reviewed By: JDevlieghere, labath
Subscribers: mgorny, #lldb, lldb-commits
Differential Revision: https://reviews.llvm.org/D55013
llvm-svn: 350388
2019-01-04 20:46:30 +08:00
|
|
|
add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} ENTITLEMENTS ${ARG_ENTITLEMENTS})
|
2017-02-01 00:59:46 +08:00
|
|
|
|
[CMake] Use PRIVATE in target_link_libraries for executables
We currently use target_link_libraries without an explicit scope
specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables.
Dependencies added in this way apply to both the target and its
dependencies, i.e. they become part of the executable's link interface
and are transitive.
Transitive dependencies generally don't make sense for executables,
since you wouldn't normally be linking against an executable. This also
causes issues for generating install export files when using
LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM
library dependencies, which are currently added as interface
dependencies. If clang is in the distribution components but the LLVM
libraries it depends on aren't (which is a perfectly legitimate use case
if the LLVM libraries are being built static and there are therefore no
run-time dependencies on them), CMake will complain about the LLVM
libraries not being in export set when attempting to generate the
install export file for clang. This is reasonable behavior on CMake's
part, and the right thing is for LLVM's build system to explicitly use
PRIVATE dependencies for executables.
Unfortunately, CMake doesn't allow you to mix and match the keyword and
non-keyword target_link_libraries signatures for a single target; i.e.,
if a single call to target_link_libraries for a particular target uses
one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must
also be updated to use those keywords. This means we must do this change
in a single shot. I also fully expect to have missed some instances; I
tested by enabling all the projects in the monorepo (except dragonegg),
and configuring both with and without shared libraries, on both Darwin
and Linux, but I'm planning to rely on the buildbots for other
configurations (since it should be pretty easy to fix those).
Even after this change, we still have a lot of target_link_libraries
calls that don't specify a scope keyword, mostly for shared libraries.
I'm thinking about addressing those in a follow-up, but that's a
separate change IMO.
Differential Revision: https://reviews.llvm.org/D40823
llvm-svn: 319840
2017-12-06 05:49:56 +08:00
|
|
|
target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
|
2016-09-22 05:02:16 +08:00
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
FOLDER "lldb executables")
|
|
|
|
|
2018-06-19 02:27:16 +08:00
|
|
|
if(ARG_INCLUDE_IN_SUITE)
|
|
|
|
add_dependencies(lldb-suite ${name})
|
|
|
|
if(LLDB_BUILD_FRAMEWORK)
|
2017-07-26 04:31:15 +08:00
|
|
|
if(NOT IOS)
|
|
|
|
set(resource_dir "/Resources")
|
|
|
|
set(resource_dots "../")
|
|
|
|
endif()
|
2016-09-22 05:02:16 +08:00
|
|
|
string(REGEX REPLACE "[^/]+" ".." _dots ${LLDB_FRAMEWORK_INSTALL_DIR})
|
|
|
|
set_target_properties(${name} PROPERTIES
|
2018-07-28 07:38:58 +08:00
|
|
|
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:liblldb>${resource_dir}
|
2016-09-22 05:02:16 +08:00
|
|
|
BUILD_WITH_INSTALL_RPATH On
|
2017-07-26 04:31:15 +08:00
|
|
|
INSTALL_RPATH "@loader_path/../../../${resource_dots}${_dots}/${LLDB_FRAMEWORK_INSTALL_DIR}")
|
2016-12-21 00:28:18 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-06-19 02:27:16 +08:00
|
|
|
if(LLDB_BUILD_FRAMEWORK AND NOT ARG_INCLUDE_IN_SUITE)
|
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
BUILD_WITH_INSTALL_RPATH On
|
|
|
|
INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
|
|
|
|
endif()
|
|
|
|
|
2018-07-17 03:19:56 +08:00
|
|
|
if(ARG_GENERATE_INSTALL)
|
|
|
|
set(out_dir "bin")
|
|
|
|
if (LLDB_BUILD_FRAMEWORK AND ARG_INCLUDE_IN_SUITE)
|
2018-07-28 07:38:58 +08:00
|
|
|
set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR}/${LLDB_FRAMEWORK_RESOURCE_DIR})
|
2018-08-02 01:21:18 +08:00
|
|
|
# While install-liblldb-stripped will handle copying the tools, it will
|
|
|
|
# not strip them. We depend on this target to guarantee a stripped version
|
|
|
|
# will get installed in the framework.
|
|
|
|
add_dependencies(install-lldb-framework-stripped install-${name}-stripped)
|
2018-07-17 03:19:56 +08:00
|
|
|
endif()
|
2016-12-21 00:28:18 +08:00
|
|
|
install(TARGETS ${name}
|
|
|
|
COMPONENT ${name}
|
2018-07-17 03:19:56 +08:00
|
|
|
RUNTIME DESTINATION ${out_dir})
|
2016-12-21 00:28:18 +08:00
|
|
|
if (NOT CMAKE_CONFIGURATION_TYPES)
|
2017-12-12 08:47:07 +08:00
|
|
|
add_llvm_install_targets(install-${name}
|
2017-12-13 09:14:27 +08:00
|
|
|
DEPENDS ${name}
|
|
|
|
COMPONENT ${name})
|
2016-09-22 05:02:16 +08:00
|
|
|
endif()
|
|
|
|
endif()
|
2016-12-16 06:01:17 +08:00
|
|
|
|
2018-06-19 02:27:16 +08:00
|
|
|
if(ARG_INCLUDE_IN_SUITE AND LLDB_BUILD_FRAMEWORK)
|
2016-12-16 06:01:17 +08:00
|
|
|
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()
|