Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake config generates invalid compiler flag when the (optional) dependency libusb-1.0 can not be found #1406

Closed
harendt opened this issue Oct 29, 2015 · 3 comments

Comments

@harendt
Copy link

harendt commented Oct 29, 2015

When I'm compiling code that depends on PCL without the (optional) dependency libusb-1.0, I get a huge number of the following warnings:

:0:15: warning: ISO C99 requires whitespace after the macro name [enabled by default]

The warning comes from the token -DDISABLE_LIBUSB-1.0 that is added to the compiler flags by PCL. The minus sign and the dot in DISABLE_LIBUSB-1.0 are not allowed for macro names.

I found the place where this invalid macro definition comes from (PCLConfig.cmake.in, line 618):

add_definitions("-DDISABLE_${LIB}")

When ${LIB} is LIBUSB-1.0, it should be changed to LIBUSB_1_0 or something similar.

@SergioRAgostinho
Copy link
Member

Can you provide more information on your setup? I just tried disabling libusb and building and no warnings were generated.

@harendt
Copy link
Author

harendt commented Nov 20, 2015

I'm working on Ubuntu 14.04. And libusb is not installed. I compiled PCL (version 1.7.2) on my own. The error occurs, when I try to compile code, that depends on PCL (pcl-common and pcl-io, I guess). I'm using CMake as build system. And CMake's function find_package() uses the file PCLConfig.cmake that is installed by PCL.

On line 618 this CMake file adds the compiler flag -DDISABLE_LIBUSB-1.0, if libusb is not found:

add_definitions("-DDISABLE_${LIB}")

The problem is that -- as the warning indicates -- the characters - and . are not allowed in macro definitions. Hence these characters should be replaced (e.g. replaced by _).

I could add a patch to PCLConfig.cmake, that replaces these invalid characters, but I don't know, if this would affect anything else.

@taketwo
Copy link
Member

taketwo commented Nov 21, 2015

I don't see any usage of such DISABLE variables anywhere besides pcl_config.h.in, where OpenNI and QHull support is tested. I think it's very safe to fix the invalid characters in -DDISABLE_LIBUSB-1.0. I'd even say it's okay to remove it completely, but we don't need to go that far :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants