Default Values ​​for CMAKE_FIND_LIBRARY_PREFIXES / CMAKE_FIND_LIBRARY_SUFFIXES

I think I missed something very obvious here, but it seems to me that the cmake variables CMAKE_FIND_LIBRARY_PREFIXES/CMAKE_FIND_LIBRARY_SUFFIXES not set to any "decent" default value depending on the current system / settings! I checked the cmake and google docs, but there is nothing about that.

for example, a simple CMakeLists.txt, essentially calling find_package(OpenSSL REQUIRED) , will be broken if you do not set the variables in your main file or call cmake -DCMAKE_FIND_LIBRARY_PREFIXES=lib -DCMAKE_FIND_LIBRARY_SUFFIXES=.so .. (on cmake -DCMAKE_FIND_LIBRARY_PREFIXES=lib -DCMAKE_FIND_LIBRARY_SUFFIXES=.so .. libssl-dev) on the other hand, the default values ​​of PREFIX / SUFFIX for the purposes are initialized “correctly” for each platform, even considering BUILD_SHARED_LIBS, etc., why not find_library?

Does anyone know why / what should be suggested (by users)?

+3
cmake prefix platform
source share
2 answers

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

Why do you think so? For example:

 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 

the find_package (OpenSSL REQUIRED) call is interrupted if you do not set the variables in your main file

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

+4
source share

therefore, I will answer this question again, since I need more space than the comment allows.

The “something obvious” I missed was that I accessed these values ​​before calling “project (Foo),” and at this point CMAKE_FIND_LIBRARY_PREFIXES and CMAKE_FIND_LIBRARY_SUFFIXES have not yet been initialized. good to know anyway!

I checked the conditions on whether it is possible to create the main project at all, and also check if the new version of cmake is enough and should be downloaded and created before anything else. on the other hand, under the cmake convention, you need to specify which minimum version you need before you issue any project commands. do you see a dead end there? therefore, if I needed to build a new version of cmake on the fly, OpenSSL should be enabled, if possible. it was discovered with find_package(OpenSSL) , but it, in turn, gained access to the un-initialized CMAKE_FIND_LIBRARY_PREFIXES and it all broke.

+2
source share

All Articles