1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
| cmake_minimum_required(VERSION 3.14)
set(MY_PROJECT_NAME qtdialog)
project(${MY_PROJECT_NAME} LANGUAGES CXX)
message ("cmake:${PROJECT_NAME}")
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_DEBUG_POSTFIX -d)
set(MY_SOURCE_LIB_DIR "${PROJECT_SOURCE_DIR}/../lib/")
include_directories("../include") include_directories("../") include_directories(${CMAKE_CURRENT_BINARY_DIR})
link_directories("${MY_SOURCE_LIB_DIR}")
if (NOT CMAKE_BUILD_TYPE) set (CMAKE_BUILD_TYPE "Release") message ( STATUS "${PROJECT_NAME} no CMAKE_BUILD_TYPE selected, defaulting to ${CMAKE_BUILD_TYPE} " ) endif()
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network Gui Widgets WebEngineWidgets WebChannel) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network Gui Widgets WebEngineWidgets WebChannel)
FILE(GLOB SOURCEFILES "./*.cpp") FILE(GLOB HEADERFILES "./*.h") FILE(GLOB UIFILES "./*.ui")
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) QT6_WRAP_UI(WRAPS ${UIFILES}) elseif(${QT_VERSION_MAJOR} GREATER_EQUAL 5) QT5_WRAP_UI(WRAPS ${UIFILES}) else() QT_WRAP_UI(WRAPS ${UIFILES}) endif()
SET(RCCFILES res.qrc)
SOURCE_GROUP("UI" FILES ${UIFILES} ${WRAPS} )
add_executable(${PROJECT_NAME} ${SOURCEFILES} ${HEADERFILES} ${UIFILES} res.qrc )
if(WIN32) target_link_libraries(${PROJECT_NAME} PRIVATE debug mylib1-d.lib debug mylib2-d.lib optimized mylib1.lib optimized mylib2.lib ) else() target_link_libraries(${PROJECT_NAME} PRIVATE debug libmylib1-d.so debug libmylib2-d.so optimized libmylib1.so optimized libmylib2.so -lpthread ) endif()
target_link_libraries(${PROJECT_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::WebEngineWidgets Qt${QT_VERSION_MAJOR}::WebChannel )
if(MSVC) add_definitions("-DUNICODE" "-D_UNICODE") target_compile_options(${PROJECT_NAME} PUBLIC "/ZI") target_link_options(${PROJECT_NAME} PUBLIC "/INCREMENTAL") endif()
if (WIN32) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<$<CONFIG:Debug>:debug/${PROJECT_NAME}.exe>" "$<$<CONFIG:Release>:release/${PROJECT_NAME}.exe>" "${MY_SOURCE_LIB_DIR}") else() add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<$<CONFIG:Debug>:${PROJECT_NAME}>" "$<$<CONFIG:Release>:${PROJECT_NAME}>" "${MY_SOURCE_LIB_DIR}") endif()
|