mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-23 15:29:51 +00:00
901166c939
The basic idea is similar to the existing cross compilation support. A directory must be configured to build host versions of tablegen tools and llvm-config. This directory can be user provided (and configured), or it can be created during the build. During a build the native build directory will be configured and built to supply the tablegen tools used during the build. A user could also explicitly provide the tablegen executables to run on the CMake command line. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217105 91177308-0d34-0410-b5e6-96231b3b80d8
51 lines
2.2 KiB
CMake
51 lines
2.2 KiB
CMake
set(LLVM_LINK_COMPONENTS support)
|
|
|
|
set(BUILDVARIABLES_SRCPATH ${CMAKE_CURRENT_SOURCE_DIR}/BuildVariables.inc.in)
|
|
set(BUILDVARIABLES_OBJPATH ${CMAKE_CURRENT_BINARY_DIR}/BuildVariables.inc)
|
|
|
|
# Compute the substitution values for various items.
|
|
get_property(LLVM_SYSTEM_LIBS_LIST TARGET LLVMSupport PROPERTY LLVM_SYSTEM_LIBS)
|
|
foreach(l ${LLVM_SYSTEM_LIBS_LIST})
|
|
set(SYSTEM_LIBS ${SYSTEM_LIBS} "-l${l}")
|
|
endforeach()
|
|
string(REPLACE ";" " " SYSTEM_LIBS "${SYSTEM_LIBS}")
|
|
|
|
# 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}")
|
|
set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
|
|
# Use the C++ link flags, since they should be a superset of C link flags.
|
|
set(LLVM_LDFLAGS "${CMAKE_CXX_LINK_FLAGS}")
|
|
set(LLVM_BUILDMODE ${CMAKE_BUILD_TYPE})
|
|
set(LLVM_SYSTEM_LIBS ${SYSTEM_LIBS})
|
|
string(REPLACE ";" " " LLVM_TARGETS_BUILT "${LLVM_TARGETS_TO_BUILD}")
|
|
configure_file(${BUILDVARIABLES_SRCPATH} ${BUILDVARIABLES_OBJPATH} @ONLY)
|
|
|
|
# Set build-time environment(s).
|
|
add_definitions(-DCMAKE_CFG_INTDIR="${CMAKE_CFG_INTDIR}")
|
|
|
|
# Add the llvm-config tool.
|
|
add_llvm_tool(llvm-config
|
|
llvm-config.cpp
|
|
)
|
|
|
|
# Add the dependency on the generation step.
|
|
add_file_dependencies(${CMAKE_CURRENT_SOURCE_DIR}/llvm-config.cpp ${BUILDVARIABLES_OBJPATH})
|
|
|
|
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})
|
|
add_dependencies(${project}NativeLLVMConfig ConfigureNativeLLVM)
|
|
|
|
add_dependencies(llvm-config ${project}NativeLLVMConfig)
|
|
endif(CMAKE_CROSSCOMPILING)
|