CMake 3.11.0 check_include_files using CMAKE_REQUIRED_LIBRARIES is a breaking change
In https://github.com/SOCI/soci/ project, we've been using CMake for very long time, building locally as well as on CI services (AppVeyor and Travis CI). Our old-school CMake configuration has not changed significantly, if at all, for long time. It just works.
Earlier this week, AppVeyor updated to the latest 3.11 and our builds started failing. The reasons is quite a mystery.
TL;TR: We call check_include_files("windows.h;sqlext.h" HAVE_SQLEXT_H)
and it succeeds using CMake 3.10 or earlier, but it fails with CMake 3.11.
If I re-run CMake 3.11 for the failing configuration straight-away again, it passes without error and project is generated fine:
D:\tmp\cmake_test\build-3.11
λ C:\apps\cmake-3.11.0-win64-x64\bin\cmake.exe ..
-- Building for: Visual Studio 15 2017
-- The C compiler identification is MSVC 19.13.26129.0
-- The CXX compiler identification is MSVC 19.13.26129.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.13.26128/bin/Hostx64/x86/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.13.26128/bin/Hostx64/x86/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.13.26128/bin/Hostx64/x86/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/VC/Tools/MSVC/14.13.26128/bin/Hostx64/x86/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- MySQL:
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION - Success
-- Found MySQL: C:/Program Files/MySQL/MySQL Connector C 6.1/include, C:/Program Files/MySQL/MySQL Connector C 6.1/lib/libmysql.lib
-- MySQL Embedded not found.
-- ODBC:
-- Looking for include files windows.h, sqlext.h
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
MYSQL_EMBEDDED_LIBRARIES
linked by target "cmTC_7696b" in directory D:/tmp/cmake_test/build-3.11/CMakeFiles/CMakeTmp
CMake Error at C:/apps/cmake-3.11.0-win64-x64/share/cmake-3.11/Modules/CheckIncludeFiles.cmake:103 (try_compile):
Failed to configure test project build system.
Call Stack (most recent call first):
cmake/modules/FindODBC.cmake:21 (check_include_files)
cmake/dependencies/ODBC.cmake:3 (find_package)
cmake/SociDependencies.cmake:10 (include)
CMakeLists.txt:11 (include)
-- Configuring incomplete, errors occurred!
See also "D:/tmp/cmake_test/build-3.11/CMakeFiles/CMakeOutput.log".
D:\tmp\cmake_test\build-3.11
λ C:\apps\cmake-3.11.0-win64-x64\bin\cmake.exe ..
-- MySQL:
-- Found MySQL: C:/Program Files/MySQL/MySQL Connector C 6.1/include, C:/Program Files/MySQL/MySQL Connector C 6.1/lib/libmysql.lib
-- MySQL Embedded not found.
-- ODBC:
-- Configuring done
-- Generating done
-- Build files have been written to: D:/tmp/cmake_test/build-3.11
D:\tmp\cmake_test\build-3.11
Here is minimal working example which can be used to reproduce the problem cmake_test.zip. It includes cache generated with both, CMake 3.10 and 3.11, on Windows with VS2017 Professional (15.6.3).
In the release notes for 3.11, I don't see any breaking changing in check_include_files
, so it possibly is a regression.