Xcode: Compiler identification is unknown fot tvos
(Description originally taken from !2299 (merged).)
Description:
When executing command
$ cmake -G Xcode -DCMAKE_TOOLCHAIN_FILE=iOS.cmake .
with following files:
CMakeLists.txt
project(test)
message (STATUS "CMAKE_CXX_COMPILER_ID - ${CMAKE_CXX_COMPILER_ID}")
iOS.cmake
set(CMAKE_C_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang")
set(CMAKE_CXX_COMPILER "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++")
set(CMAKE_OSX_SYSROOT /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS11.4.sdk)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
cmake fails to identify compilers.
Output from command is:
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- CMAKE_CXX_COMPILER_ID -
-- Configuring done
-- Generating done
As one can see, CMAKE_CXX_COMPILER_ID remains empty.
CMakeError.log contains following errors:
Compiling the C compiler identification source file "CMakeCCompilerId.c" failed.
Compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
Build flags:
Id flags:
The output was:
65
=== BUILD TARGET CompilerIdC OF PROJECT CompilerIdC WITH THE DEFAULT CONFIGURATION (Debug) ===
Check dependencies
Code Signing Error: Signing for "CompilerIdC" requires a development team. Select a development team in the project editor.
** BUILD FAILED **
System configuration to reproduce is following:
Darwin 17.7.0
cmake 3.12.20180816-gba12-dirty (also present in official releases 3.10.2 and 3.12.1)
clang - Apple LLVM version 9.1.0 (clang-902.0.39.2)
sdk version - AppleTVOS11.4.sdk
XCode - 9.4.1 (9F2000)
Reason of failure:
Attached file is a screenshot of xcode project used by module CMakeDetermineCompilerId.cmake
to identify CXX compiler.
Above system configuration (system/xcode/sdk) contains non-empty default value for CODE_SIGNING_IDENTITY which makes XCode to require signing even though DEVELOPMENT_TEAM is empty and REQUIRE_CODE_SIGNING is set to NO.
For example, the same project run for iphoneos device contains empty default value for CODE_SIGNING_IDENTITY thus combination of CODE_SIGNING_IDENTITY, DEVELOPMENT_TEAM, REQUIRE_CODE_SIGNING does not require signing and whole identification works.
Possible other solutions:
- one can provide valid DEVELOPMENT_TEAM value and actually sign project during compiler id identification however seems too much to require valid signing infrastructure just to identify compiler
- modify product-type used by
CMakeDetermineCompilerId.cmake:347
module toset(id_product_type "com.apple.product-type.library.static")