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 error caused by the merge of #2100 #2427

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

CMake error caused by the merge of #2100 #2427

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

With the latest merge of #2100, there is a problem when a library is linking to another library that links to PCL, please see below minimal to reproduce the problem.

CMakeLists.txt

cmake_minimum_required(VERSION 3.11)

project(sample)

find_package( PCL REQUIRED )

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

target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES})

add_subdirectory(sample2)

Sample.cpp

#include "Sample.h"

Sample::Sample() {}

Sample::~Sample() {}

Sample.h

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

sample2/CMakeLists.txt

cmake_minimum_required(VERSION 3.11)

project(sample2)

find_package( PCL REQUIRED )

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

# not even linking to ${PCL_LIBRARIES}
target_link_libraries(${PROJECT_NAME} sample)

sample2/Sample2.cpp

#include "Sample2.h"

Sample2::Sample2() {}

Sample2::~Sample2() {}

sample2/Sample2.h

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

Expected Behavior

After

mkdir build 
cd build 
cmake ..

It should work without a problem.

Current Behavior

However, here is the output

-- Eigen found (include: /usr/include/eigen3, version: 3.3.90)
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   system
--   filesystem
--   thread
--   date_time
--   iostreams
--   serialization
--   chrono
--   atomic
--   regex
-- FLANN found (include: /usr/include, lib: optimized;/usr/lib/libflann_cpp.so;debug;/usr/lib/libflann_cpp.so)
-- FLANN found (include: /usr/include, lib: optimized;/usr/lib/libflann_cpp.so;debug;/usr/lib/libflann_cpp.so)
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- LIBUSB_1_LIBRARY (missing: LIBUSB_1_INCLUDE_DIR) 
** WARNING ** io features related to libusb-1.0 will be disabled
-- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so)
-- looking for PCL_COMMON
-- looking for PCL_KDTREE
-- looking for PCL_OCTREE
-- looking for PCL_SEARCH
-- looking for PCL_SAMPLE_CONSENSUS
-- looking for PCL_FILTERS
-- looking for PCL_2D
-- looking for PCL_GEOMETRY
-- looking for PCL_IO
-- looking for PCL_FEATURES
-- looking for PCL_ML
-- looking for PCL_SEGMENTATION
-- looking for PCL_VISUALIZATION
-- looking for PCL_SURFACE
-- looking for PCL_REGISTRATION
-- looking for PCL_KEYPOINTS
-- looking for PCL_TRACKING
-- looking for PCL_RECOGNITION
-- looking for PCL_STEREO
-- looking for PCL_CUDA_COMMON
-- looking for PCL_CUDA_FEATURES
-- looking for PCL_CUDA_SEGMENTATION
-- looking for PCL_CUDA_SAMPLE_CONSENSUS
-- looking for PCL_OUTOFCORE
-- looking for PCL_GPU_CONTAINERS
-- looking for PCL_GPU_UTILS
-- looking for PCL_GPU_OCTREE
-- looking for PCL_GPU_FEATURES
-- looking for PCL_GPU_SEGMENTATION
-- looking for PCL_PEOPLE
-- Eigen found (include: /usr/include/eigen3, version: 3.3.90)
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   system
--   filesystem
--   thread
--   date_time
--   iostreams
--   serialization
--   chrono
--   atomic
--   regex
-- FLANN found (include: /usr/include, lib: optimized;/usr/lib/libflann_cpp.so;debug;/usr/lib/libflann_cpp.so)
-- FLANN found (include: /usr/include, lib: optimized;/usr/lib/libflann_cpp.so;debug;/usr/lib/libflann_cpp.so)
** WARNING ** io features related to pcap will be disabled
** WARNING ** io features related to png will be disabled
-- LIBUSB_1_LIBRARY (missing: LIBUSB_1_INCLUDE_DIR) 
** WARNING ** io features related to libusb-1.0 will be disabled
-- QHULL found (include: /usr/include, lib: optimized;/usr/lib/x86_64-linux-gnu/libqhull.so;debug;/usr/lib/x86_64-linux-gnu/libqhull.so)
-- looking for PCL_COMMON
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_common" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_KDTREE
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_kdtree" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_OCTREE
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_octree" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_SEARCH
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_search" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_SAMPLE_CONSENSUS
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_sample_consensus" because
  another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_FILTERS
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_filters" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_2D
-- looking for PCL_GEOMETRY
-- looking for PCL_IO
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_io" because another target
  with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_FEATURES
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_features" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_ML
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_ml" because another target
  with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_SEGMENTATION
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_segmentation" because
  another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_VISUALIZATION
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_visualization" because
  another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_SURFACE
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_surface" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_REGISTRATION
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_registration" because
  another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_KEYPOINTS
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_keypoints" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_TRACKING
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_tracking" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_RECOGNITION
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_recognition" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_STEREO
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_stereo" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_CUDA_COMMON
-- looking for PCL_CUDA_FEATURES
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_cuda_features" because
  another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_CUDA_SEGMENTATION
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_cuda_segmentation" because
  another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_CUDA_SAMPLE_CONSENSUS
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_cuda_sample_consensus"
  because another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_OUTOFCORE
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_outofcore" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_GPU_CONTAINERS
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_gpu_containers" because
  another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_GPU_UTILS
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_gpu_utils" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_GPU_OCTREE
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_gpu_octree" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_GPU_FEATURES
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_gpu_features" because
  another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_GPU_SEGMENTATION
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_gpu_segmentation" because
  another target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)


-- looking for PCL_PEOPLE
CMake Error at /usr/share/pcl-1.8/PCLConfig.cmake:630 (add_library):
  add_library cannot create imported target "pcl_people" because another
  target with the same name already exists.
Call Stack (most recent call first):
  sample2/CMakeLists.txt:5 (find_package)

-- Configuring incomplete, errors occurred!

This problem pops up only after the merge of #2100, if I remove the find_package( PCL REQUIRED ) in sample2/CMakeLists.txt the error goes away, but I should be allowed to call find_package( PCL REQUIRED ) in sample2/CMakeLists.txt even if it's redundant.

@taketwo
Copy link
Member

taketwo commented Sep 10, 2018

Could you please post this as a gist or small repo so I can directly check out all the files? I'll have a look.

@jasjuang
Copy link
Contributor Author

@taketwo
Copy link
Member

taketwo commented Sep 10, 2018

Thanks. See #2428.

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

2 participants