Skip to content

Commit

Permalink
Fix build with Qt6 (probonopd#613)
Browse files Browse the repository at this point in the history
find_package(QT ...) only finds out if Qt5 or Qt6 is available.
One needs to then to find_package(Qt5...) or find_package(Qt6...) as in
the Qt documentation:
https://doc.qt.io/qt-6/cmake-qt5-and-qt6-compatibility.html

Otherwise, one gets this error:
CMake Error: AUTOMOC for target linuxdeployqt: Could not find moc
executable target Qt6::moc
CMake Generate step failed.  Build files cannot be regenerated
correctly.

Co-authored-by: David Faure <faure@kde.org>
  • Loading branch information
2 people authored and omergoktas committed Oct 12, 2024
1 parent 79fcdeb commit a2d64de
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tools/linuxdeployqt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
set(CMAKE_AUTOMOC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# expose version data as compiler definition
add_definitions("-DLINUXDEPLOYQT_VERSION=\"${GIT_TAG_NAME}\"")
add_definitions("-DLINUXDEPLOYQT_GIT_COMMIT=\"${GIT_COMMIT}\"")
add_definitions("-DBUILD_DATE=\"${DATE}\"")
add_definitions("-DBUILD_NUMBER=\"${BUILD_NUMBER}\"")

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)

# update excludelist
message(STATUS "Updating excludelist...")
execute_process(
COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/../generate-excludelist.sh
OUTPUT_VARIABLE EXCLUDELIST
TIMEOUT 10
RESULT_VARIABLE EXCLUDELIST_RESULT
)
if(NOT EXCLUDELIST_RESULT EQUAL 0)
message(WARNING "Updating excludelist failed, using outdated copy")
endif()
mark_as_advanced(EXCLUDELIST EXCLUDELIST_RESULT)

add_executable(linuxdeployqt main.cpp shared.cpp)
target_include_directories(linuxdeployqt PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(linuxdeployqt Qt${QT_VERSION_MAJOR}::Core)
target_compile_definitions(linuxdeployqt PRIVATE -DEXCLUDELIST="${EXCLUDELIST}")

0 comments on commit a2d64de

Please sign in to comment.