Hi,
I've been trying to use the check_include_file() macro to verify if a
particular ObjC header can be compiled. This turns out to be almost impossible,
but I cannot put my finger on whether there isn't a compiler error involved too.
Let's take the easier case for Mac OS X, where you don't have to install
GNUstep. The following statement could be expected to work:
check_include_file(Foundation/Foundation.h HAVE_FOUNDATION "-v -x objective-c")
but it fails. The -x argument is required, the -v option is purely for
debugging. The error from CMakeError.log is copied below; it seems that the
intermediate object file is corrupt. However, the same symptoms occur with a
comparable test file built the same way with clang:
%> clang -x objective-c -c test.c
%> clang -x objective-c test.o
However,
%> clang test.o
and
%> clang -x objective-c test.c
work fine, and it's clear from the trace output that the -x option should NOT
be passed to clang when it's used as a linker driver.
Questions:
- is there a more appropriate way to check if an Objective C header can be
compiled?
- is there a way to configure or set up things such that the trycompile
functions use a single compiler invocation, or test only the object file
generation (which should be enough for testing a headerfile)?
Thank,
René
CMakeError.log extract:
Building C object CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-O3 -march=native -g -v -x objective-c
-isystem /usr/include/GNUstep -o
CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o -c ...//src/MSWin/
SynchroTr/CMake/Release/CMakeFiles/CMakeTmp/CheckIncludeFile.c
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
-cc1 -triple x86_64-apple-macosx10.9
.0 -emit-obj -disable-free -disable-llvm-verifier -main-file-name
CheckIncludeFile.c -mrelocation-model pic -pic-level 2 -mdisable-f
p-elim -masm-verbose -munwind-tables -target-cpu corei7-avx
-target-linker-version 241.9 -v -gdwarf-2 -coverage-file
...//src/MSWin/SynchroTr/CMake/Release/CMakeFiles/CMakeTmp/CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o
-resource-di
r
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0
-isystem /usr/include/GNUs
tep -I/opt/local/include -O3 -fdebug-compilation-dir
...//src/MSWin/SynchroTr/CMake/Release/CMakeFiles/
CMakeTmp -ferror-limit 19 -fmessage-length 0 -stack-protector 1 -mstackrealign
-fblocks -fobjc-runtime=macosx-10.9.0 -fencode-extend
ed-block-signature -fobjc-exceptions -fexceptions -fdiagnostics-show-option
-vectorize-loops -vectorize-slp -o CMakeFiles/cmTC_61f5f
.dir/CheckIncludeFile.c.o -x objective-c
...//src/MSWin/SynchroTr/CMake/Release/CMakeFiles/CMakeTmp/Che
ckIncludeFile.c
clang -cc1 version 6.0 based upon LLVM 3.5svn default target
x86_64-apple-darwin13.4.0
ignoring nonexistent directory "/usr/include/GNUstep"
#include "..." search starts here:
#include <...> search starts here:
/opt/local/include
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
Linking C executable cmTC_61f5f
/opt/local/bin/cmake -E cmake_link_script CMakeFiles/cmTC_61f5f.dir/link.txt
--verbose=1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-O3 -march=native -g -v -x objective-c -isystem /usr/include/GNUstep
-Wl,-search_paths_first -Wl,-headerpad_max_install_names
CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o -o cmTC_61f5f
Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin13.4.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
-cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -disable-free
-disable-llvm-verifier -main-file-name CheckIncludeFile.c.o -mrelocation-model
pic -pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu
corei7-avx -target-linker-version 241.9 -v -gdwarf-2 -resource-dir
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0
-isystem /usr/include/GNUstep -I/opt/local/include -O3 -fdebug-compilation-dir
...//src/MSWin/SynchroTr/CMake/Release/CMakeFiles/CMakeTmp -ferror-limit 19
-fmessage-length 0 -stack-protector 1 -mstackrealign -fblocks
-fobjc-runtime=macosx-10.9.0 -fencode-extended-block-signature
-fobjc-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops
-vectorize-slp -o
/var/folders/j1/1439ppj08xj8h6006s6drbq00000gs/T/CheckIncludeFile-025ed5.o -x
objective-c CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o
clang -cc1 version 6.0 based upon LLVM 3.5svn default target
x86_64-apple-darwin13.4.0
ignoring nonexistent directory "/usr/include/GNUstep"
#include "..." search starts here:
#include <...> search starts here:
/opt/local/include
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o:1:1: error: source file is not
valid UTF-8
<CF><FA><ED><FE><U+0007>
^
CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o:1:2: error: source file is not
valid UTF-8
<CF><FA><ED><FE><U+0007>
^
CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o:1:3: error: source file is not
valid UTF-8
<CF><FA><ED><FE><U+0007>
^
CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o:1:4: error: source file is not
valid UTF-8
<CF><FA><ED><FE><U+0007>
^
CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o:1:5: error: expected identifier
or '('
<CF><FA><ED><FE><U+0007>
^
CMakeFiles/cmTC_61f5f.dir/CheckIncludeFile.c.o:1:6: warning: null character
ignored [-Wnull-character]
<CF><FA><ED><FE><U+0007>
[etc, snip]
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake