Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support specifying Qt version manually #9

Merged
merged 1 commit into from
Mar 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,13 @@ option(QUAZIP_BZIP2_STDIO "Output BZIP2 errors to stdio" ON)
option(QUAZIP_FETCH_LIBS "Enables fetching third-party libraries if not found" ${WIN32})
option(QUAZIP_FORCE_FETCH_LIBS "Enables fetching third-party libraries always" OFF)

# Set the default value of `${QUAZIP_QT_MAJOR_VERSION}`.
# We search quietly for Qt6, Qt5 and Qt4 in that order.
# Qt6 and Qt5 provide config files for CMake.
# Qt4 relies on `FindQt4.cmake`.
find_package(
QT NAMES Qt6 Qt5
QUIET COMPONENTS Core
)
if (NOT QT_FOUND)
find_package(Qt4 QUIET COMPONENTS QtCore)
if (Qt4_FOUND)
set(QT_VERSION_MAJOR 4)
else()
# If neither 6, 5 nor 4 are found, we default to 5.
# The setup will fail further down.
set(QT_VERSION_MAJOR 5)
endif()
# If Qt version is not explicitly specified, automatically determine it.
# However, it will be set by LibrePCB anyway.
if(NOT QUAZIP_QT_MAJOR_VERSION)
find_package(Qt NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
set(QUAZIP_QT_MAJOR_VERSION ${Qt_VERSION_MAJOR})
endif()

set(QUAZIP_QT_MAJOR_VERSION ${QT_VERSION_MAJOR} CACHE STRING "Qt version to use (4, 5 or 6), defaults to ${QT_VERSION_MAJOR}")

if (QUAZIP_QT_MAJOR_VERSION EQUAL 6)
set(CMAKE_CXX_STANDARD 17)
else()
Expand Down Expand Up @@ -108,7 +94,7 @@ else()
message(FATAL_ERROR "Qt version ${QUAZIP_QT_MAJOR_VERSION} is not supported")
endif()

message(STATUS "Using Qt version ${QUAZIP_QT_MAJOR_VERSION}")
message(STATUS "Building QuaZip with Qt ${QUAZIP_QT_MAJOR_VERSION}")

set(QUAZIP_QT_ZLIB_USED OFF)
if(QUAZIP_USE_QT_ZLIB)
Expand Down
Loading