Hi Robert, Hi osg cmake maintainer
I See today in my work that in cmake, the FIND_PATH command
search in a special order the path, and this order is not intuitive.
The problem is, I have osg includes installed in /usr/include and
in $OSG_HOME, and I want to build an application with includes in
$OSG_HOME.
with the command
FIND_PATH(OSG_INCLUDE_DIR osg/Node
PATHS $OSG_HOME/include
/usr/include
/usr/local/include)
in the Findosg.cmake of the application, includes used are the
/usr/include/osg
and not the $OSG_HOME/include/osg .... what's bad ??
cmake documentation say :
FIND_FILE(
<VAR>
name | NAMES name1 [name2 ...]
PATHS path1 [path2 ... ENV var]
[PATH_SUFFIXES suffix1 [suffix2 ...]]
[DOC "cache documentation string"]
[NO_DEFAULT_PATH]
[NO_CMAKE_ENVIRONMENT_PATH]
[NO_CMAKE_PATH]
[NO_SYSTEM_ENVIRONMENT_PATH]
[NO_CMAKE_SYSTEM_PATH]
)
If NO_DEFAULT_PATH is specified, then no additional paths are added to
the search. If NO_DEFAULT_PATH is not specified, the search process is
as follows:
1. Search cmake specific environment variables. This can be skipped
if NO_CMAKE_ENVIRONMENT_PATH is passed.
CMAKE_FRAMEWORK_PATH
CMAKE_APPBUNDLE_PATH
CMAKE_INCLUDE_PATH
2. Search cmake variables with the same names as the cmake specific
environment variables. These are intended to be used on the command
line with a -DVAR=value. This can be skipped if NO_CMAKE_PATH is
passed.
CMAKE_FRAMEWORK_PATH
CMAKE_APPBUNDLE_PATH
CMAKE_INCLUDE_PATH
3. Search the standard system environment variables. This can be
skipped if NO_SYSTEM_ENVIRONMENT_PATH is an argument.
PATH
INCLUDE
4. Search cmake variables defined in the Platform files for the
current system. This can be skipped if NO_CMAKE_SYSTEM_PATH is passed.
CMAKE_SYSTEM_FRAMEWORK_PATH
CMAKE_SYSTEM_APPBUNDLE_PATH
CMAKE_SYSTEM_INCLUDE_PATH
5. Search the paths specified after PATHS or in the short-hand version
of the command.
On Darwin or systems supporting OSX Frameworks, the cmake variable
CMAKE_FIND_FRAMEWORK can be set to empty or one of the following:
"FIRST" - Try to find frameworks before standard
libraries or headers. This is the default on Darwin.
"LAST" - Try to find frameworks after standard
libraries or headers.
"ONLY" - Only try to find frameworks.
"NEVER". - Never try to find frameworks.
On Darwin or systems supporting OSX Application Bundles, the cmake
variable CMAKE_FIND_APPBUNDLE can be set to empty or one of the
following:
"FIRST" - Try to find application bundles before standard
programs. This is the default on Darwin.
"LAST" - Try to find application bundles after standard
programs.
"ONLY" - Only try to find application bundles.
"NEVER". - Never try to find application bundles.
The reason the paths listed in the call to the command are searched
last is that most users of CMake would expect things to be found first
in the locations specified by their environment. Projects may override
this behavior by simply calling the command twice:
FIND_FILE(<VAR> NAMES name PATHS paths NO_DEFAULT_PATH)
FIND_FILE(<VAR> NAMES name)
Once one of these calls succeeds the result variable will be set and
stored in the cache so that neither call will search again.
-----
So just add NO_CMAKE_SYSTEM_PATH or most restrictive NO_DEFAULT_PATH
solve the problem.
This is same thing for all OpenSceneGraph/CMakeModules/Find*.cmake
which specify a non-standard path (like a environment variable) in the
FIND_PATH or FIND_LIBRARY command.
This put me to look the "cmake variables defined in the Platform files
for the current system". I am surprised when I found all path we
generally give to the FIND_PATH and FIND_LIBRARY command:
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/include
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
all this path are in the CMAKE_SYSTEM_FRAMEWORK_PATH or
CMAKE_SYSTEM_INCLUDE_PATH variable.
So, Why we didn't use the way describe in the cmake documentation?
FIND_FILE(<VAR> NAMES name PATHS paths NO_DEFAULT_PATH)
FIND_FILE(<VAR> NAMES name)
and trust in cmake for the plateform-specific path.
but some one are missing :
/opt/csw/include # Blastwave
/usr/freeware/include
/usr/freeware/lib64
It is a cmake bug ??
Perhaps for /opt/csw/include, I only found /opt/csw/lib in
cmake/Modules/Plateform/UnixPaths.cmake
But /usr/freeware/ look like a custome path, isn't it ? (i found it in
some OpenSceneGraph/CMakeModules/Find*.cmake)
I didn't post in osg-submissions because I don't know which solution to choose.
So what solution did you want to use ? Robert ?? osg cmake maintainer ??
Best Regards
David Callu
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/