2011-12-01 21:18:09 +01:00
|
|
|
set(LLVM_LINK_COMPONENTS support)
|
2008-09-22 03:08:49 +02:00
|
|
|
|
2011-12-01 21:18:09 +01:00
|
|
|
set(BUILDVARIABLES_SRCPATH ${CMAKE_CURRENT_SOURCE_DIR}/BuildVariables.inc.in)
|
|
|
|
set(BUILDVARIABLES_OBJPATH ${CMAKE_CURRENT_BINARY_DIR}/BuildVariables.inc)
|
2008-10-26 02:47:52 +02:00
|
|
|
|
2015-08-14 18:20:31 +02:00
|
|
|
# Add the llvm-config tool.
|
|
|
|
add_llvm_tool(llvm-config
|
|
|
|
llvm-config.cpp
|
|
|
|
)
|
|
|
|
|
2011-12-01 21:18:09 +01:00
|
|
|
# Compute the substitution values for various items.
|
2014-02-23 07:27:04 +01:00
|
|
|
get_property(LLVM_SYSTEM_LIBS_LIST TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
|
2009-05-27 17:49:33 +02:00
|
|
|
foreach(l ${LLVM_SYSTEM_LIBS_LIST})
|
2016-02-09 20:41:14 +01:00
|
|
|
if(MSVC)
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}.lib")
|
|
|
|
else()
|
2016-06-21 21:34:40 +02:00
|
|
|
if (l MATCHES "^-")
|
|
|
|
# If it's an option, pass it without changes.
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}")
|
|
|
|
else()
|
|
|
|
# Otherwise assume it's a library name we need to link with.
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
|
|
|
|
endif()
|
2016-02-09 20:41:14 +01:00
|
|
|
endif()
|
2009-05-27 17:49:33 +02:00
|
|
|
endforeach()
|
2013-08-28 19:04:06 +02:00
|
|
|
string(REPLACE ";" " " SYSTEM_LIBS "${SYSTEM_LIBS}")
|
2009-04-05 00:41:07 +02:00
|
|
|
|
2015-08-14 18:20:31 +02:00
|
|
|
# Fetch target specific compile options, e.g. RTTI option
|
|
|
|
get_property(COMPILE_FLAGS TARGET llvm-config PROPERTY COMPILE_FLAGS)
|
|
|
|
|
2013-08-23 19:59:13 +02:00
|
|
|
# Use configure_file to create BuildVariables.inc.
|
|
|
|
set(LLVM_SRC_ROOT ${LLVM_MAIN_SRC_DIR})
|
|
|
|
set(LLVM_OBJ_ROOT ${LLVM_BINARY_DIR})
|
2017-03-22 13:06:11 +01:00
|
|
|
set(LLVM_CPPFLAGS "${CMAKE_CPP_FLAGS} ${CMAKE_CPP_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
|
|
|
|
set(LLVM_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
|
|
|
|
set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}")
|
2015-09-09 18:39:30 +02:00
|
|
|
set(LLVM_BUILD_SYSTEM cmake)
|
2015-11-04 21:57:43 +01:00
|
|
|
set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI})
|
tools/llvm-config: improve shared library support
Summary:
This is a re-commit of r257003, which was reverted,
along with the fixes from http://reviews.llvm.org/D15986.
r252532 added support for reporting the monolithic library
when LLVM_BUILD_LLVM_DYLIB is used. This would only be done
if the individual components were not found, and the dynamic
library is found.
This diff extends this as follows:
- If LLVM_LINK_LLVM_DYLIB is set, then prefer the shared
library, even if all component libraries exist.
- Two flags, --link-shared and --link-static are introduced
to provide explicit guidance. If --link-shared is passed
and the shared library does not exist, an error results.
Additionally, changed the expected shared library names from
(e.g.) LLVM-3.8.0 to LLVM-3.8. The former exists only in an
installation (and then only in CMake builds I think?), and not
in the build tree; this breaks usage of llvm-config during
builds, e.g. by llvm-go.
Reviewers: DiamondLovesYou, beanz
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15986
llvm-svn: 258283
2016-01-20 05:03:09 +01:00
|
|
|
set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}${LLVM_VERSION_SUFFIX}")
|
2017-08-03 23:52:25 +02:00
|
|
|
set(LLVM_HAS_GLOBAL_ISEL "ON")
|
2015-09-09 18:39:30 +02:00
|
|
|
|
2014-04-25 03:44:20 +02:00
|
|
|
# Use the C++ link flags, since they should be a superset of C link flags.
|
|
|
|
set(LLVM_LDFLAGS "${CMAKE_CXX_LINK_FLAGS}")
|
2013-08-23 19:59:13 +02:00
|
|
|
set(LLVM_BUILDMODE ${CMAKE_BUILD_TYPE})
|
|
|
|
set(LLVM_SYSTEM_LIBS ${SYSTEM_LIBS})
|
2013-08-28 19:04:06 +02:00
|
|
|
string(REPLACE ";" " " LLVM_TARGETS_BUILT "${LLVM_TARGETS_TO_BUILD}")
|
2017-01-10 20:55:51 +01:00
|
|
|
llvm_canonicalize_cmake_booleans(
|
|
|
|
LLVM_BUILD_LLVM_DYLIB
|
|
|
|
LLVM_LINK_LLVM_DYLIB
|
|
|
|
LLVM_HAS_RTTI
|
|
|
|
LLVM_HAS_GLOBAL_ISEL
|
|
|
|
BUILD_SHARED_LIBS)
|
2013-08-23 19:59:13 +02:00
|
|
|
configure_file(${BUILDVARIABLES_SRCPATH} ${BUILDVARIABLES_OBJPATH} @ONLY)
|
2008-09-22 03:08:49 +02:00
|
|
|
|
2013-12-03 15:35:17 +01:00
|
|
|
# Set build-time environment(s).
|
|
|
|
add_definitions(-DCMAKE_CFG_INTDIR="${CMAKE_CFG_INTDIR}")
|
|
|
|
|
2017-07-31 12:07:13 +02:00
|
|
|
if(LLVM_ENABLE_MODULES)
|
|
|
|
target_compile_options(llvm-config PUBLIC
|
|
|
|
"-fmodules-ignore-macro=CMAKE_CFG_INTDIR"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2011-12-01 21:18:09 +01:00
|
|
|
# Add the dependency on the generation step.
|
|
|
|
add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp ${BUILDVARIABLES_OBJPATH})
|
2014-09-04 01:21:18 +02:00
|
|
|
|
2018-01-21 01:29:00 +01:00
|
|
|
if(CMAKE_CROSSCOMPILING AND NOT LLVM_CONFIG_PATH)
|
|
|
|
set(LLVM_CONFIG_PATH "${LLVM_NATIVE_BUILD}/bin/llvm-config" CACHE STRING "")
|
2014-09-04 01:21:18 +02:00
|
|
|
|
2018-01-21 01:29:00 +01:00
|
|
|
add_custom_command(OUTPUT "${LLVM_CONFIG_PATH}"
|
2014-09-04 01:21:18 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND} --build . --target llvm-config --config $<CONFIGURATION>
|
|
|
|
DEPENDS ${LLVM_NATIVE_BUILD}/CMakeCache.txt
|
|
|
|
WORKING_DIRECTORY ${LLVM_NATIVE_BUILD}
|
2016-12-21 22:19:00 +01:00
|
|
|
COMMENT "Building native llvm-config..."
|
|
|
|
USES_TERMINAL)
|
2018-01-21 01:29:00 +01:00
|
|
|
add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH})
|
|
|
|
add_dependencies(NativeLLVMConfig CONFIGURE_LLVM_NATIVE)
|
2014-09-04 01:21:18 +02:00
|
|
|
|
2018-01-21 01:29:00 +01:00
|
|
|
add_dependencies(llvm-config NativeLLVMConfig)
|
|
|
|
endif()
|