E
E
Egorithm2020-07-20 23:41:32
CMake
Egorithm, 2020-07-20 23:41:32

How to force CMake to look for a library of the required bitness through find_package?

I collected x86 and x64 , moreover, it did not work in one directory. CMake gave an error when trying to configure a different bit depth (relative to the previous one). I need to somehow choose the directory to search for OpenCVConfig.cmake via find_package(), i.e. add it to CMAKE_PREFIX_PATHvisible. I looked as far as possible through FIND_LIBRARY_USE_LIB32_PATHSand FIND_LIBRARY_USE_LIB64_PATHS, but this is no good, there are no lib32 and lib64 directories , only lib. It may be possible to combine them manually, but I'm not sure that I will do everything right. Outside x86/x64 directoriesI found one small difference =) (see screenshot). It may be possible to add both paths there, but again, I'm not sure if this will work out (maybe after that it will take the first one it comes across, and not the right one). In short, how would you do it?
5f1600f4ebbcd909356741.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Egorithm, 2020-07-21
@EgoRusMarch

So here's how it works:

if (${CMAKE_SIZEOF_VOID_P} STREQUAL 4)
    message("It's 32 bit build")
elseif (${CMAKE_SIZEOF_VOID_P} STREQUAL 8)
    message("It's 64 bit build")
endif ()

S
Stanislav Makarov, 2020-07-21
@Nipheris

I collected x86 and x64, moreover, it did not work in one directory.

Do not need. Personally, I think this is a perversion (several configurations in one shared folder), forcing you to invent naming conventions and all sorts of layouts for subfolders, which everyone then has their own, cycling.
I need to somehow select the directory to search for OpenCVConfig.cmake via find_package(), i.e. add it to CMAKE_PREFIX_PATH apparently.

Not bad idea. And why didn't it work?
In general, in theory, the library config (which is OpenCVConfig.cmake) should check the bit depth and prevent the library from being connected with invalid bit depth. In theory, then several paths can be specified (not sure, you need to check).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question