auto_bus/CMakeLists.txt

66 lines
2.1 KiB
CMake
Raw Normal View History

2022-06-10 19:52:43 +08:00
cmake_minimum_required(VERSION 3.10)
project(auto_bus_gui)
2022-04-26 19:55:44 +08:00
2022-06-16 21:45:49 +08:00
file(GLOB_RECURSE QRC_SOURCE_FILES ${PROJECT_SOURCE_DIR}/*.qrc)
2022-06-10 19:52:43 +08:00
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
2022-06-16 21:45:49 +08:00
set(QRC_SOURCE_FILES Resources.qrc)
2022-04-26 19:55:44 +08:00
2022-06-16 21:45:49 +08:00
set(CMAKE_PREFIX_PATH "C:/Users/ricardo.DESKTOP-N6OVBK5/Programs/Qt/6.1.3/msvc2019_64")
2022-04-26 19:55:44 +08:00
2022-06-10 19:52:43 +08:00
find_package(Qt6 COMPONENTS
Core
Gui
Widgets
REQUIRED)
2022-04-26 19:55:44 +08:00
2022-06-16 21:45:49 +08:00
qt6_add_resources(QRC_FILES ${QRC_SOURCE_FILES})
SOURCE_GROUP("Resource Files" FILES ${QRC_SOURCE_FILES})
2022-04-26 19:55:44 +08:00
include_directories(
2022-06-10 19:52:43 +08:00
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src/header
2022-04-26 19:55:44 +08:00
)
2022-06-10 21:21:35 +08:00
2022-06-10 19:52:43 +08:00
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRCS)
2022-04-26 19:55:44 +08:00
add_executable(auto_bus_gui WIN32 main.cpp ${SRCS} ${QRC_FILES})
2022-06-10 21:21:35 +08:00
2022-06-10 19:52:43 +08:00
target_link_libraries(auto_bus_gui
Qt::Core
Qt::Gui
Qt::Widgets
)
2022-04-29 10:37:33 +08:00
2022-06-10 19:52:43 +08:00
if (WIN32)
set(DEBUG_SUFFIX)
if (MSVC AND CMAKE_BUILD_TYPE MATCHES "Debug")
set(DEBUG_SUFFIX "d")
endif ()
set(QT_INSTALL_PATH "${CMAKE_PREFIX_PATH}")
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
if (NOT EXISTS "${QT_INSTALL_PATH}/bin")
set(QT_INSTALL_PATH "${QT_INSTALL_PATH}/..")
endif ()
endif ()
if (EXISTS "${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/plugins/platforms/qwindows${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>/plugins/platforms/")
endif ()
foreach (QT_LIB Core)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${QT_INSTALL_PATH}/bin/Qt6${QT_LIB}${DEBUG_SUFFIX}.dll"
"$<TARGET_FILE_DIR:${PROJECT_NAME}>")
endforeach (QT_LIB)
endif ()