CMAKE_FIND_LIBRARY_PREFIXES / CMAKE_FIND_LIBRARY_SUFFIXES的默认值 [英] Default values for CMAKE_FIND_LIBRARY_PREFIXES/CMAKE_FIND_LIBRARY_SUFFIXES

查看:368
本文介绍了CMAKE_FIND_LIBRARY_PREFIXES / CMAKE_FIND_LIBRARY_SUFFIXES的默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我在这里遗漏了一些非常明显的东西,但是在我看来,cmake变量 CMAKE_FIND_LIBRARY_PREFIXES / CMAKE_FIND_LIBRARY_SUFFIXES 并未设置为任何适当的默认值,具体取决于在当前系统/设置上!我已经检查了cmake文档和google,但实际上似乎什么都没有。



例如,一个简单的CMakeLists.txt本质上调用了 find_package (需要OpenSSL)会中断,除非您在主文件中设置变量或直接调用 cmake -DCMAKE_FIND_LIBRARY_PREFIXES = lib -DCMAKE_FIND_LIBRARY_SUFFIXES = .so ... (在ubuntu w openssl / libssl-dev上安装)
,对于每个平台,目标的默认值PREFIX / SUFFIX都会正确初始化,即使考虑了BUILD_SHARED_LIBS等。为什么不为find_library设置?



有人知道为什么/建议的(用户)行为应该是什么吗?

解决方案

< blockquote>

cmake变量CMAKE_FIND_LIBRARY_PREFIXES / CMAKE_FIND_LIBRARY_SUFFIXES未设置为任何适当的默认值


为什么也这样觉得?例如:

  cmake_minimum_required(版本3.1)
项目(Foo)

消息( 前缀:$ {CMAKE_FIND_LIBRARY_PREFIXES})
消息(后缀:$ {CMAKE_FIND_LIBRARY_SUFFIXES})

Linux(Ubuntu):

 前缀:lib 
后缀:.so; .a

Mac:

 前缀:lib 
后缀:.dylib; .so; .a

Windows(Visual Studio):

 前缀:
后缀:.lib




除非您在主文件中设置了变量,否则调用find_package(需要OpenSSL)将中断


刚刚测试过,对我来说很好。 Ubuntu 14.04。 CMake 2.8.12.2和CMake 3.1.0-rc2。


i guess i'm missing something very obvious here, but it seems to me that the cmake variables CMAKE_FIND_LIBRARY_PREFIXES/CMAKE_FIND_LIBRARY_SUFFIXES are not set to any "decent" default value depending on the current system/settings! i've checked the cmake docs and google, but there seems nothing about it really.

for example, a simple CMakeLists.txt essentially calling find_package(OpenSSL REQUIRED) will break unless you set the variables in your main file or directly invoke cmake -DCMAKE_FIND_LIBRARY_PREFIXES=lib -DCMAKE_FIND_LIBRARY_SUFFIXES=.so .. (on ubuntu w openssl/libssl-dev installed) on the other hand, the default values PREFIX/SUFFIX for targets are initialized "correctly" for each platform, even considering BUILD_SHARED_LIBS etc. why not for find_library?

does anyone know why/what the suggested (users) behaviour should be?

解决方案

cmake variables CMAKE_FIND_LIBRARY_PREFIXES/CMAKE_FIND_LIBRARY_SUFFIXES are not set to any "decent" default value

Why do you think so? For instance:

cmake_minimum_required(VERSION 3.1)
project(Foo)

message("prefix: ${CMAKE_FIND_LIBRARY_PREFIXES}")
message("suffix: ${CMAKE_FIND_LIBRARY_SUFFIXES}")

Linux (Ubuntu):

prefix: lib
suffix: .so;.a

Mac:

prefix: lib
suffix: .dylib;.so;.a

Windows (Visual Studio):

prefix:
suffix: .lib

calling find_package(OpenSSL REQUIRED) will break unless you set the variables in your main file

Just tested, works fine for me. Ubuntu 14.04. CMake 2.8.12.2 and CMake 3.1.0-rc2.

这篇关于CMAKE_FIND_LIBRARY_PREFIXES / CMAKE_FIND_LIBRARY_SUFFIXES的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆