Skip to content

Commit

Permalink
[infra] Provide CMAKE_TOOLCHAIN_FILE for external (#8482)
Browse files Browse the repository at this point in the history
This will provide CMAKE_TOOLCHAIN_FILE for external CMake projects if defined.

ONE-DCO-1.0-Signed-off-by: SaeHie Park <[email protected]>
  • Loading branch information
seanshpark authored Feb 22, 2022
1 parent 5a51b2d commit 7802d36
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions infra/cmake/modules/ExternalBuildTools.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ function(ExternalBuild_CMake)

message(STATUS "Build ${ARG_PKG_NAME} from ${ARG_CMAKE_DIR}")

# if we're doing the cross compilation, external project also needs it
if(CMAKE_TOOLCHAIN_FILE)
set(TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
# NOTE CMAKE_TOOLCHAIN_FILE maybe relative path -> make abs folder
if(NOT EXISTS ${TOOLCHAIN_FILE})
set(TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/${CMAKE_TOOLCHAIN_FILE})
if(NOT EXISTS ${TOOLCHAIN_FILE})
message(FATAL "Failed to find ${CMAKE_TOOLCHAIN_FILE}")
endif()
endif()
message(STATUS "ExternalBuild_CMake TOOLCHAIN_FILE=${TOOLCHAIN_FILE}")
list(APPEND ARG_EXTRA_OPTS -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE})
endif(CMAKE_TOOLCHAIN_FILE)

file(MAKE_DIRECTORY ${ARG_BUILD_DIR})
file(MAKE_DIRECTORY ${ARG_INSTALL_DIR})

Expand Down

0 comments on commit 7802d36

Please sign in to comment.