[CMake] Help with libintl/configure tests
Tim Holy
holy at wustl.edu
Thu Apr 24 22:25:39 EDT 2008
Hi Bill,
OK, I think I understand better. The whole problem can be illustrated with
this simple CMakeLists.txt file:
include(CheckTypeSize)
include(CheckIncludeFile)
# Block_begin
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)
# Block_end
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_type_size(intmax_t INTMAX_T)
message("HIT ${HAVE_INTMAX_T}, IT ${INTMAX_T}")
This file can be created with the write permission off (so that we can easily
delete everything except this file), then
rm -r *
cmake .
If I omit the steps between Block_begin and Block_end, I get unpredictable
behavior; usually the existence of intmax_t is disputed (unless running with
debug-trycompile), other times it claims to be found but of size 0, and still
other times it finds a non-zero size.
But with the include file checks in place it works reliably to yield an object
of size 8.
Thanks for the tips; just as you suggested, I figured it out by looking at the
CheckSymbolExists.c file. I don't understand _why_ it fails sporadically, but
at least I know how to keep it from doing so.
Would it be sensible to have CMake issue a warning in case you're compiling a
test for which a #define variable has not been set?
Thanks,
--Tim
On Thursday 24 April 2008, you wrote:
> Tim Holy wrote:
> > On Wednesday 23 April 2008, you wrote:
> >>> So, I don't understand why this isn't discovering that these types have
> >>> been declared. Can anyone offer some insight?
> >>
> >> Best thing to do is to use --debug-trycompile.
> >
> > Thanks for the tip. The outcome, however, is not at all what I expected.
> > Check this out (sorry that the line wrapping will make the shell command
> > look weird):
>
> Not totally unexpected as we clean the directory for a reason...
>
> So, what you want to try is this:
>
> tim at diva:/tmp/build-intl$ rm -r *
> tim at diva:/tmp/build-intl$ cmake ~/src/tux4kids/tuxmath/trunk/intl/
>
> Now, edit the CMakeCache.txt file and remove the references to uintmax
> in the cache.
>
> Then do this:
> tim at diva:/tmp/build-intl$ cmake --debug-trycompile
> ~/src/tux4kids/tuxmath/trunk/intl/
>
>
> This will cause cmake to only run the one test and it should leave the
> source code for the test in CMakeFiles/CMakeTmp. You can then go look
> at the source code and try to compile it by hand.
>
>
> But, actually, looking at your CMakeError.log I don't think you have to
> do that...
>
> You have this:
>
> Determining if the intmax_t exist failed with the following output:
> /usr/bin/make -f CMakeFiles/cmTryCompileExec.dir/build.make
> CMakeFiles/cmTryCompileExec.dir/build
> make[1]: Entering directory `/tmp/build-intl/CMakeFiles/CMakeTmp'
> /usr/bin/cmake -E cmake_progress_report
> /tmp/build-intl/CMakeFiles/CMakeTmp/CMakeFiles 1
> Building C object CMakeFiles/cmTryCompileExec.dir/CheckSymbolExists.o
> /usr/bin/gcc -o CMakeFiles/cmTryCompileExec.dir/CheckSymbolExists.o
> -c /tmp/build-intl/CMakeFiles/CMakeTmp/CheckSymbolExists.c
> /tmp/build-intl/CMakeFiles/CMakeTmp/CheckSymbolExists.c: In
> function â€$(0ma(Binâ€$(1:
> (B/tmp/build-intl/CMakeFiles/CMakeTmp/CheckSymbolExists.c:8: error:
> expected expression before â€$(0in(Btmax_tâ€$(1
> m(Bake[1]: *** [CMakeFiles/cmTryCompileExec.dir/CheckSymbolExists.o]
> Error 1
> make[1]: Leaving directory `/tmp/build-intl/CMakeFiles/CMakeTmp'
> make: *** [cmTryCompileExec/fast] Error 2
>
> File /tmp/build-intl/CMakeFiles/CMakeTmp/CheckSymbolExists.c:
> /* */
> #include <stdint.h>
>
> void cmakeRequireSymbol(int dummy,...){(void)dummy;}
> int main()
> {
> #ifndef intmax_t
> cmakeRequireSymbol(0,&intmax_t);
> #endif
> return 0;
> }
>
>
> So, create your own file CheckSymbolExists.c with the above contents and
> then compile it like this:
>
> /usr/bin/gcc -o foo.o -c CheckSymbolExists.c
>
> -Bill
More information about the CMake
mailing list