[CMake] Preventing search for libraries in random prefixes

Mojca Miklavec mojca at macports.org
Thu Jun 26 16:56:09 EDT 2014


Hi,

In our package manager where it is of crucial importance to link
against the proper library we often end up with hardcoding lots and
lots of options, like:

-DOPENGL_INCLUDE_DIR=${prefix}/include \
-DX11_ICE_INCLUDE_PATH=${prefix}/include \
-DX11_SM_INCLUDE_PATH=${prefix}/include \
-DX11_X11_INCLUDE_PATH=${prefix}/include \
-DX11_Xext_INCLUDE_PATH=${prefix}/include \
-DX11_Xft_INCLUDE_PATH=${prefix}/include \
-DX11_Xpm_INCLUDE_PATH=${prefix}/include \
-DX11_ICE_LIB=${prefix}/lib/libICE.dylib \
-DX11_SM_LIB=${prefix}/lib/libSM.dylib \
-DX11_X11_LIB=${prefix}/lib/libX11.dylib \
-DX11_Xext_LIB=${prefix}/lib/libXext.dylib \
-DX11_Xft_LIB=${prefix}/lib/libXft.dylib \
-DX11_Xpm_LIB=${prefix}/lib/libXpm.dylib \
-DOPENGL_gl_LIBRARY=${prefix}/lib/libGL.dylib \

With autotools that usually boiled down to just:
    --with-x=${prefix}

My question: is there any way to tell CMake the following?

"Please don't search for any libraries or headers from /sw or /usr/X11
or /opt/local or anything, I really really want you to search for the
libraries in /my/special/prefix and only there".

A while back a user asked for removing /sw from CMake Find<Foo>
modules because that caused him problems. But I would like to
understand the general policy about this.

See:
    https://trac.macports.org/ticket/41817

I like that fact that CMake eventually offers more flexibility, but it
makes it a bit painful to ensure that exactly the right libraries are
used. I'm sure that I'm missing something though, so I would like to
understand how to handle this properly.

Thank you,
    Mojca


More information about the CMake mailing list