diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2019-06-12 14:49:47 +0200 |
---|---|---|
committer | Cristian Adam <cristian.adam@qt.io> | 2019-06-12 13:34:58 +0000 |
commit | 36135aa26174c2ebf6dec213a469e671e67b2cfb (patch) | |
tree | 6b311f77da58319e966a0cd6b3f26c76d51ba2fb /share/qtcreator/templates | |
parent | 5ac71e485ac2b8a480454e5111fc4219ec7efc45 (diff) | |
download | qt-creator-36135aa26174c2ebf6dec213a469e671e67b2cfb.tar.gz |
CMake: Small clean-up of CMake Wizards
* Updated CMake minimum version to 3.5 (Ubuntu LTS 16.04)
* Lowercase commands
* Used the target name instead of ${PROJECT_NAME}, which nobody uses in practice
* No string quotes around the source filenames, which do not contain spaces
Change-Id: Ide9b3eb85535213798c6c35e08624cae080ebd9d
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'share/qtcreator/templates')
7 files changed, 89 insertions, 62 deletions
diff --git a/share/qtcreator/templates/wizards/autotest/files/tst.txt b/share/qtcreator/templates/wizards/autotest/files/tst.txt index 2d3826d00b..bf5e75ff16 100644 --- a/share/qtcreator/templates/wizards/autotest/files/tst.txt +++ b/share/qtcreator/templates/wizards/autotest/files/tst.txt @@ -1,7 +1,6 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) -PROJECT(%{TestCaseName} - LANGUAGES CXX) +project(%{TestCaseName} LANGUAGES CXX) @if "%{TestFrameWork}" == "QtTest" @@ -10,38 +9,46 @@ find_package(Qt5Test REQUIRED) find_package(Qt5Gui REQUIRED) @endif -SET(CMAKE_AUTOMOC ON) -SET(CMAKE_INCLUDE_CURRENT_DIR ON) -SET(CMAKE_CXX_STANDARD 11) -SET(CMAKE_CXX_STANDARD_REQUIRED ON) -ENABLE_TESTING() +set(CMAKE_INCLUDE_CURRENT_DIR ON) -add_executable(${PROJECT_NAME} %{TestCaseFileWithCppSuffix}) -add_test(${PROJECT_NAME} COMMAND ${PROJECT_NAME}) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +enable_testing() + +add_executable(%{TestCaseName} %{TestCaseFileWithCppSuffix}) +add_test(%{TestCaseName} COMMAND %{TestCaseName}) @if "%{RequireGUI}" == "true" -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Gui Qt5::Test) +target_link_libraries(%{TestCaseName} PRIVATE Qt5::Gui Qt5::Test) @else -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Test) +target_link_libraries(%{TestCaseName} PRIVATE Qt5::Test) @endif @endif @if "%{TestFrameWork}" == "QtQuickTest" find_package(Qt5QuickTest REQUIRED) -SET(CMAKE_AUTOMOC ON) -SET(CMAKE_INCLUDE_CURRENT_DIR ON) -SET(CMAKE_CXX_STANDARD 11) -SET(CMAKE_CXX_STANDARD_REQUIRED ON) -ENABLE_TESTING() +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +enable_testing() # no need to copy around qml test files for shadow builds - just set the respective define add_definitions(-DQUICK_TEST_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") -add_executable(${PROJECT_NAME} %{MainCppName}) -add_test(${PROJECT_NAME} COMMAND ${PROJECT_NAME}) +add_executable(%{TestCaseName} %{MainCppName}) +add_test(%{TestCaseName} COMMAND %{TestCaseName}) -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::QuickTest) +target_link_libraries(%{TestCaseName} PRIVATE Qt5::QuickTest) @endif @if "%{TestFrameWork}" == "GTest" @@ -53,14 +60,14 @@ add_definitions(-DGTEST_LANGUAGE_CXX11) find_package(Threads REQUIRED) if ($ENV{GOOGLETEST_DIR}) - SET(GOOGLETEST_DIR $ENV{GOOGLETEST_DIR}) + set(GOOGLETEST_DIR $ENV{GOOGLETEST_DIR}) else () message(WARNING "Using googletest src dir specified at Qt Creator wizard") - SET(GOOGLETEST_DIR "%{GTestRepository}") + set(GOOGLETEST_DIR "%{GTestRepository}") endif () if (EXISTS ${GOOGLETEST_DIR}) - SET(GTestSrc ${GOOGLETEST_DIR}/googletest) - SET(GMockSrc ${GOOGLETEST_DIR}/googlemock) + set(GTestSrc ${GOOGLETEST_DIR}/googletest) + set(GMockSrc ${GOOGLETEST_DIR}/googlemock) else () message( FATAL_ERROR "No googletest src dir found - set GOOGLETEST_DIR to enable!") endif () @@ -68,19 +75,22 @@ endif () include_directories(${GTestSrc} ${GTestSrc}/include ${GMockSrc} ${GMockSrc}/include) -add_executable(${PROJECT_NAME} %{MainCppName} %{TestCaseFileWithHeaderSuffix} +add_executable(%{TestCaseName} %{MainCppName} %{TestCaseFileWithHeaderSuffix} ${GTestSrc}/src/gtest-all.cc ${GMockSrc}/src/gmock-all.cc) -add_test(${PROJECT_NAME} COMMAND ${PROJECT_NAME}) -target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads) +add_test(%{TestCaseName} COMMAND %{TestCaseName}) +target_link_libraries(%{TestCaseName} PRIVATE Threads::Threads) @endif @if "%{TestFrameWork}" == "BoostTest" -SET(CMAKE_INCLUDE_CURRENT_DIR ON) -ENABLE_TESTING() +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +enable_testing() -add_executable(${PROJECT_NAME} %{MainCppName}) -add_test(${PROJECT_NAME} COMMAND ${PROJECT_NAME}) +add_executable(%{TestCaseName} %{MainCppName}) +add_test(%{TestCaseName} COMMAND %{TestCaseName}) if (DEFINED ENV{BOOST_INCLUDE_DIR}) set(BOOST_INCLUDE_DIR $ENV{BOOST_INCLUDE_DIR}) diff --git a/share/qtcreator/templates/wizards/projects/consoleapp/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/consoleapp/CMakeLists.txt index 4beef640b7..ce63061d75 100644 --- a/share/qtcreator/templates/wizards/projects/consoleapp/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/consoleapp/CMakeLists.txt @@ -1,12 +1,17 @@ -cmake_minimum_required(VERSION 3.0.0) +cmake_minimum_required(VERSION 3.5) -project(%{ProjectName} VERSION 0.1 LANGUAGES CXX) +project(%{ProjectName} LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) -find_package(Qt5Core) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) -add_executable(${PROJECT_NAME} "%{CppFileName}") +find_package(Qt5Core) -target_link_libraries(${PROJECT_NAME} Qt5::Core) +add_executable(%{ProjectName} %{CppFileName}) +target_link_libraries(%{ProjectName} Qt5::Core) diff --git a/share/qtcreator/templates/wizards/projects/cpplibrary/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/cpplibrary/CMakeLists.txt index 29d8396852..243280b657 100644 --- a/share/qtcreator/templates/wizards/projects/cpplibrary/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/cpplibrary/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) project(%{ProjectName} LANGUAGES CXX) @@ -15,21 +15,21 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt5 COMPONENTS %{QtModuleUpperCase} REQUIRED) @endif -add_library(${PROJECT_NAME} %{JS: %{IsStatic} ? 'STATIC' : 'SHARED'} +add_library(%{ProjectName} %{JS: %{IsStatic} ? 'STATIC' : 'SHARED'} @if '%{Type}' === 'shared' - "%{GlobalHdrFileName}" + %{GlobalHdrFileName} @endif - "%{SrcFileName}" - "%{HdrFileName}" + %{SrcFileName} + %{HdrFileName} @if %{IsQtPlugin} - "%{PluginJsonFile}" + %{PluginJsonFile} @endif ) @if '%{QtModule}' != 'none' -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::%{QtModuleUpperCase}) +target_link_libraries(%{ProjectName} PRIVATE Qt5::%{QtModuleUpperCase}) @endif @if '%{IsShared}' -target_compile_definitions(${PROJECT_NAME} PRIVATE %{LibraryDefine}) +target_compile_definitions(%{ProjectName} PRIVATE %{LibraryDefine}) @endif diff --git a/share/qtcreator/templates/wizards/projects/plainc/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/plainc/CMakeLists.txt index f4783c4195..5af2f09fb6 100644 --- a/share/qtcreator/templates/wizards/projects/plainc/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/plainc/CMakeLists.txt @@ -1,4 +1,5 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.5) -project(%{ProjectName}) -add_executable(${PROJECT_NAME} "%{CFileName}") +project(%{ProjectName} LANGUAGES C) + +add_executable(%{ProjectName} %{CFileName}) diff --git a/share/qtcreator/templates/wizards/projects/plaincpp/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/plaincpp/CMakeLists.txt index 6393118931..cdea69420e 100644 --- a/share/qtcreator/templates/wizards/projects/plaincpp/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/plaincpp/CMakeLists.txt @@ -1,4 +1,8 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.5) -project(%{ProjectName}) -add_executable(${PROJECT_NAME} "%{CppFileName}") +project(%{ProjectName} LANGUAGES CXX) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(%{ProjectName} %{CppFileName}) diff --git a/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt index 0b7b832155..165a32be3d 100644 --- a/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/qtquickapplication/CMakeLists.txt @@ -1,23 +1,28 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) project(%{ProjectName} LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) + set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt5 COMPONENTS Core Quick REQUIRED) if(ANDROID) - add_library(${PROJECT_NAME} SHARED "%{MainCppFileName}" "qml.qrc") + add_library(%{ProjectName} SHARED %{MainCppFileName} qml.qrc) else() - add_executable(${PROJECT_NAME} "%{MainCppFileName}" "qml.qrc") + add_executable(%{ProjectName} %{MainCppFileName} qml.qrc) endif() -target_compile_definitions(${PROJECT_NAME} PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Core Qt5::Quick) +target_compile_definitions(%{ProjectName} + PRIVATE $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>) +target_link_libraries(%{ProjectName} + PRIVATE Qt5::Core Qt5::Quick) # QtCreator supports the following variables for Android, which are identical to qmake Android variables. # Check http://doc.qt.io/qt-5/deployment-android.html for more information. diff --git a/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt b/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt index 75a2beb233..5fd51e9014 100644 --- a/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/projects/qtwidgetsapplication/CMakeLists.txt @@ -1,23 +1,25 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.5) project(%{ProjectName} LANGUAGES CXX) set(CMAKE_INCLUDE_CURRENT_DIR ON) + set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) + set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(Qt5 COMPONENTS Widgets REQUIRED) -add_executable(${PROJECT_NAME} - "%{MainFileName}" - "%{SrcFileName}" - "%{HdrFileName}" +add_executable(%{ProjectName} + %{MainFileName} + %{SrcFileName} + %{HdrFileName} @if %{GenerateForm} - "%{FormFileName}" + %{FormFileName} @endif ) -target_link_libraries(${PROJECT_NAME} PRIVATE Qt5::Widgets) +target_link_libraries(%{ProjectName} PRIVATE Qt5::Widgets) |