gpt4 book ai didi

visual-c++ - CMakeLists.txt 中的 CMake Warning (dev) : No cmake_minimum_required command is present. 一行代码如 cmake_minimum_required(VERSION 3.9)

转载 作者:行者123 更新时间:2023-12-02 13:46:25 30 4
gpt4 key购买 nike

我正在尝试使用 cmake 从源代码构建 ssh.lib。

为此,我下载了 libssh 0.8.2、Win32OpenSSL_Light-1_1_0i 和 cmake-3.9.0-rc1-win64-x64。

使用 Visual Studio 2017。我已将 open SSL 安装到 c 目录中,然后使用 cmake 分配源和构建路径。生成时,显示错误“配置过程中出错,项目文件可能无效”和

**CMake Error at CMakeLists.txt:335 (install):
install Library TARGETS given no DESTINATION!


Threads_FOUND=
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 3.9)

should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.**

我读了 this ,问题还是没有解决。我从很多天开始都在尝试这样做,请提供任何建议或帮助。

和 C:\Users\Sami\Downloads\libssh-0.8.0.tar\libssh-0.8.0\src\CMakeLists.txt 在下面
**
set(LIBSSH_PUBLIC_INCLUDE_DIRS
${libssh_SOURCE_DIR}/include
CACHE INTERNAL "libssh public include directories"
)

set(LIBSSH_PRIVATE_INCLUDE_DIRS
${libssh_BINARY_DIR}
)

set(LIBSSH_LINK_LIBRARIES
${LIBSSH_REQUIRED_LIBRARIES}
)

if (WIN32)
set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
ws2_32
)
endif (WIN32)

if (HAVE_LIBSOCKET)
set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
socket
)
endif (HAVE_LIBSOCKET)

if (OPENSSL_CRYPTO_LIBRARY)
set(LIBSSH_PRIVATE_INCLUDE_DIRS
${LIBSSH_PRIVATE_INCLUDE_DIRS}
${OPENSSL_INCLUDE_DIR}
)

set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
${OPENSSL_CRYPTO_LIBRARY}
)
endif (OPENSSL_CRYPTO_LIBRARY)

if (MBEDTLS_CRYPTO_LIBRARY)
set(LIBSSH_PRIVATE_INCLUDE_DIRS
${LIBSSH_PRIVATE_INCLUDE_DIRS}
${MBEDTLS_INCLUDE_DIR}
)
set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
${MBEDTLS_CRYPTO_LIBRARY}
)
endif (MBEDTLS_CRYPTO_LIBRARY)

if (GCRYPT_LIBRARY)
set(LIBSSH_PRIVATE_INCLUDE_DIRS
${LIBSSH_PRIVATE_INCLUDE_DIRS}
${GCRYPT_INCLUDE_DIR}
)

set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
${GCRYPT_LIBRARY}
)
endif (GCRYPT_LIBRARY)

if (WITH_ZLIB)
set(LIBSSH_PRIVATE_INCLUDE_DIRS
${LIBSSH_PRIVATE_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
)

set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
${ZLIB_LIBRARY}
)
endif (WITH_ZLIB)

if (WITH_GSSAPI AND GSSAPI_FOUND)
set(LIBSSH_PRIVATE_INCLUDE_DIRS
${LIBSSH_PRIVATE_INCLUDE_DIRS}
${GSSAPI_INCLUDE_DIR}
)

set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
${GSSAPI_LIBRARIES}
)
endif (WITH_GSSAPI AND GSSAPI_FOUND)

if (WITH_NACL AND NACL_FOUND)
set(LIBSSH_PRIVATE_INCLUDE_DIRS
${LIBSSH_PRIVATE_INCLUDE_DIRS}
${NACL_INCLUDE_DIR}
)

set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
${NACL_LIBRARY}
)
endif (WITH_NACL AND NACL_FOUND)

set(LIBSSH_LINK_LIBRARIES
${LIBSSH_LINK_LIBRARIES}
CACHE INTERNAL "libssh link libraries"
)

set(LIBSSH_SHARED_LIBRARY
ssh_shared
CACHE INTERNAL "libssh shared library"
)

if (WITH_STATIC_LIB)
set(LIBSSH_STATIC_LIBRARY
ssh_static
CACHE INTERNAL "libssh static library"
)
endif (WITH_STATIC_LIB)

set(libssh_SRCS
agent.c
auth.c
base64.c
bignum.c
buffer.c
callbacks.c
channels.c
client.c
config.c
connect.c
connector.c
curve25519.c
dh.c
ecdh.c
error.c
getpass.c
init.c
kex.c
known_hosts.c
knownhosts.c
legacy.c
log.c
match.c
messages.c
misc.c
options.c
packet.c
packet_cb.c
packet_crypt.c
pcap.c
pki.c
pki_container_openssh.c
pki_ed25519.c
poll.c
session.c
scp.c
socket.c
string.c
threads.c
wrapper.c
external/bcrypt_pbkdf.c
external/blowfish.c
external/chacha.c
external/ed25519.c
external/fe25519.c
external/ge25519.c
external/poly1305.c
external/sc25519.c
chachapoly.c
)

if (CMAKE_USE_PTHREADS_INIT)
set(libssh_SRCS
${libssh_SRCS}
threads/noop.c
threads/pthread.c
)
elseif (CMAKE_USE_WIN32_THREADS_INIT)
set(libssh_SRCS
${libssh_SRCS}
threads/noop.c
threads/winlocks.c
)
else()
set(libssh_SRCS
${libssh_SRCS}
threads/noop.c
)
endif()

if (WITH_GCRYPT)
set(libssh_SRCS
${libssh_SRCS}
threads/libgcrypt.c
libgcrypt.c
gcrypt_missing.c
pki_gcrypt.c
ecdh_gcrypt.c
)
elseif (WITH_MBEDTLS)
set(libssh_SRCS
${libssh_SRCS}
threads/mbedtls.c
libmbedcrypto.c
mbedcrypto_missing.c
pki_mbedcrypto.c
ecdh_mbedcrypto.c
)
else (WITH_GCRYPT)
set(libssh_SRCS
${libssh_SRCS}
threads/libcrypto.c
pki_crypto.c
ecdh_crypto.c
libcrypto.c
)
if(OPENSSL_VERSION VERSION_LESS "1.1.0")
set(libssh_SRCS ${libssh_SRCS} libcrypto-compat.c)
endif()
endif (WITH_GCRYPT)

if (WITH_SFTP)
set(libssh_SRCS
${libssh_SRCS}
sftp.c
)

if (WITH_SERVER)
set(libssh_SRCS
${libssh_SRCS}
sftpserver.c
)
endif (WITH_SERVER)
endif (WITH_SFTP)

if (WITH_SERVER)
set(libssh_SRCS
${libssh_SRCS}
server.c
bind.c
)
endif (WITH_SERVER)

if (WITH_ZLIB)
set(libssh_SRCS
${libssh_SRCS}
gzip.c
)
endif(WITH_ZLIB)

if (WITH_GSSAPI AND GSSAPI_FOUND)
set(libssh_SRCS
${libssh_SRCS}
gssapi.c
)
endif (WITH_GSSAPI AND GSSAPI_FOUND)

if (NOT WITH_NACL)
set(libssh_SRCS
${libssh_SRCS}
external/curve25519_ref.c
)
endif (NOT WITH_NACL)

include_directories(
${LIBSSH_PUBLIC_INCLUDE_DIRS}
${LIBSSH_PRIVATE_INCLUDE_DIRS}
)

# Set the path to the default map file
set(MAP_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.map")

if (WITH_SYMBOL_VERSIONING AND ABIMAP_FOUND)
# Get the list of header files
get_file_list("dev_header_list"
DIRECTORIES "${LIBSSH_PUBLIC_INCLUDE_DIRS}/libssh"
FILES_PATTERNS "*.h")

# Extract the symbols marked as "LIBSSH_API" from the header files
extract_symbols("${PROJECT_NAME}_dev.symbols"
HEADERS_LIST_FILE "dev_header_list"
FILTER_PATTERN "LIBSSH_API")

if (WITH_ABI_BREAK)
set(ALLOW_ABI_BREAK "BREAK_ABI")
endif()

# Generate the symbol version map file
generate_map_file("${PROJECT_NAME}_dev.map"
SYMBOLS "${PROJECT_NAME}_dev.symbols"
RELEASE_NAME_VERSION ${PROJECT_NAME}_AFTER_${LIBRARY_VERSION}
CURRENT_MAP ${MAP_PATH}
${ALLOW_ABI_BREAK})

set(libssh_SRCS
${libssh_SRCS}
${PROJECT_NAME}_dev.map
)
endif (WITH_SYMBOL_VERSIONING AND ABIMAP_FOUND)

add_library(${LIBSSH_SHARED_LIBRARY} SHARED ${libssh_SRCS})

target_link_libraries(${LIBSSH_SHARED_LIBRARY} ${LIBSSH_LINK_LIBRARIES})

if (WITH_SYMBOL_VERSIONING)
if (ABIMAP_FOUND)
# Change path to devel map file
set(MAP_PATH "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_dev.map")
endif (ABIMAP_FOUND)

set_target_properties(${LIBSSH_SHARED_LIBRARY}
PROPERTIES LINK_FLAGS
"-Wl,--version-script,\"${MAP_PATH}\"")
endif (WITH_SYMBOL_VERSIONING)

set_target_properties(
${LIBSSH_SHARED_LIBRARY}
PROPERTIES
VERSION
${LIBRARY_VERSION}
SOVERSION
${LIBRARY_SOVERSION}
OUTPUT_NAME
ssh
DEFINE_SYMBOL
LIBSSH_EXPORTS
)

if (WITH_VISIBILITY_HIDDEN)
set_target_properties(${LIBSSH_SHARED_LIBRARY} PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
endif (WITH_VISIBILITY_HIDDEN)

if (MINGW)
set_target_properties(${LIBSSH_SHARED_LIBRARY} PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup")
endif ()


install(
TARGETS
${LIBSSH_SHARED_LIBRARY}
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
COMPONENT libraries
)

if (WITH_STATIC_LIB)
add_library(${LIBSSH_STATIC_LIBRARY} STATIC ${libssh_SRCS})

if (MSVC)
set(OUTPUT_SUFFIX static)
else (MSVC)
set(OUTPUT_SUFFIX )
endif (MSVC)
set_target_properties(
${LIBSSH_STATIC_LIBRARY}
PROPERTIES
VERSION
${LIBRARY_VERSION}
SOVERSION
${LIBRARY_SOVERSION}
OUTPUT_NAME
ssh
ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_SUFFIX}
)

if (WIN32)
set_target_properties(
${LIBSSH_STATIC_LIBRARY}
PROPERTIES
COMPILE_FLAGS
"-DLIBSSH_STATIC"
)
endif (WIN32)

install(
TARGETS
${LIBSSH_STATIC_LIBRARY}
DESTINATION
${LIB_INSTALL_DIR}/${OUTPUT_SUFFIX}
COMPONENT
libraries
)
endif (WITH_STATIC_LIB)

message(STATUS "Threads_FOUND=${Threads_FOUND}")

**

最佳答案

警告

No cmake_minimum_required command is present.

通常表示 错误的源目录使用,和 CMakeLists.txt在配置过程中,这个目录不应该是顶级目录。

在给定的情况下,您使用 src/子目录作为源,但正确的方法是使用上面的, C:\Users\Sami\Downloads\libssh-0.8.0.tar\libssh-0.8.0 .

妥妥的顶级 CMakeLists.txt包含 cmake_minimum_required调用并定义 CMakeLists.txt 所需的所有变量在子目录中。

关于visual-c++ - CMakeLists.txt 中的 CMake Warning (dev) : No cmake_minimum_required command is present. 一行代码如 cmake_minimum_required(VERSION 3.9),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52255075/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com