1# Cable: CMake Bootstrap Library. 2# Copyright 2018 Pawel Bylica. 3# Licensed under the Apache License, Version 2.0. See the LICENSE file. 4 5set(cable_toolchain_dir ${CMAKE_CURRENT_LIST_DIR}/toolchains) 6 7function(cable_configure_toolchain) 8 if(NOT PROJECT_IS_NESTED) 9 # Do this configuration only in the top project. 10 11 cmake_parse_arguments("" "" "DEFAULT" "" ${ARGN}) 12 13 set(default_toolchain default) 14 if(_DEFAULT) 15 set(default_toolchain ${_DEFAULT}) 16 endif() 17 18 set(TOOLCHAIN ${default_toolchain} CACHE STRING "CMake toolchain") 19 20 set(toolchain_file toolchains/${TOOLCHAIN}.cmake) 21 foreach(path ${CMAKE_MODULE_PATH}) 22 if(EXISTS "${path}/${toolchain_file}") 23 set(toolchain_file "${path}/${toolchain_file}") 24 break() 25 endif() 26 endforeach() 27 28 cable_debug("Toolchain file: ${toolchain_file}") 29 set(CMAKE_TOOLCHAIN_FILE ${toolchain_file} CACHE FILEPATH "CMake toolchain file") 30 endif() 31endfunction() 32