forked from llvm-mirror/llvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabling LLVM & Clang to be cross-compiled using CMake from a single …
…configuration command line 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
- Loading branch information
Chris Bieneman
committed
Sep 3, 2014
1 parent
c0f2b8b
commit 901166c
Showing
5 changed files
with
105 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
if(NOT DEFINED LLVM_NATIVE_BUILD) | ||
set(LLVM_NATIVE_BUILD "${CMAKE_BINARY_DIR}/native") | ||
message(STATUS "Setting native build dir to ${LLVM_NATIVE_BUILD}") | ||
endif(NOT DEFINED LLVM_NATIVE_BUILD) | ||
|
||
add_custom_command(OUTPUT ${LLVM_NATIVE_BUILD} | ||
COMMAND ${CMAKE_COMMAND} -E make_directory ${LLVM_NATIVE_BUILD} | ||
COMMENT "Creating ${LLVM_NATIVE_BUILD}...") | ||
|
||
add_custom_command(OUTPUT ${LLVM_NATIVE_BUILD}/CMakeCache.txt | ||
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${CMAKE_SOURCE_DIR} | ||
WORKING_DIRECTORY ${LLVM_NATIVE_BUILD} | ||
DEPENDS ${LLVM_NATIVE_BUILD} | ||
COMMENT "Configuring native LLVM...") | ||
|
||
add_custom_target(ConfigureNativeLLVM DEPENDS ${LLVM_NATIVE_BUILD}/CMakeCache.txt) | ||
|
||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${LLVM_NATIVE_BUILD}) | ||
|
||
if(NOT IS_DIRECTORY ${LLVM_NATIVE_BUILD}) | ||
if(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") | ||
set(HOST_SYSROOT_FLAGS -DCMAKE_OSX_SYSROOT=macosx) | ||
endif(${CMAKE_HOST_SYSTEM_NAME} MATCHES "Darwin") | ||
|
||
message(STATUS "Configuring native build...") | ||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory | ||
${LLVM_NATIVE_BUILD} ) | ||
|
||
message(STATUS "Configuring native targets...") | ||
execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release | ||
-G "${CMAKE_GENERATOR}" -DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD} ${HOST_SYSROOT_FLAGS} ${CMAKE_SOURCE_DIR} | ||
WORKING_DIRECTORY ${LLVM_NATIVE_BUILD} ) | ||
endif(NOT IS_DIRECTORY ${LLVM_NATIVE_BUILD}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Toolchain config for iOS. | ||
# | ||
# Usage: | ||
# mkdir build; cd build | ||
# cmake ..; make | ||
# mkdir ios; cd ios | ||
# cmake -DLLVM_IOS_TOOLCHAIN_DIR=/path/to/ios/ndk \ | ||
# -DCMAKE_TOOLCHAIN_FILE=../../cmake/platforms/iOS.cmake ../.. | ||
# make <target> | ||
|
||
SET(CMAKE_SYSTEM_NAME Darwin) | ||
SET(CMAKE_SYSTEM_VERSION 13) | ||
SET(CMAKE_CXX_COMPILER_WORKS True) | ||
SET(CMAKE_C_COMPILER_WORKS True) | ||
SET(DARWIN_TARGET_OS_NAME ios) | ||
|
||
IF(NOT DEFINED ENV{SDKROOT}) | ||
MESSAGE(FATAL_ERROR "SDKROOT env var must be set: " $ENV{SDKROOT}) | ||
ENDIF() | ||
|
||
IF(NOT CMAKE_C_COMPILER) | ||
execute_process(COMMAND xcrun -sdk iphoneos -find clang | ||
OUTPUT_VARIABLE CMAKE_C_COMPILER | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
message(STATUS "Using c compiler ${CMAKE_C_COMPILER}") | ||
ENDIF() | ||
|
||
IF(NOT CMAKE_CXX_COMPILER) | ||
execute_process(COMMAND xcrun -sdk iphoneos -find clang++ | ||
OUTPUT_VARIABLE CMAKE_CXX_COMPILER | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
message(STATUS "Using c compiler ${CMAKE_CXX_COMPILER}") | ||
ENDIF() | ||
|
||
IF (NOT DEFINED IOS_MIN_TARGET) | ||
execute_process(COMMAND xcodebuild -sdk iphoneos -version SDKVersion | ||
OUTPUT_VARIABLE IOS_MIN_TARGET | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
ENDIF() | ||
|
||
SET(IOS_COMMON_FLAGS "-isysroot $ENV{SDKROOT} -mios-version-min=${IOS_MIN_TARGET}") | ||
SET(CMAKE_C_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cflags" FORCE) | ||
SET(CMAKE_CXX_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_cxxflags" FORCE) | ||
SET(CMAKE_LINK_FLAGS "${IOS_COMMON_FLAGS}" CACHE STRING "toolchain_linkflags" FORCE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters