【发布时间】:2021-08-24 10:57:02
【问题描述】:
我想检查我的所有依赖项是否都是使用 libc++ 编译的。如果不是这种情况,则返回警告或错误。我的一些依赖项是共享库,一些是静态的。对于我目前这样做的共享库
if(MYLIB_FOUND)
set (MYLIB_LIB "${MYLIB_LIBDIR}/lib${MYLIB_LIBRARIES}.so")
set(MYLIB_FOUND TRUE)
# Check if library has been compiled with -stdlib=libc++
if(${CMAKE_VERSION} VERSION_LESS "3.16.0")
include(GetPrerequisites)
GET_PREREQUISITES(${MYLIB_LIB} PREREQUISITES FALSE FALSE "" "")
if (PREREQUISITES MATCHES "/libc\\+\\+")
if(NOT USE_LIBCXX)
message(WARNING "MyLib compiled using libc++ but this project does not use this flag")
set(MYLIB_FOUND FALSE)
endif()
else()
if(USE_LIBCXX)
message(WARNING "MyLib not compiled using libc++ but this project requires this flag")
set(MYLIB_FOUND FALSE)
endif()
endif()
else()
file(GET_RUNTIME_DEPENDENCIES RESOLVED_DEPENDENCIES_VAR MYLIB_DEPENDENCIES LIBRARIES ${MYLIB_LIB})
if (MYLIB_DEPENDENCIES MATCHES "/libc\\+\\+")
if(NOT USE_LIBCXX)
message(WARNING "MyLib compiled using libc++ but this project does not use this flag")
set(JMYLIB_FOUND FALSE)
endif()
else()
if(USE_LIBCXX)
message(WARNING "MyLib not compiled using libc++ but this project requires this flag")
set(MYLIB_FOUND FALSE)
endif()
endif()
endif()
else()
set(MYLIB_FOUND FALSE)
endif()
我怎样才能为静态库做同样的事情? (主要是 CMake 3.8 及更高版本)
【问题讨论】: