cURL / Mailing Lists / curl-library / Single Mail

curl-library

[PATCH] CMake build improvements

From: Tetetest <tetetest_at_rambler.ru>
Date: Thu, 28 Apr 2011 00:51:11 +0400

Hello all,

  Recently I tried to build curl using CMake. My goal was to get
static libcurl library, with zlib and openssl support (both libraries
were also built static). Of course there were problems, and some of
them were related to CMake buildchain:

1. CHECK_FUNCTION_EXISTS_CONCAT() macro. It had two main problems:

1.1 To check if a function exists in a library, it used try_compile()
    with the list of libraries like this:
    -llib_to_check -lother -llibs -lthat -lwere -found -lbefore
    
    Note that the library is in the front of the list.
    Then, if the check succeeded, it APPENDED the library to the list,
    which produced a reversed list of libraries!
    
    This is not a big problem when you use shared libraries (or DLLs
    under Windows), but when you link with static libraries, the order
    of libraries is of vital importance.

1.2 Another problem: only default system paths were used to search the
    library. No matter how many paths you added to CMAKE_LIBRARY_PATH
    variable (which is supposed to affect library searches) - the
    macro would not see a library if it was not in the system library
    path.

2. Order of checks: openssl was checked before zlib.

   This caused openssl checks to fail because openssl was built with
   zlib support, but -lz was not passed to linker.

The attached patch fixes both of the problems.

There was also a build problem on Solaris: when building with CMake
from distribution tarball, I got errors about unsupported
non-configure capable system. That came from "generic"
include/curl/curlbuild.h file that comes with the distribution.

So, I have also added a notice to docs/INSTALL.cmake, warning CMake
users about potential problems with this file.

As a bonus, the patch adds basic 'install' capability to CMake build.
Currently, only libcurl, curl binary, and headers are installed, but
at least it is a start.

-- 
Best regards,
 Tetetest                          mailto:tetetest_at_rambler.ru


-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2011-04-27