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

Follow up on #2427, CMake problems #2431

Closed
jasjuang opened this issue Sep 10, 2018 · 3 comments
Closed

Follow up on #2427, CMake problems #2431

jasjuang opened this issue Sep 10, 2018 · 3 comments

Comments

@jasjuang
Copy link
Contributor

jasjuang commented Sep 10, 2018

Your Environment

  • Operating System and version: Ubuntu 18.04
  • Compiler: GCC 7
  • PCL Version: Latest

Context

This is the minimal example to recreate the problem

CMakeLists.txt

cmake_minimum_required(VERSION 3.11)

add_subdirectory(sample2)
add_subdirectory(sample3)

sample2/CMakeLists.txt

cmake_minimum_required(VERSION 3.11)

project(sample2)

find_package( PCL REQUIRED )

add_library(${PROJECT_NAME} SHARED Sample2.cpp Sample2.h)

target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES})

sample2/Sample2.h

class Sample2{
 public:
  Sample2();
  ~Sample2();
};

sample2/Sample2.cpp

#include "Sample2.h"

Sample2::Sample2() {}

Sample2::~Sample2() {}

sample3/CMakeLists.txt

cmake_minimum_required(VERSION 3.11)

project(sample3)

find_package( PCL REQUIRED )

add_library(${PROJECT_NAME} SHARED Sample3.cpp Sample3.h)

target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES})

sample3/Sample3.h

class Sample3{
 public:
  Sample3();
  ~Sample3();
};

sample3/Sample3.cpp

#include "Sample3.h"

#include "pcl/common/common.h"

Sample3::Sample3() {}

Sample3::~Sample3() {}

You can see that sample2 and sample3 are irrelevant to each other, but when I compile it shows the below compilation error

In file included from /usr/include/pcl-1.8/pcl/common/common.h:41:0,
                 from /home/hypevr/test/sample3/Sample3.cpp:3:
/usr/include/pcl-1.8/pcl/pcl_base.h:49:10: fatal error: Eigen/StdVector: No such file or directory
 #include <Eigen/StdVector>
          ^~~~~~~~~~~~~~~~~
compilation terminated.
sample3/CMakeFiles/sample3.dir/build.make:62: recipe for target 'sample3/CMakeFiles/sample3.dir/Sample3.cpp.o' failed

However, if I comment out the add_subdirectory(sample2) in the head CMakeLists so it becomes like this

cmake_minimum_required(VERSION 3.11)

#add_subdirectory(sample2)
add_subdirectory(sample3)

It actually compiles as it should be. So for some reason sample2 is still affecting sample3 even though they are irrelevant. Can someone please fix it?

@taketwo
Copy link
Member

taketwo commented Sep 10, 2018

We should have CI tests for PCLConfig 😢

@taketwo
Copy link
Member

taketwo commented Sep 10, 2018

There is a fundamental question, actually. Should our imported targets be marked GLOBAL or not? In other words, should the PCL libs found by "sample2" subproject be visible/usable in "sample3"? At the moment we have inconsistency, our targets are marked global and are visible, however the PCL_LIBRARIES variable which includes all the target library names is not global. Further, thinking about how it was before, none of the variables created by the config script were set global, so the found PCL was not shared across subprojects. So I'm inclined to think that we shouldn't make our targets global.

@taketwo taketwo added this to the pcl-1.9.0 milestone Sep 10, 2018
@jasjuang
Copy link
Contributor Author

I believe the standard practice is not to mark them global. If eventually PCL migrates to the modern CMake way of doing things like pcl::pcl and export the auto generated config file and targets file does not mark the imported targets as global.

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

No branches or pull requests

3 participants