cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re[2]: cmake

From: Tetetest <tetetest_at_rambler.ru>
Date: Wed, 15 Apr 2009 22:18:36 +0400

Hello Daniel,

Wednesday, April 15, 2009, 5:06:35 PM, you wrote:

DS> On Wed, 15 Apr 2009, Tetetest wrote:

>> DS> 2. What's the purpose of CMake/Platforms/config-aix.h ?
>>
>> This is a legacy file that goes with CMake itself. I didn't check if it is
>> really needed.

DS> So we remove that and see if things go boom?

On AIX, they will more or less certainly go boom. :)
Other platforms are more or less certainly not affected by this file.

>> DS> /home/daniel/src/curl-alt/lib/config.h:375:1: warning: "HAVE_LIBZ" redefined
>>
>> Basically, CMake builds must use generated config.h file.

DS> But why does it use leftovers from before? That seems like a bug!

Those 'leftovers' are not used by normal, out-of-source CMake build.
The only situation they get in your way is when you build in-source
(which is possible with CMake, albeit strongly NOT recommended).

The consequences of in-source builds include:
- auto-generated files may not get updated properly (especially if the
  file already exists in the source tree). This is exactly what
  happened with you.
- once you have attempted to build in-source, CMake creates cache
  files that instructs CMake to do in-source builds even if you try to
  build it out-of-source. This is exactly what happened with you
  afterwards:

DS> Clearly something is missing as that doesn't work for me:

DS> $ cmake --version
DS> cmake version 2.6-patch 3
DS> $ mkdir curl-cmake
DS> $ cd curl-cmake
DS> $ cmake ../curl-alt/
DS> -- Configuring done
DS> -- Generating done
DS> -- Build files have been written to: /home/daniel/src/curl-alt
DS> $ make
DS> make: *** No targets specified and no makefile found. Stop.

CMake sees CMakeCache files in your source tree, understands that it
must perform an in-source build, and generates Makefiles right into
the source tree.

To build out-of-source, you can remove CMakeCache.txt and repeat the
build. Or better, use a fresh clean source tree. :)

>> DS> Linking C executable curl
>> DS> CMakeFiles/curl.dir/curlutil.c.o: In function `cutil_tvnow':
>> DS> curlutil.c:(.text+0x15): undefined reference to `clock_gettime'
>> DS> collect2: ld returned 1 exit status
>>
>> Again, it looks like your build catches the wrong config.h :)

DS> Not exactly, that's the link phase that fails so a header file won't be used.
DS> It is a lack of use/detect of the correct lib, librt in this case. But they
DS> certainly seem related:

DS> Interestingly, if I remove src/config.h and lib/config.h before I run "cmake .
DS> && make" it seems to work!?

For CMake, overwriting an existing file with an auto-generated one is
a no-no. When you remove the file, CMake is happy to generate a new
one. That's why in-source builds are not recommended for CMake: you
cannot be sure that all files are generated properly.

DS> BTW: how do I provide additional config options when I build with cmake? Like
DS> "disable shared libs" and "enable debug mode" ?

Uhm... I usually change CMakeLists.txt and rebuild. :)
Or you can supply cmake with a '-D VARIABLE:TYPE=VALUE' construct on
the command-line. Like this:

cmake -D CMAKE_BUILD_TYPE:STRING=Debug ../curl-lib

-- 
Best regards,
 Tetetest                            mailto:tetetest_at_rambler.ru
Received on 2009-04-15