Skip to content

Commit 2459ef5

Browse files
committed
Fix: Find Qt5 (if enabled) in ElementalConfig.cmake
If Qt5 has been enabled during build, then e.g. target Qt5::Widgets is exported as a install dependency via ElementalTargets.cmake. Thus ElementalConfig.cmake must find Qt5 and import these Qt5 targets or else the user will get errors like: CMake Error at CMakeLists.txt:... (add_executable): Target "..." links to target "Qt5::Widgets" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?
1 parent de7b5be commit 2459ef5

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

cmake/configure_files/ElementalConfig.cmake.in

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ IF(@MPC_FOUND@)
88
set(Elemental_INCLUDE_DIRS "${Elemental_INCLUDE_DIRS};@MPFR_INCLUDES@")
99
set(Elemental_INCLUDE_DIRS "${Elemental_INCLUDE_DIRS};@GMP_INCLUDES@")
1010
ENDIF()
11-
set(Elemental_INCLUDE_DIRS
12-
"${Elemental_INCLUDE_DIRS};@Qt5Widgets_INCLUDE_DIRS@")
11+
12+
IF(@EL_HAVE_QT5@)
13+
include(CMakeFindDependencyMacro)
14+
set(QT_USE_IMPORTED_TARGETS TRUE)
15+
find_dependency(Qt5Widgets)
16+
set(Elemental_INCLUDE_DIRS
17+
"${Elemental_INCLUDE_DIRS};@Qt5Widgets_INCLUDE_DIRS@")
18+
ENDIF()
1319

1420
set(Elemental_COMPILE_FLAGS "@CXX_FLAGS@")
1521
set(Elemental_LINK_FLAGS "@EL_LINK_FLAGS@")
1622

17-
set(Elemental_DEFINITIONS "@Qt5Widgets_DEFINITIONS@")
23+
IF(@EL_HAVE_QT5@)
24+
set(Elemental_DEFINITIONS "@Qt5Widgets_DEFINITIONS@")
25+
ENDIF()
1826

1927
# Our library dependencies (contains definitions for IMPORTED targets)
2028
include("${CMAKE_CURRENT_LIST_DIR}/ElementalTargets.cmake")

0 commit comments

Comments
 (0)