# Resolve tools before project() performs its compiler and generator checks. if(CMAKE_GENERATOR MATCHES "Makefiles|Ninja") foreach(language C CXX) if(language STREQUAL "C") set(names clang cc gcc) else() set(names clang++ c++ g++) endif() if(CMAKE_${language}_COMPILER) get_filename_component(requested "${CMAKE_${language}_COMPILER}" NAME) list(INSERT names 0 "${requested}") endif() cpsc_find_dependency(PROGRAM CMAKE_${language}_COMPILER NAMES ${names} REQUIRED) # project() would otherwise restore the previous path from this file. set(compiler_info "${CMAKE_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION}/CMake${language}Compiler.cmake") if(EXISTS "${compiler_info}") file(STRINGS "${compiler_info}" previous REGEX "^set\\(CMAKE_${language}_COMPILER \"") string(REGEX REPLACE "^set\\(CMAKE_${language}_COMPILER \"([^\"]*)\"\\)$" "\\1" previous "${previous}") if(NOT previous STREQUAL CMAKE_${language}_COMPILER) file(REMOVE "${compiler_info}") endif() endif() endforeach() endif() if(CMAKE_GENERATOR MATCHES "Ninja") set(names ninja ninja-build) elseif(CMAKE_GENERATOR STREQUAL "MinGW Makefiles") set(names mingw32-make) elseif(CMAKE_GENERATOR MATCHES "NMake") set(names nmake) elseif(CMAKE_GENERATOR STREQUAL "MSYS Makefiles") set(names make) elseif(CMAKE_GENERATOR STREQUAL "Unix Makefiles") set(names gmake make) else() set(names) endif() if(names) cpsc_find_dependency(PROGRAM CMAKE_MAKE_PROGRAM NAMES ${names} REQUIRED) endif()