Ticket #1203 (new defect)

Opened 5 years ago

Last modified 4 years ago

Do not add "AND NOT PKG_CONFIG_FOUND" in cmake modules

Reported by: scriptor Owned by: bricks
Priority: normal Milestone: OpenSync 0.40
Component: OpenSync: Build Environment Version: 0.39
Severity: minor Keywords: cmake modules and pkg-config in cross-compiling scenarios
Cc:

Description

Hello,

many cmake modules are written in this way:

(pkg-config looks for the library...)
(...)

# Look for libxml-2.0 include dir and libraries w/o pkgconfig
IF ( NOT LIBXML2_FOUND AND NOT PKG_CONFIG_FOUND )
(...)

(cmake itself searches for the library...)

ENDIF ( NOT LIBXML2_FOUND AND NOT PKG_CONFIG_FOUND )

So the pkg-config independent code can only be reached on systems without pkg-config.

But this code should also be executed on systems with pkg-config, if LIBXML2 could NOT be found. It should ALWAYS be executed, when the library in question can not be found. Regardless of whether or not pkg-config is installed.

Otherwise you get into trouble in some cross-compiling scenarios.

pkg-config does not work well in certain cross-compiling situations. Whereas cmake itself works much better in these cases, because cmake can be told about the library mapping when you compile for a different target.

So the build system must be able to search for the library in question without using pkg-config, even when pkg-config is installed.

I try and add two patches for those two cmake modules which have caused me some trouble. And to clarify what I mean...

Bye.

Attachments

FindLibXml2.cmake.diff (776 bytes) - added by scriptor 5 years ago.
Patch for cmake/modules/FindLibXml2.cmake
FindLibXslt.cmake.diff (755 bytes) - added by scriptor 5 years ago.
Patch for cmake/modules/FindLibXslt.cmake

Change History

Changed 5 years ago by scriptor

Patch for cmake/modules/FindLibXml2.cmake

Changed 5 years ago by scriptor

Patch for cmake/modules/FindLibXslt.cmake

comment:1 Changed 5 years ago by dgollub

Sounds sane to me. Just checked how the upstream versions (in cmake) of this modules look like. And indeed this line changed ... we should sync-up again with the cmake version.

In case of FindLibXml2.cmake one define changed and would require to get adapted to all plugins buildenv and to opensync buildenv:

LIBXML2_INCLUDE_DIRS turns to LIBXML2_INCLUDE_DIR

Same for FindLibXslt2.cmake:

LIBXSLT_INCLUDE_DIRS turns to LIBXSLT_INCLUDE_DIR

Björn, what do you think? Should we sync up and get again a copy of the cmake project? Could you check if this doesn't break the build on mac-os-x? scriptor, could you check if the original find modules with the latest cmake version works for you?

comment:2 Changed 5 years ago by dgollub

  • Severity changed from normal to minor
  • Milestone set to OpenSync 0.40

comment:3 Changed 4 years ago by scriptor

Hello - yes, the new modules as shipped with cmake-2.6.4 work for me, even when I cross-compile. Most of the plugins and format plugins will have to adjust their paths, as you already described it.

It is not that many modules, that are actually new, at least not with cmake-2.6.4: FindLibXml2.cmake, FindLibXslt?.cmake, FindPkgConfig?.cmake, FindQt4.cmake and FindSWIG.cmake.

The upstream site may have even newer modules, which I haven't tried, yet.

Bye, bye,

Juergen

Note: See TracTickets for help on using tickets.