[英]OSX Deprecation Warnings CMake
I'm building some code using CMake
that should be compiled against the ScriptingBridge
. 我正在使用CMake
构建一些应针对ScriptingBridge
进行编译的代码。
I'm seeing many tens of thousands of log lines such as: 我看到成千上万的日志行,例如:
In file included from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Security.framework/Headers/cssmapple.h:30,
from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Security.framework/Headers/Security.h:25,
from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSURLCredential.h:9,
from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:70,
from /Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/AppKit.framework/Headers/AppKit.h:10,
from /Users/codebeaker/Projects/watchedit-client-code/src/libwhatsplaying/include/apple/itunes.h:5,
from /Users/codebeaker/Projects/watchedit-client-code/src/libwhatsplaying/src/osx/itunes_scripting_bridge.m:1:
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Security.framework/Headers/cssmtype.h:142: warning: ‘CSSM_GUID’ is deprecated
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Security.framework/Headers/cssmtype.h:143: warning: ‘CSSM_VERSION’ is deprecated
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Security.framework/Headers/cssmtype.h:156: warning: ‘CSSM_GUID’ is deprecated
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Security.framework/Headers/cssmtype.h:197: warning: ‘CSSM_DATA’ is deprecated
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Security.framework/Headers/cssmtype.h:217: warning: ‘CSSM_DATA_PTR’ is deprecated
/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks/Security.framework/Headers/cssmtype.h:220: warning: ‘CSSM_DATA’ is deprecated
( Full extensive output here ) ( 这里完全粗放输出 )
The files are being compiled with: 正在使用以下文件编译文件:
/usr/bin/c++ -I/Users/codebeaker/Projects/watchedit-client-code/src/libwhatsplaying/include -I/Users/codebeaker/Projects/watchedit-client-code/src/libwhatsplaying/../libwatchedit/include -x objective-c -o CMakeFiles/whatsplaying.dir/src/osx/itunes_scripting_bridge.m.o -c /Users/codebeaker/Projects/watchedit-client-code/src/libwhatsplaying/src/osx/itunes_scripting_bridge.m
/usr/bin/gcc -I/Users/codebeaker/Projects/watchedit-client-code/src/libwhatsplaying/include -I/Users/codebeaker/Projects/watchedit-client-code/src/libwhatsplaying/../libwatchedit/include -F/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks -x objective-c -o CMakeFiles/whatsplaying.dir/src/osx/itunes_scripting_bridge.m.o -c /Users/codebeaker/Projects/watchedit-client-code/src/libwhatsplaying/src/osx/itunes_scripting_bridge.m
Having reviewed the man page for (Clang) gcc
on my Mac, there's this which sounds interesting: 在Mac上查看了(Clang) gcc
的手册页后,听起来很有趣:
-Fdir Add the framework directory dir to the head of the list of directories to be searched for header files. These directories are interleaved with those specified by -I options and are scanned in a left-to-right order. A framework directory is a directory with frameworks in it. A framework is a directory with a "Headers" and/or "PrivateHeaders" directory contained directly in it that ends in ".framework". The name of a framework is the name of this directory excluding the ".framework". Headers associated with the framework are found in one of those two directories, with "Headers" being searched first. A subframework is a framework directory that is in a framework's "Frameworks" directory. Includes of subframework headers can only appear in a header of a framework that contains the subframework, or in a sibling subframework header. Two subframeworks are siblings if they occur in the same framework. A subframework should not have the same name as a framework, a warning will be issued if this is violated. Currently a subframework cannot have subframeworks, in the future, the mechanism may be extended to support this. The standard frameworks can be found in "/System/Library/Frameworks" and "/Library/Frameworks". An example include looks like "#include ", where Framework denotes the name of the framework and header.h is found in the "PrivateHeaders" or "Headers" directory. -iframeworkdir Like -F except the directory is a treated as a system directory. The main effect is to not warn about constructs contained within header files found via dir.
Maybe I ought to be looking for -iframework
. 也许我应该在寻找-iframework
。 When building with -iframework
on the terminal, manually this completes without any deprecation warnings. 在终端上使用-iframework
进行构建时,手动完成此操作不会出现任何弃用警告。
However CMake doesn't support an option to use -framework
. 但是,CMake不支持使用-framework
的选项。 From their find_library()
documentation: 从他们的find_library()
文档中:
CMake will use a -framework A, and a -F to link the framework to the target. CMake将使用-framework A和-F将框架链接到目标。
I'm looking for any way to have a quiet build. 我正在寻找一种安静的构建方式。 I also have (4x) smaller warnings from OpenSSL'x EVA interface, those I can handle... thanks in advance. 我还从OpenSSL'x EVA界面收到了(4x)个较小的警告,我可以处理的警告...在此先感谢。
The answer was to use -iframework
, probably as this is intended to ignore system level deprecation warnings when you can't resolve them. 答案是使用-iframework
,可能是因为当您无法解决它们时,它打算忽略系统级弃用警告。
Instead I was able to use -Wno-deprecated-declarations
, a flag to GCC
which is documented and available everywhere. 相反,我能够使用-Wno-deprecated-declarations
,它是GCC
的标志,已在文档中记录并在任何地方都可用。 It's reliable, and I include it in my CMake declaration as such: 它是可靠的,因此我将其包括在我的CMake声明中:
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_and_add_framework(Foundation watchedit)
find_and_add_framework(Cocoa watchedit)
find_and_add_framework(AppKit watchedit)
find_and_add_framework(ScriptingBridge watchedit)
set_source_files_properties(${sources} PROPERTIES COMPILE_FLAGS
"-xobjective-c -Wno-deprecated-declarations")
set_source_files_properties(${sources} PROPERTIES LANGUAGE C)
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
For anyone who would benefit, here's the implementation of find_and_add_framework
. 对于任何受益的人,这里都是find_and_add_framework
的实现。 I'm not sure where I cribbed it from, but it's not my own work: 我不确定我从哪里抄来的,但这不是我自己的工作:
macro(FIND_AND_ADD_FRAMEWORK fwname appname)
find_library(FRAMEWORK_${fwname}
NAMES ${fwname}
PATHS ${CMAKE_OSX_SYSROOT}/System/Library
PATH_SUFFIXES Frameworks
NO_DEFAULT_PATH)
if( ${FRAMEWORK_${fwname}} STREQUAL FRAMEWORK_${fwname}-NOTFOUND)
MESSAGE(ERROR ": Framework ${fwname} not found")
else()
TARGET_LINK_LIBRARIES(${appname} ${FRAMEWORK_${fwname}})
# MESSAGE(STATUS "Framework ${fwname} found at ${FRAMEWORK_${fwname}}")
endif()
endmacro(FIND_AND_ADD_FRAMEWORK)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.