Hello, On Wed, Oct 26, 2011 at 10:02:04AM +0200, David van der Spoel wrote:
I'm using CLN within a large software package and trying to build it with cmake. Just before I put a lot of effort in it, did someone try to make a "Findcln.cmake" script already? It would help to have pkg-config support for this as well, e.g. to get the gmp library linked in automatically.
include(FindPkgConfig) pkg_check_modules(cln REQUIRED cln>=1.2.2) include_directories(${cln_INCLUDE_DIRS}) link_directories({cln_LIBRARY_DIRS}) # On ELF systems (such as GNU/Linux) this prevents the infamous `error # while loading shared libraries: libfoo.so: cannot open shared object # file: no such file or directory' set(CMAKE_INSTALL_RPATH_USE_LINK_RPATH TRUE) list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${cln_LIBRARY_DIRS}" isSystemDir) if("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:${cln_LIBRARY_DIRS}") endif() # Tell CMake to link target(s) with CLN target_link_libraries(hello ${cln_LIBRARIES}) Note: the above code is rather unorthodox, as CMake refers libraries by their absolute path, and does not trust pkg-config (I don't think any of these is a good idea, but that's how things work with CMake). Also, rpath should be configurable (so whoever makes deb/rpm packages won't write you hate mails), etc.
If no-one did it before I will do it myself. It would be nice if it got incorporated in the cln distribution in that case.
I'm working on CMake based build system for GiNaC (and CLN), Find* will be written as a side effect. Best regards, Alexei