For the lib32 paths: If you pass -m32 in {C,CXX}FLAGS environment variables or pass it in -DCMAKE_{C,CXX}_FLAGS on the command-line, CMake would automatically detect a 32-bit build and disables searching in lib64 paths. The same is accomplished by setting the FIND_LIBRARY_USE_LIB64_PATHS
global property.
However, it still doesn't search in lib32 variants, only the generic lib directories. As lib contains 64-bit libraries on some distributions this will fail.
Curiously, CMake sometimes magically transforms /usr/lib/libfoobar.so paths into -lfoobar before generating the makefile, which will allow the linker to find the correct library. This didn't happen here for me.
For the lib32 paths: If you pass -m32 in {C,CXX}FLAGS environment variables or pass it in -DCMAKE_{C,CXX}_FLAGS on the command-line, CMake would automatically detect a 32-bit build and disables searching in lib64 paths. The same is accomplished by setting the FIND_LIBRARY_USE_LIB64_PATHS global property.
However, it still doesn't search in lib32 variants, only the generic lib directories. As lib contains 64-bit libraries on some distributions this will fail.
Curiously, CMake sometimes magically transforms /usr/lib/libfoobar.so paths into -lfoobar before generating the makefile, which will allow the linker to find the correct library. This didn't happen here for me.
There is a CMake bug report with a patch for this but it seems to have been abandoned.