Reputation: 1814
Using MacOS Sierra, cmake 3.7.2 and qt 5.8.0 installed with homebrew. In this specific application, cmake completes without error but during build I get the following error:
CMakeFiles/CereLink.dir/build.make:174: *** target pattern contains no `%'. Stop.
make[1]: *** [CMakeFiles/CereLink.dir/all] Error 2
make: *** [all] Error 2
The offending line has Qt5::Core-NOTFOUND
It is definitely a problem with this application as I have other Qt5-dependent applications that build correctly, and this application depends on an ExternalProject that links Qt5 which also builds correctly!
The problematic application can be found online.
cmake seems to find Qt5 correctly. Using
FIND_PROGRAM(QT_QMAKE_EXECUTABLE_FINDQT
NAMES
qmake qmake5 qmake-qt5
PATHS
"${QT_SEARCH_PATH}/bin"
"$ENV{QTDIR}/bin"
)
SET(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt qmake program.")
EXEC_PROGRAM(${QT_QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_PREFIX" OUTPUT_VARIABLE QT_INSTALL_PREFIX)
message(${QT_INSTALL_PREFIX})
reports /usr/local/Cellar/qt5/5.8.0_1
find_package(Qt5 COMPONENTS Core REQUIRED)
or find_package(Qt5Core REQUIRED)
both seem to work correctly. See Additional Info below for evidence.
EDIT - Additional info:
message(${Qt5Core_FOUND})
prints 1
.message(${Qt5Core_LIBRARIES})
prints Qt5::Core
Qt5Core_DIR
instead of CMAKE_PREFIX_PATH
does not change
anything.Qt5Core
or ${Qt5Core_LIBRARIES}
(and additional includes) does not help.get_target_property(QtCore_location Qt5::Core IMPORTED_LOCATION_RELEASE)
: /usr/local/Cellar/qt5/5.8.0_1/lib/QtCore.framework/QtCore
Upvotes: 1
Views: 2926
Reputation: 2493
In my case adding Qt5 path directly solved the problem:
cmake .. -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5
Upvotes: 0
Reputation: 1814
The problem was that I was overwriting CMAKE_IMPORT_LIBRARY_SUFFIX
while configuring another 3rd party library. It took me a while to find this problem because it happens after all the calls to find Qt. I guess some aspect of finding/linking Qt is deferred until after configuration is complete and therefore after this variable was set, and these deferred aspects must use CMAKE_IMPORT_LIBRARY_SUFFIX
. My solution was to create a new variable and set/use that manually instead of relying on CMAKE_IMPORT_LIBRARY_SUFFIX
.
Upvotes: 1