libftdi Archives

Subject: Wrong pkg-config file generated by cmake when -DDOCUMENTATION=OFF

From: Maciej Grela <maciej.grela@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 20 Jun 2012 23:24:12 +0200
Hi,

when trying to build a package in Gentoo against libftdi I discovered,
that pkg-config cannot find a version for it. This was because the
build process generates an incorrect pkg-config file for libftdi:

grela@kraken ~/ftdi-git $ cat /usr/lib/pkgconfig/libftdi.pc
prefix=/usr
exec_prefix=/usr/bin
libdir=/usr/lib64
includedir=/usr/include/libftdi

Name: libftdi
Description: Library to program and control the FTDI USB controller
Requires:
Version:
Libs: -L${libdir} -lftdi -lusb
Cflags: -I${includedir}

grela@kraken ~/ftdi-git $

As you can see the "Version" field is not set preventing pkg-config
from working correctly. I found out, that this problem is happening
only when you build libftdi with -DDOCUMENTATION=OFF in the cmake
commandline. After checking CMakeLists.txt I found a fragment which
doesn't seem right:

# Documentation

option(DOCUMENTATION "Generate API documentation with Doxygen" ON)

find_package(Doxygen)
if(DOCUMENTATION AND DOXYGEN_FOUND)

   # Set variables
   set(PACKAGE libftdi)
   set(VERSION ${VERSION_STRING})
   set(top_srcdir ${CMAKE_SOURCE_DIR})

   # Find doxy config
   message(STATUS "Doxygen found.")
   set(DOXY_DIR "${CMAKE_SOURCE_DIR}/doc")
   set(DOXY_CONFIG "${DOXY_DIR}/Doxyfile.in")

When I moved the set(PACKAGE) and set(VERSION) commands outside the if
and ran the build again this time it generated a correct libftdi.pc
file. A patch for this change is attached.

My knowledge of cmake is not very extensive so I'd like to know if the
fix I've devised is the right one. If yes, will you consider including
this change ? If no, can you provide me with some hints what is the
right solution ?

For the record, I'm building the git HEAD on Gentoo with the following software:

grela@kraken ~/ftdi-git/libftdi $ LC_ALL=C pkg-config --version;
0.26
grela@kraken ~/ftdi-git/libftdi $ LC_ALL=C cmake --version
cmake version 2.8.8
grela@kraken ~/ftdi-git/libftdi $ LC_ALL=C make --version
GNU Make 3.82
Built for x86_64-pc-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
grela@kraken ~/ftdi-git/libftdi $ LC_ALL=C gcc --version
gcc (Gentoo 4.6.3 p1.3, pie-0.5.2) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
grela@kraken ~/ftdi-git/libftdi $

What are your thoughts about this ?

Best regards,
Maciej Grela


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Attachment: 0001-Fix-libftdi.pc-file-generation-when-building-with-DD.patch
Description: Binary data

Current Thread