添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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
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.

so i'll answer this question myself again as i need more space than the comment allows.

The "something obvious" i've missed is that i accessed those values before invocation of "project(Foo)", and at that stage CMAKE_FIND_LIBRARY_PREFIXES and CMAKE_FIND_LIBRARY_SUFFIXES are not initialized yet. good to know in any case!

I was checking conditions on whether the main project could be built at all, and that involved checking if the cmake version is new enough and should be downloaded&built before anything further. on the other side, by cmake convention, you need to specify which minimum version you need before you issue any project commands. you see the deadlock there? so if i needed to build a newer cmake version on-the-fly, OpenSSL should be included if possible. this was detected using find_package(OpenSSL), but that in turn accessed the un-initialized CMAKE_FIND_LIBRARY_PREFIXES and everything broke.

you see the deadlock there? actually no, I don't see :) When you, for example, set minimum version to 2.8 it will work for both 2.8 and 3.1. To check the exact version of cmake you can use CMAKE_VERSION variable. – user2288008 Feb 1, 2015 at 12:33 Yes. Im already using a lower version check before and a dummy project to have it work. I was trying to explain how it got to that situation, mayhaps not the right way. Sorry! – daniel.wirtz Feb 1, 2015 at 12:54

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.