Skip to content

Commit

Permalink
Build with Qt 5 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
hluk committed Mar 8, 2017
1 parent e6343ab commit 87d9dc0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
23 changes: 10 additions & 13 deletions CMakeLists.txt
Expand Up @@ -16,7 +16,7 @@ endif()
OPTION(PEDANTIC "Enable all compiler warnings" OFF)

# Options (cmake -LH)
OPTION(WITH_QT5 "Qt5 support" OFF)
OPTION(WITH_QT5 "Use Qt 5 (disable to use Qt 4 instead)" ON)
OPTION(WITH_TESTS "Run test cases from command line" ${COPYQ_DEBUG})
OPTION(WITH_PLUGINS "Compile plugins" ON)
# Linux-specific options
Expand All @@ -32,26 +32,23 @@ endif()

set(CMAKE_AUTOMOC ON)

# If Qt4 unavailable use Qt5.
if (NOT WITH_QT5)
if (WITH_QT5)
cmake_minimum_required(VERSION 2.8.8)
find_package(Qt5Widgets)
if (NOT Qt5Widgets_FOUND)
message(FATAL_ERROR "Qt 5 is unavailable. To compile with Qt 4 use -DWITH_QT5=OFF.")
endif()
message(STATUS "Building with Qt 5.")
else()
find_package(Qt4)
if (NOT QT4_FOUND)
# Try different executable name.
set(QT_QMAKE_EXECUTABLE "qmake-qt4")
find_package(Qt4)
if (NOT QT4_FOUND)
message(FATAL_ERROR
"Qt 4 is unavailable. To compile with Qt 5 use -DWITH_QT5=TRUE.\n"
"Note: Qt version 5.0.2 and earlier can be unstable on some systems.")
message(FATAL_ERROR "Qt 4 is unavailable. To compile with Qt 5 use -DWITH_QT5=ON.")
endif()
endif()
endif()

if (WITH_QT5)
cmake_minimum_required(VERSION 2.8.8)
find_package(Qt5Widgets REQUIRED)
message(STATUS "Building with Qt 5.")
else()
message(STATUS "Building with Qt 4.")
endif()

Expand Down
2 changes: 1 addition & 1 deletion utils/appveyor/before_build.bat
@@ -1 +1 @@
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -G "%CMAKE_GENERATOR%" -DWITH_QT5=ON -DWITH_TESTS=ON
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release -G "%CMAKE_GENERATOR%" -DWITH_TESTS=ON
1 change: 0 additions & 1 deletion utils/gitlab/build-script.sh
Expand Up @@ -7,7 +7,6 @@ INSTALL_PREFIX=$(readlink -f "$INSTALL_PREFIX")

cmake_args=(
-DWITH_TESTS=TRUE
-DWITH_QT5=TRUE
-DCMAKE_INSTALL_PREFIX="$INSTALL_PREFIX"
..
)
Expand Down
8 changes: 7 additions & 1 deletion utils/travis/script-linux.sh
Expand Up @@ -10,7 +10,13 @@ cd build
# Configure.
if [ "$CC" == "gcc" ]; then
# GCC build generates coverage.
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_CXX_FLAGS=--coverage -DCMAKE_C_FLAGS=--coverage ..
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_COMPILER=$COMPILER \
-DCMAKE_CXX_FLAGS=--coverage \
-DCMAKE_C_FLAGS=--coverage \
-DWITH_QT5=OFF \
..
else
qmake CONFIG+=debug QMAKE_CXX=$COMPILER QMAKE_CXXFLAGS="-std=c++11" ..
fi
Expand Down

0 comments on commit 87d9dc0

Please sign in to comment.