Hi all,
I’m writing two c++ projects, both controlled by CMakeLists files: a library and an application.
VisualStudio 2019 as environment.
Library libUpgrade
It includes libusb library installed by vcpkg tool, so in CMakeLists file I included the following directives:
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE PkgConfig::libusb)
The VisualStudio project is correclty generated without errors and the library is compiled.
Same project generates libUpgradeConfig.cmake file inside the ./install/cmake folder by the configure_package_config_file() command.
This file I guess should transmit the libusb dependency to the upper projects.
Application
The application includes the library in the follwing mode:
find_package(libUpgrade REQUIRED)
This one looks for the libusb package by the …/include/cmake/libUpgradeConfig.cmake file but, in this project, the libusb package is not found:
– Found PkgConfig: C:/Users/stefano.mora/Source/Repos/vcpkg/installed/x64-windows/tools/pkgconf/pkgconf.exe (found version “2.1.0”)
– Checking for module ‘libusb-1.0’
– Package ‘libusb-1.0’, required by ‘virtual:world’, not found
CMake Error at C:/Program Files/CMake/share/cmake-3.28/Modules/FindPkgConfig.cmake:619 (message):
The following required packages were not found:
- libusb-1.0
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.28/Modules/FindPkgConfig.cmake:841 (_pkg_check_modules_internal)
C:/Users/stefano.mora/Source/Repos/dbTechnologies/libUpgrade/install/cmake/libUpgradeConfig.cmake:44 (pkg_check_modules)
C:/Users/stefano.mora/Source/Repos/vcpkg/scripts/buildsystems/vcpkg.cmake:859 (_find_package)
CMakeLists.txt:55 (find_package)
I guess the libUpgradeConfig.cmake file is lacking of something.
The libUpgradeConfig model file is the following:
set(LIBUPGRADE_VERSION @CMAKE_PROJECT_VERSION@)
@PACKAGE_INIT@set_and_check(libUpgrade_INCLUDE_DIRS @ PACKAGE_INCLUDE_INSTALL_DIR@ )
check_required_components(libUpgrade)
include(${CMAKE_CURRENT_LIST_DIR}/libUpgradeTargets.cmake)set_target_properties(libUpgrade PROPERTIES
MAP_IMPORTED_CONFIG_MINSIZEREL Debug
MAP_IMPORTED_CONFIG_RELWITHDEBINFO Debug
)include(CMakeFindDependencyMacro)
find_dependency(PkgConfig)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
Thanks,
regards