<br>This is a discussion about how to code module search paths, with regard to distribution porting of cmake. The examples below use MacPorts only because that's what I'm working with at the moment. The issue applies to any port of cmake on a specific distribution system (MacPorts, Fink, debian, freebsd, ubuntu, redhat, etc.).<br>
<br>The main PREFIX on MacPorts is /opt/local/. This will list all the module files that contain /opt/local for an installation of cmake 2.6 on MacPorts:
<div class="comment searchable">
<pre class="wiki">$ grep -C3 ".*/opt/local.*" /opt/local/share/cmake-2.6/Modules/*.cmake<br></pre><p>
Not all the .cmake files contain this prefix. Moreover, even when the /opt/local prefix is in a module search path, it doesn't resolve an issue of path precedence. For example:
</p>
<pre class="wiki">/opt/local/share/cmake-2.6/Modules/Findosg_functions.cmake- PATH_SUFFIXES lib64 lib<br>/opt/local/share/cmake-2.6/Modules/Findosg_functions.cmake- PATHS<br>/opt/local/share/cmake-2.6/Modules/Findosg_functions.cmake- /sw # Fink<br>
/opt/local/share/cmake-2.6/Modules/Findosg_functions.cmake: /opt/local # DarwinPorts<br>/opt/local/share/cmake-2.6/Modules/Findosg_functions.cmake- /opt/csw # Blastwave<br>/opt/local/share/cmake-2.6/Modules/Findosg_functions.cmake- /opt<br>
/opt/local/share/cmake-2.6/Modules/Findosg_functions.cmake- /usr/freeware<br></pre><p>
Here, the path precedence favors the main alternative to MacPorts for
open-source ports on OSX - Fink. If anyone has both Fink and MacPorts
installed, any of their MacPorts cmake builds that require
any such module could link against a Fink library because it appears higher in the
module path precedence (even when /opt/local is in the module search
path). The same argument applies in reverse if the module shuffles around these paths to favor MacPorts over Fink (or some other distribution) in the search path precedence.
</p>
<p>I'm not aware of a cmake build-time config variable that allows
distros to set a specific module search path. That would be really
neat! Maybe something like the following when building cmake:
</p>
<pre class="wiki">-D CMAKE_MODULE_PREFIX_PATH:STRING=/opt/local;/usr/local;/usr<br>-D CMAKE_MODULE_INCLUDE_PATH:STRING=/opt/local/include;/usr/local/include;/usr/include<br>-D CMAKE_MODULE_LIBRARY_PATH:STRING=/opt/local/lib;/usr/local/lib;/usr/lib;/usr/lib64<br>
</pre><p>If something like this could be defined, then module .cmake files could use these cmake variables to define their search paths, rather than
have them hard-coded in the module files. If these variables are not set explicitly, some common fallback paths must be set.<br></p>
<p>
Darren
</p>
</div><br>PS, see this ticket for further details on this issue for MacPorts:<br><a href="http://trac.macports.org/ticket/19781">http://trac.macports.org/ticket/19781</a><br><br>