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.
|
2018-03-09 15:46:44 +01:00
|
|
|
get_property(SUPPORT_SYSTEM_LIBS TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
|
|
|
|
get_property(WINDOWSMANIFEST_SYSTEM_LIBS TARGET LLVMWindowsManifest PROPERTY LLVM_SYSTEM_LIBS)
|
|
|
|
foreach(l ${SUPPORT_SYSTEM_LIBS} ${WINDOWSMANIFEST_SYSTEM_LIBS})
|
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.
|
2019-12-03 17:52:21 +01:00
|
|
|
if(IS_ABSOLUTE ${l})
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} "${l}")
|
|
|
|
else()
|
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
|
|
|
|
endif()
|
2016-06-21 21:34:40 +02:00
|
|
|
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)
|
|
|
|
|
Don't add unnecessary compiler flags to llvm-config output
Summary:
llvm-config --cxxflags --cflags, should only output the minimal flags
required to link against the llvm libraries. They currently contain
all flags used to compile llvm including flags like -g, -pedantic,
-Wall, etc, which users may not always want.
This changes the llvm-config output to only include flags that have been
explictly added to the COMPILE_FLAGS property of the llvm-config target
by the llvm build system.
llvm.org/PR8220
Output from llvm-config when running cmake with:
cmake -G Ninja .. -DCMAKE_CXX_FLAGS=-funroll-loops
Before:
--cppflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include
-fPIC -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings \
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough \
-Wno-comment -fdiagnostics-color -g -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS \
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cxxflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include\
-funroll-loops -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall \
-Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers \
-pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized \
-Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment \
-fdiagnostics-color -g -fno-exceptions -fno-rtti -D_GNU_SOURCE -D_DEBUG \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
After:
--cppflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include \
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include \
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cxxflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include \
-std=c++11 -fno-exceptions -fno-rtti \
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
Reviewers: sylvestre.ledru, infinity0, mgorny
Reviewed By: sylvestre.ledru, mgorny
Subscribers: mgorny, dmgreen, llvm-commits
Differential Revision: https://reviews.llvm.org/D55391
llvm-svn: 349068
2018-12-13 19:21:23 +01:00
|
|
|
# NOTE: We don't want to start extracting any random C/CXX flags that the
|
|
|
|
# user may add that could affect the ABI. We only want to extract flags
|
|
|
|
# that have been added by the LLVM build system.
|
2019-08-26 11:42:30 +02:00
|
|
|
string(REGEX MATCH "-stdlib=[^ ]+" LLVM_CXX_STDLIB_FLAG ${CMAKE_CXX_FLAGS})
|
|
|
|
string(REGEX MATCH "-std=[^ ]+" LLVM_C_STD_FLAG ${CMAKE_C_FLAGS})
|
Don't add unnecessary compiler flags to llvm-config output
Summary:
llvm-config --cxxflags --cflags, should only output the minimal flags
required to link against the llvm libraries. They currently contain
all flags used to compile llvm including flags like -g, -pedantic,
-Wall, etc, which users may not always want.
This changes the llvm-config output to only include flags that have been
explictly added to the COMPILE_FLAGS property of the llvm-config target
by the llvm build system.
llvm.org/PR8220
Output from llvm-config when running cmake with:
cmake -G Ninja .. -DCMAKE_CXX_FLAGS=-funroll-loops
Before:
--cppflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include
-fPIC -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings \
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough \
-Wno-comment -fdiagnostics-color -g -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS \
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cxxflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include\
-funroll-loops -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall \
-Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers \
-pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized \
-Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment \
-fdiagnostics-color -g -fno-exceptions -fno-rtti -D_GNU_SOURCE -D_DEBUG \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
After:
--cppflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include \
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include \
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cxxflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include \
-std=c++11 -fno-exceptions -fno-rtti \
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
Reviewers: sylvestre.ledru, infinity0, mgorny
Reviewed By: sylvestre.ledru, mgorny
Subscribers: mgorny, dmgreen, llvm-commits
Differential Revision: https://reviews.llvm.org/D55391
llvm-svn: 349068
2018-12-13 19:21:23 +01:00
|
|
|
|
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})
|
Don't add unnecessary compiler flags to llvm-config output
Summary:
llvm-config --cxxflags --cflags, should only output the minimal flags
required to link against the llvm libraries. They currently contain
all flags used to compile llvm including flags like -g, -pedantic,
-Wall, etc, which users may not always want.
This changes the llvm-config output to only include flags that have been
explictly added to the COMPILE_FLAGS property of the llvm-config target
by the llvm build system.
llvm.org/PR8220
Output from llvm-config when running cmake with:
cmake -G Ninja .. -DCMAKE_CXX_FLAGS=-funroll-loops
Before:
--cppflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include
-fPIC -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings \
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough \
-Wno-comment -fdiagnostics-color -g -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS \
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cxxflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include\
-funroll-loops -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall \
-Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers \
-pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized \
-Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment \
-fdiagnostics-color -g -fno-exceptions -fno-rtti -D_GNU_SOURCE -D_DEBUG \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS"
After:
--cppflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include \
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include \
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
--cxxflags: -I$HEADERS_DIR/llvm/include -I$HEADERS_DIR/llvm/build/include \
-std=c++11 -fno-exceptions -fno-rtti \
-D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
Reviewers: sylvestre.ledru, infinity0, mgorny
Reviewed By: sylvestre.ledru, mgorny
Subscribers: mgorny, dmgreen, llvm-commits
Differential Revision: https://reviews.llvm.org/D55391
llvm-svn: 349068
2018-12-13 19:21:23 +01:00
|
|
|
set(LLVM_CPPFLAGS "${LLVM_DEFINITIONS}")
|
|
|
|
set(LLVM_CFLAGS "${LLVM_C_STD_FLAG} ${LLVM_DEFINITIONS}")
|
2019-11-01 17:12:03 +01:00
|
|
|
# The language standard potentially affects the ABI/API of LLVM, so we want
|
|
|
|
# to make sure it is reported by llvm-config.
|
|
|
|
set(LLVM_CXXFLAGS "${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION} ${LLVM_CXX_STDLIB_FLAG} ${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})
|
2018-03-29 11:44:09 +02:00
|
|
|
set(LLVM_DYLIB_VERSION "${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX}")
|
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
|
|
|
|
BUILD_SHARED_LIBS)
|
2019-07-20 00:46:47 +02:00
|
|
|
llvm_expand_pseudo_components(LLVM_DYLIB_COMPONENTS_expanded "${LLVM_DYLIB_COMPONENTS}")
|
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)
|
2019-04-02 17:58:03 +02:00
|
|
|
build_native_tool(llvm-config LLVM_CONFIG_PATH)
|
|
|
|
set(LLVM_CONFIG_PATH "${LLVM_CONFIG_PATH}" CACHE STRING "")
|
2014-09-04 01:21:18 +02:00
|
|
|
|
2018-01-21 01:29:00 +01:00
|
|
|
add_custom_target(NativeLLVMConfig DEPENDS ${LLVM_CONFIG_PATH})
|
|
|
|
add_dependencies(llvm-config NativeLLVMConfig)
|
|
|
|
endif()
|