問題:
AUTOGEN: No valid Qt version found for target opencv_opencl. AUTOMOC, AUTOUIC and AUTORCC disabled. Consider adding: find_package(Qt<QTVERSION> COMPONENTS Widgets) to your CMakeLists.txt file. This warning is for project developers. Use -Wno-dev to suppress it. CMake Error at AppNLP/CMakeLists.txt:255 (add_executable): Target "xxxxxxx" links to target "ZLIB::ZLIB" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing? Generating done CMake Warning: Manually-specified variables were not used by the project: QT_QMAKE_EXECUTABLE CMake Project parsing failed.
D:\AwsOneDriver\aStudioLk\AeolusPterosaurPlat\AppNLP\CMakeLists.txt:255: error: Target "appNLP_my" links to target "ZLIB::ZLIB"
but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?
:-1: error: Failed to compute build system.
當前的makefile寫法:
find_package(ZLIB ) include_directories( "D:/win10/aspDep/zlib1211/x64/include") link_directories( "D:/win10/aspDep/zlib1211/x64/lib") ADD_DEFINITIONS (${ZLIB_DEFINITIONS})
問題的解決辦法:
set( ZLIB_ROOT "D:/win10/aspDep/zlib1211/x64" ) find_package(ZLIB ) include_directories( "D:/win10/aspDep/zlib1211/x64/include") link_directories( "D:/win10/aspDep/zlib1211/x64/lib") ADD_DEFINITIONS (${ZLIB_DEFINITIONS})
是的,只需要加一行代碼即可。
問題總結:
出現這個問題的原因不是由於protobuf庫是否靜態庫,也不是由於zlib庫是否靜態庫,而僅僅是因為沒有找到zlib的根目錄,由此導致找不到zlib的一些定義。
附官網資料:
官網說明:https://cmake.org/cmake/help/latest/module/FindZLIB.html
FindZLIB
Find the native ZLIB includes and library.
IMPORTED Targets
This module defines IMPORTED
target ZLIB::ZLIB
, if ZLIB has been found.
Result Variables
This module defines the following variables:
ZLIB_INCLUDE_DIRS - where to find zlib.h, etc.
ZLIB_LIBRARIES - List of libraries when using zlib.
ZLIB_FOUND - True if zlib found.
ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
ZLIB_VERSION_MAJOR - The major version of zlib
ZLIB_VERSION_MINOR - The minor version of zlib
ZLIB_VERSION_PATCH - The patch version of zlib
ZLIB_VERSION_TWEAK - The tweak version of zlib
Backward Compatibility
The following variable are provided for backward compatibility
ZLIB_MAJOR_VERSION - The major version of zlib
ZLIB_MINOR_VERSION - The minor version of zlib
ZLIB_PATCH_VERSION - The patch version of zlib
Hints
A user may set ZLIB_ROOT
to a zlib installation root to tell this module where to look.