chadwick.boulay
chadwick.boulay

Reputation: 1814

cmake finds Qt5Core, but build.make reports "Qt5::Core-NOTFOUND"

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:

Upvotes: 1

Views: 2926

Answers (2)

Mikhail Chuprynski
Mikhail Chuprynski

Reputation: 2493

In my case adding Qt5 path directly solved the problem:

cmake .. -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5

Upvotes: 0

chadwick.boulay
chadwick.boulay

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

Related Questions