mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
Merge topic 'normalize-toolchain-file' into release-4.1
c393300e2bcmake: Restore acceptance of -DCMAKE_TOOLCHAIN_FILE=//... on non-Windowscf0f46ed85Tests/RunCMake/CommandLine: Simplify --toolchain cases Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !10901
This commit is contained in:
@@ -139,17 +139,24 @@ endif()
|
||||
# variables around so they can be used in CMakeLists.txt.
|
||||
# In all other cases, the host and target platform are the same.
|
||||
if(CMAKE_TOOLCHAIN_FILE)
|
||||
# at first try to load it as path relative to the directory from which cmake has been run
|
||||
include("${CMAKE_BINARY_DIR}/${CMAKE_TOOLCHAIN_FILE}" OPTIONAL RESULT_VARIABLE _INCLUDED_TOOLCHAIN_FILE)
|
||||
if(NOT _INCLUDED_TOOLCHAIN_FILE)
|
||||
# if the file isn't found there, check the default locations
|
||||
include("${CMAKE_TOOLCHAIN_FILE}" OPTIONAL RESULT_VARIABLE _INCLUDED_TOOLCHAIN_FILE)
|
||||
endif()
|
||||
|
||||
if(_INCLUDED_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE "${_INCLUDED_TOOLCHAIN_FILE}" CACHE FILEPATH "The CMake toolchain file" FORCE)
|
||||
if(IS_ABSOLUTE "${CMAKE_TOOLCHAIN_FILE}" AND EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
# Normalize the absolute path.
|
||||
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" CACHE FILEPATH "The CMake toolchain file" FORCE)
|
||||
set(CMAKE_TOOLCHAIN_FILE "$CACHE{CMAKE_TOOLCHAIN_FILE}")
|
||||
include("${CMAKE_TOOLCHAIN_FILE}" OPTIONAL RESULT_VARIABLE _INCLUDED_TOOLCHAIN_FILE)
|
||||
else()
|
||||
message(FATAL_ERROR "Could not find toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
# at first try to load it as path relative to the directory from which cmake has been run
|
||||
include("${CMAKE_BINARY_DIR}/${CMAKE_TOOLCHAIN_FILE}" OPTIONAL RESULT_VARIABLE _INCLUDED_TOOLCHAIN_FILE)
|
||||
if(NOT _INCLUDED_TOOLCHAIN_FILE)
|
||||
# if the file isn't found there, check the default locations
|
||||
include("${CMAKE_TOOLCHAIN_FILE}" OPTIONAL RESULT_VARIABLE _INCLUDED_TOOLCHAIN_FILE)
|
||||
endif()
|
||||
if(_INCLUDED_TOOLCHAIN_FILE)
|
||||
set(CMAKE_TOOLCHAIN_FILE "${_INCLUDED_TOOLCHAIN_FILE}" CACHE FILEPATH "The CMake toolchain file" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT _INCLUDED_TOOLCHAIN_FILE)
|
||||
message(FATAL_ERROR "Could not find toolchain file:\n \"${CMAKE_TOOLCHAIN_FILE}\"")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user