[CMake] Preventing search for libraries in random prefixes

Mojca Miklavec mojca at macports.org
Fri Jun 27 05:26:45 EDT 2014


On Fri, Jun 27, 2014 at 10:42 AM, Angeliki Chrysochou wrote:
> Hi Mojca,
>
> From what I know cmake will look for libraries in the directories specified
> in link_directories(${LIBRARY_DIRS}) and for headers in the directories
> specified in include_directories(${INCLUDE_DIRS}) and the property
> INCLUDE_DIRECTORIES.
>
> http://www.cmake.org/cmake/help/v2.8.8/cmake.html#command:link_directories
>
> http://www.cmake.org/cmake/help/v2.8.8/cmake.html#command:include_directories

The problem is that some files like FindGTK2.cmake explicitly specify
additional (undesired) search paths, for example:

    find_path(GTK2_${_var}_INCLUDE_DIR ${_hdr}
        PATHS
            ${_gtk2_arch_dir}
            /usr/local/lib64
            /usr/local/lib
            /usr/lib64
            /usr/lib
            /opt/gnome/include
            /opt/gnome/lib
            /opt/openwin/include
            /usr/openwin/lib
            /sw/include
            /sw/lib
            /opt/local/include
            /opt/local/lib
            /usr/pkg/lib
            /usr/pkg/include/glib
            $ENV{GTKMM_BASEPATH}/include
            $ENV{GTKMM_BASEPATH}/lib
            [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/include
            [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
            [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/include
            [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
        PATH_SUFFIXES
            ${_suffixes}
    )

I would like to get rid of those.

Mojca

> On Thu, Jun 26, 2014 at 10:56 PM, Mojca Miklavec <mojca at macports.org> wrote:
>>
>> 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