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})
|
2011-12-01 21:18:09 +01:00
|
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
|
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})
|
|
|
|
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}")
|
2015-08-14 18:20:31 +02:00
|
|
|
set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}")
|
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}")
|
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}")
|
|
|
|
|
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
|
|
|
|
|
|
|
if(CMAKE_CROSSCOMPILING)
|
|
|
|
set(${project}_LLVM_CONFIG_EXE "${LLVM_NATIVE_BUILD}/bin/llvm-config")
|
|
|
|
set(${project}_LLVM_CONFIG_EXE ${${project}_LLVM_CONFIG_EXE} PARENT_SCOPE)
|
|
|
|
|
|
|
|
add_custom_command(OUTPUT "${${project}_LLVM_CONFIG_EXE}"
|
|
|
|
COMMAND ${CMAKE_COMMAND} --build . --target llvm-config --config $<CONFIGURATION>
|
|
|
|
DEPENDS ${LLVM_NATIVE_BUILD}/CMakeCache.txt
|
|
|
|
WORKING_DIRECTORY ${LLVM_NATIVE_BUILD}
|
|
|
|
COMMENT "Building native llvm-config...")
|
|
|
|
add_custom_target(${project}NativeLLVMConfig DEPENDS ${${project}_LLVM_CONFIG_EXE})
|
2015-03-12 18:33:34 +01:00
|
|
|
add_dependencies(${project}NativeLLVMConfig CONFIGURE_LLVM_NATIVE)
|
2014-09-04 01:21:18 +02:00
|
|
|
|
|
|
|
add_dependencies(llvm-config ${project}NativeLLVMConfig)
|
|
|
|
endif(CMAKE_CROSSCOMPILING)
|