[CMake] Nonstandard architectures.
Dizzy
dizzy at roedu.net
Thu Sep 27 05:33:27 EDT 2007
On Thursday 27 September 2007 12:12:56 Mathias Froehlich wrote:
> Hi,
Hello
> I have problems with nonstandard architectures.
>
> cmakes mechanism to see if some package is installed usually just looks if
> some files are present. That is good as long as you just compile for the
> standard architecture on a specific operating system.
>
> But if I build for some non default architecture (for example for 64 bit pa
> risc instead of the 32 bit default one). Most configury checks will not
> find the truth.
> For example, In my amd64 linux system we have a /usr/local/lib/libglut.so.
> so the FIND_PACKAGE(GLUT) will see: 'ah we have glut available!'. But when
> I build for emt64, this is just wrong, because I do not have the
> equivalent /usr/local/lib64/libglut.so installed ...
FIND_PACKAGE(GLUT) will use FindGLUT.cmake as it's made and it does not have
to fit every need, you can provide your own FindGLUT.cmake in a local project
cmake modules directory to override the default one (I do that with ZLIB).
Also generally, FIND_LIBRARY(), FIND_FILE() (which are generally used in
FindPackage scripts) are both configurable setting some variables for the
paths (see the cmake man page on them).
> Old autoconf used to check existence of libraries by compiling a small test
> example with the configured compiler and link against that library in
> question. In contrast to cmake that just looks for the existence of files.
Yes (but cmake has that too).
> This way one could be sure that this fits together.
> This would be for sure one solution to that problem.
So then use such a check instead of FIND_LIBRARY() (that locates files only).
CMake comes with many modules that can be used to test-compile, but there is
one specifically for your case, namely CHECK_LIBRARY_EXISTS().
> An other one would be to use the 'correct' standard librarie paths for
> different architectures. But that means that cmake will need to know more
> about the ABI in use. Currently this is not required to know.
In your example, the native arch it's x86-64 or x86? And then you are
compiling for a target x86 or x86-64?
I would not like to have cmake do very strict checks such as autoconf by
default, because then we will get the same speed as with autoconf (which was
very slow) and you generally don't need those strict checks. I would like to
have it both, so you can do both fast checks (checking for existence of
files) and compile-test checks (checking if it actually compiles) in a
configurable way. So maybe there should be a new attribute to FIND_PACKAGE()
(as we have the REQUIRED attribute) say named "STRICT" and have code in
FindPackage modules that when STRICT is present there will also be a
test-compile check done (using CHECK_LIBRARY_EXISTS and such) on the found
library.
--
Mihai RUSU Email: dizzy at roedu.net
"Linux is obsolete" -- AST
More information about the CMake
mailing list