microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
22.79k stars 6.29k forks source link

Update the hint for OpenMesh port #36293

Closed ranjeethmahankali closed 7 months ago

ranjeethmahankali commented 7 months ago

Describe the bug The hint shown at the end when you install openmesh currently looks like this:

find_package(openmesh REQUIRED)
target_include_directories(main PRIVATE ${OPENMESH_INCLUDE_DIRS})
target_link_libraries(main PRIVATE ${OPENMESH_LIBRARIES})

But this doesn't work anymore with newer versions of the port. The $ variables are empty, so there are no include dirs or libraries to link. My project wasn't building when I updated the builtin-baseline inside vcpkg.json. I got my project to build with the following:

find_package(OpenMesh REQUIRED) # Update to camel case to find the package.
target_link_libraries(main PRIVATE OpenMeshCore OpenMeshTools) # Use newer targets to link properly

Environment

To Reproduce Steps to reproduce the behavior:

  1. Start a boilerplate C++ cmake project.
  2. ./vcpkg install openmesh
  3. Copy the hint provided by the installation command to link your project with openmesh
  4. Build your project.

Expected behavior The project builds.

Failure logs At first you'll see this:

CMake Error at /home/rnjth94/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package):
  By not providing "Findopenmesh.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "openmesh",
  but CMake did not find one.

  Could not find a package configuration file provided by "openmesh" with any
  of the following names:

    openmeshConfig.cmake
    openmesh-config.cmake

  Add the installation prefix of "openmesh" to CMAKE_PREFIX_PATH or set
  "openmesh_DIR" to a directory containing one of the above files.  If
  "openmesh" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  CMakeLists.txt:23 (find_package)

If you change the argument of find_package from openmesh to OpenMesh, the above error goes away, but you'll still get linker errors. After you update the targets the project will build properly.

Additional context My project now builds without any problems, but I lack the knowledge of vcpkg to PR this change so I figured I'd report it here. Thank you!

FrankXie05 commented 7 months ago

@ranjeethmahankali Thanks for posting this issue, For cmake projects, you need to pass CMAKE_TOOLCHAIN_FILE through run commnd .\vcpkg.exe integrate install https://github.com/microsoft/vcpkg?tab=readme-ov-file#using-vcpkg-with-cmake.

but I lack the knowledge of vcpkg to PR this change so I figured I'd report it here.

And you can add set(CMAKE_FIND_DEBUG_MODE 1) in front of find_package, which can display the specific find information of cmake in the console. :)

dg0yt commented 7 months ago

@FrankXie05 You can quickly that this is a real port bug.

FrankXie05 commented 7 months ago
CMake Debug Log at F:/vcpkg/installed/x64-windows/share/OpenMesh/vcpkg-cmake-wrapper.cmake:12 (find_library):
  find_library called with the following settings:

    VAR: OPENMESHTOOLS_LIBRARY_RELEASE
    NAMES: "OpenMeshTools"
           "libOpenMeshTools"
    Documentation: Path to a library.
    Framework
      Only Search Frameworks: 0
      Search Frameworks Last: 1
      Search Frameworks First: 0
    AppBundle
      Only Search AppBundle: 0
      Search AppBundle Last: 1
      Search AppBundle First: 0
    NO_DEFAULT_PATH Enabled

  find_library considered the following locations:

    F:/vcpkg/installed/x64-windows/debug/vcpkg/installed/x64-windows/lib/()OpenMeshTools(\.lib)
    F:/vcpkg/installed/x64-windows/debug/vcpkg/installed/x64-windows/lib/()libOpenMeshTools(\.lib)
    F:/vcpkg/installed/x64-windows/debug/vcpkg/installed/x64-windows/()OpenMeshTools(\.lib)
    F:/vcpkg/installed/x64-windows/debug/vcpkg/installed/x64-windows/()libOpenMeshTools(\.lib)

  The item was found at

    F:/vcpkg/installed/x64-windows/lib/OpenMeshTools.lib

Call Stack (most recent call first):
  F:/vcpkg/scripts/buildsystems/vcpkg.cmake:813 (include)
  CMakeLists.txt:19 (find_package)

-- Configuring done (7.9s)
-- Generating done (0.0s)
-- Build files have been written to: F:/usage/build

Yes, The fake find_packahe is replaced by find_library and find_path in vcpkg-cmake-wrapper.cmake.