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

Failed to link to PCL (Property INTERFACE_LINK_LIBRARIES may not contain link-type keyword "optimized".) #7660

Closed
jasjuang opened this issue Aug 13, 2019 · 8 comments · Fixed by #8154
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@jasjuang
Copy link
Contributor

Currently, I am having a problem linking to pcl that is built by vcpkg.

Host Environment

  • OS: Windows 10
  • Compiler: Visual Studio 2017

To Reproduce
vcpkg install pcl

Create two files to simulate the downstream user

CMakeLists.txt

cmake_minimum_required(VERSION 3.1)

project(Example)

set(PROJECT_SRCS ${PROJECT_SOURCE_DIR}/mycpp.cpp)

find_package( PCL REQUIRED )

add_executable(${PROJECT_NAME} ${PROJECT_SRCS})

target_link_libraries(${PROJECT_NAME} ${PCL_LIBRARIES})

mycpp.cpp

int main(){
  return 0;
}

when I do cmake -A x64 .. it shows the below error

CMake Error at C:/dev/vcpkg/installed/x64-windows/share/pcl/PCLConfig.cmake:679 (set_target_properties):
  Property INTERFACE_LINK_LIBRARIES may not contain link-type keyword
  "optimized".  The INTERFACE_LINK_LIBRARIES property may contain
  configuration-sensitive generator-expressions which may be used to specify
  per-configuration rules.

How can I solve this?

Does the CI in vcpkg check simple downstream link and see whether it's successful? If it's just checking builds and unit tests, can we add a simple downstream linking check to avoid future problems like this?

@jasjuang jasjuang added the category:port-bug The issue is with a library, which is something the port should already support label Aug 13, 2019
@cenit
Copy link
Contributor

cenit commented Aug 13, 2019

Unfortunately CI is not doing this basic step which is so important also IMHO
To be clear, it is not even checking unit tests when available inside the port...

@cbezault
Copy link
Contributor

Both doing a simple linking check and running (at least some of) the unit tests are on the roadmap but haven't been implemented yet.

@jasjuang
Copy link
Contributor Author

Why is the issue closed? The pcl port is still broken.

@ras0219-msft ras0219-msft changed the title Does the CI in vcpkg check simple downstream link? Failed to link to PCL Failed to link to PCL (Property INTERFACE_LINK_LIBRARIES may not contain link-type keyword "optimized".) Aug 15, 2019
@ras0219-msft ras0219-msft reopened this Aug 15, 2019
@cbezault cbezault self-assigned this Aug 15, 2019
@Neumann-A
Copy link
Contributor

VCPKG wrappers which might need fixing:

  • curlpp
  • freeglut (needs debug/release xrandr libs)
  • opencv4? (depending on whatever variable OPENCV_MODULES is)

From what I found in the ports folder this seems like a PCL issue which probably sets somewhere the property INTERFACE_LINK_LIBRARIES using some variable MYLIB_LIBRARIES. The fix here would be to simply replace that code with target_link_libraries(target INTERFACE ${MYLIB_LIBRARIES}). If it is not done in a CMakeLists.txt but in a configuration file then remove that line from the configuration file and move it into the required CMakeLists.txt and hope that PCL uses CMake to generate its target files.
Could you add the line PCLConfig.cmake:679 to this issue please?

@traversaro
Copy link
Contributor

@traversaro
Copy link
Contributor

traversaro commented Sep 12, 2019

The offending keywork apparently come from the zlib library (included via the vtk library), see:

optimized;C:/vcpkg/installed/x64-windows/share/vtk/../../lib/zlib.lib;
debug;C:/vcpkg/installed/x64-windows/share/vtk/../../debug/lib/zlibd.lib;

@Neumann-A
Copy link
Contributor

@traversaro Please give the full line information. Also setting a variable like so

set(SOME_LIBRARIES optimized;C:/vcpkg/installed/x64-windows/share/vtk/../../lib/zlib.lib;
debug;C:/vcpkg/installed/x64-windows/share/vtk/../../debug/lib/zlibd.lib)

is perfectly fine CMake and to be expected from a _LIBRARIES variables.
As I stated in PointCloudLibrary/pcl#3289 (comment) it is a PCL issue not guarding against the optimized/debug keywords while setting INTERFACE_LINK_LIBRARIES using external supplied _LIBRARIES variables. So the error is not to be searched in VTK but in PCL (But VTK's cmake files should still be checked if they all correctly set debug/optimized versions of their external dependencies. If not that needs to be corrected but is a different issue)

@traversaro
Copy link
Contributor

@Neumann-A I am preparing a patch for the PCL issue: I am fully aware of your comment, and how optimized there is perfectly legal. I just wanted to share my debugging about the issue by printing a portion of "${PCL_${COMPONENT}_LINK_LIBRARIES}" from https://github.com/PointCloudLibrary/pcl/blob/pcl-1.9.1/PCLConfig.cmake.in#L631, and by "offending" I meant "that is highlighting the issue", not that is incorrect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants