CMake generation fail in check_type_size(off64_t OFF64_T) related to CMAKE_EXECUTABLE_SUFFIX definition
Hi CMake users,
In trying to compile zlib repository, I faced a very strange CMake generation error:
CMake Error at /dev/install/cmake-3.19.5-Linux-x86_64/share/cmake-3.19/Modules/CheckTypeSize.cmake:135 (try_compile):
Cannot copy output executable
''
to destination specified by COPY_FILE:
'/dev/build/CMakeFiles/CheckTypeSize/OFF64_T.bin'
Unable to find the executable at any of:
/dev/build/CMakeFiles/CMakeTmp/cmTC_e470b.x
/dev/build/CMakeFiles/CMakeTmp/Debug/cmTC_e470b.x
/dev/build/CMakeFiles/CMakeTmp/Development/cmTC_e470b.x
Call Stack (most recent call first):
/dev/install/cmake-3.19.5-Linux-x86_64/share/cmake-3.19/Modules/CheckTypeSize.cmake:266 (__check_type_size_impl)
CMakeLists.txt:8 (check_type_size)
To identify the root of this error, I reproduced in a small CMakeLists:
cmake_minimum_required(VERSION 3.19)
project(zlib C)
set(CMAKE_EXECUTABLE_SUFFIX ".x")
include(CheckTypeSize)
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
check_type_size(off64_t OFF64_T)
With this small example the generation fail:
cmake -G Ninja -DCMAKE_C_COMPILER=icc -DCMAKE_CXX_COMPILER=icpc -DCMAKE_BUILD_TYPE=Release ..
-- The C compiler identification is Intel 19.0.5.20190815
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/intel_2019/compilers_and_libraries_2019.5.281/linux/bin/intel64/icc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- var : OFF64_T : src : /dev/build/CMakeFiles/CheckTypeSize/OFF64_T.c : bin : /dev/build/CMakeFiles/CheckTypeSize/OFF64_T.bin : CMAKE_TRY_COMPILE_CONFIGURATION =
-- CMAKE_REQUIRED_DEFINITIONS : -D_LARGEFILE64_SOURCE=1 : CMAKE_REQUIRED_LINK_OPTIONS : : CMAKE_REQUIRED_LINK_OPTIONS : : CMAKE_REQUIRED_LIBRARIES : -DCOMPILE_DEFINITIONS:STRING= : -DINCLUDE_DIRECTORIES:STRING=
CMake Error at /dev/install/cmake-3.19.5-Linux-x86_64/share/cmake-3.19/Modules/CheckTypeSize.cmake:135 (try_compile):
Cannot copy output executable
''
to destination specified by COPY_FILE:
'/dev/build/CMakeFiles/CheckTypeSize/OFF64_T.bin'
Unable to find the executable at any of:
/dev/build/CMakeFiles/CMakeTmp/cmTC_e470b.x
/dev/build/CMakeFiles/CMakeTmp/Debug/cmTC_e470b.x
/dev/build/CMakeFiles/CMakeTmp/Development/cmTC_e470b.x
Call Stack (most recent call first):
/dev/install/cmake-3.19.5-Linux-x86_64/share/cmake-3.19/Modules/CheckTypeSize.cmake:266 (__check_type_size_impl)
CMakeLists.txt:8 (check_type_size)
-- Configuring incomplete, errors occurred!
See also "/dev/build/CMakeFiles/CMakeOutput.log".
We also observed two things:
- It fails only on the first generation
- It works when the
set(CMAKE_EXECUTABLE_SUFFIX ".x")
is commented🤔
Any ideas ?