kylin-printer/CMakeLists.txt

160 lines
4.8 KiB
CMake

cmake_minimum_required(VERSION 3.5)
#Set Project Name
project(kylin-printer LANGUAGES CXX C)
project(${PROJECT_NAME} VERSION 1.3.0)
set(PROJECT_VERSION_DETAIL "1.3.0-ok10")
include(${PROJECT_SOURCE_DIR}/cmake/common.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/printer.cmake)
option(TEST_DEBUG "option for debug" OFF)
if (TEST_DEBUG)
add_definitions(-DTEST_DEBUG)
add_definitions(-DPROJECT_SOURCE_DIR=\"${PROJECT_SOURCE_DIR}\")
add_definitions(-DPROJECT_BINARY_DIR=\"${PROJECT_BINARY_DIR}\")
endif(TEST_DEBUG)
add_definitions(-DPROJECT_NAME=\"${PROJECT_NAME}\")
add_subdirectory(backend)
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)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
find_package(QT NAMES Qt6 Qt5)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets LinguistTools Network DBus REQUIRED)
execute_process(COMMAND bash ${PROJECT_SOURCE_DIR}/sh/update_translations.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
execute_process(COMMAND bash ${PROJECT_SOURCE_DIR}/sh/apply_translations.sh
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
#add include
include_directories(${PROJECT_SOURCE_DIR}/printer_manager/
${PROJECT_SOURCE_DIR}/device_manager/
${PROJECT_SOURCE_DIR}/ui/
${PROJECT_SOURCE_DIR}/ui/custom_ui/
${PROJECT_SOURCE_DIR}/ui/main_win_ui/
${PROJECT_SOURCE_DIR}/ui/new_pop_window/
${PROJECT_SOURCE_DIR}/util/
${PROJECT_SOURCE_DIR}/dictionary/
${PROJECT_SOURCE_DIR}/common/
${PROJECT_SOURCE_DIR}/avahi_qt/
${PROJECT_SOURCE_DIR}/qt_zeroconf/
${PROJECT_SOURCE_DIR}/ui/new_property_window/
${PROJECT_SOURCE_DIR}/ui/new_property_window/SecondComponent/
)
add_definitions("-Wall")
configure_file(config.h.in
config.h
@ONLY
)
file(GLOB common_SRC
"common/*"
)
file(GLOB avahi_qt_SRC
"avahi_qt/*.cpp"
"avahi_qt/*.h"
"qt_zeroconf/*.cpp"
"qt_zeroconf/*.h"
)
file(GLOB printer_manager_SRC
"printer_manager/*.cpp"
"printer_manager/*.c"
"printer_manager/*.h"
)
file(GLOB device_manager_SRC
"device_manager/device_information.*"
"device_manager/device_monitor.*"
"device_manager/network_device_detector.*"
"device_manager/network_device_monitor.*"
"device_manager/udev_devices.*"
)
file(GLOB dictionary_SRC
"dictionary/*.cpp"
"dictionary/*.h"
)
file(GLOB ui_SRC
"ui/*.cpp"
"ui/*.h"
"ui/main_win_ui/*.cpp"
"ui/main_win_ui/*.h"
"ui/new_pop_window/*.cpp"
"ui/new_pop_window/*.h"
"ui/custom_ui/*"
"ui/new_property_window/*.h"
"ui/new_property_window/*.cpp"
"ui/new_property_window/SecondComponent/*.h"
"ui/new_property_window/SecondComponent/*.cpp"
)
file(GLOB util_SRC
"util/*.cpp"
"util/*.h"
)
SET(ui_RESOURCE ${PROJECT_SOURCE_DIR}/ui/picture.qrc)
set(TS_FILES ${PROJECT_SOURCE_DIR}/translations/${PROJECT_NAME}_zh_CN.ts
${PROJECT_SOURCE_DIR}/translations/${PROJECT_NAME}_en.ts
${PROJECT_SOURCE_DIR}/translations/${PROJECT_NAME}_dict_zh_CN.ts)
QT5_CREATE_TRANSLATION(QM_FILES
${ui_SRC}
${TS_FILES})
add_executable(${PROJECT_NAME}
main.cpp
${common_SRC}
${printer_manager_SRC}
${device_manager_SRC}
${ui_SRC}
${util_SRC}
${ui_RESOURCE}
${avahi_qt_SRC}
${dictionary_SRC}
${QM_FILES}
)
target_link_kysdk_libraries(${PROJECT_NAME})
target_link_glib_libraries(${PROJECT_NAME})
target_link_snmp_libraries(${PROJECT_NAME})
target_link_qgsettings_libraries(${PROJECT_NAME})
target_link_cups_libraries(${PROJECT_NAME})
target_link_cupsfilters_libraries(${PROJECT_NAME})
target_link_avahi_libraries(${PROJECT_NAME})
target_link_usb_libraries(${PROJECT_NAME})
target_link_udev_libraries(${PROJECT_NAME})
target_link_KWindowSystem_libraries(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network Qt${QT_VERSION_MAJOR}::DBus)
#dependencies
target_link_libraries(${PROJECT_NAME} "-lpthread -lz")
########### install ###############
install(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
install(FILES ${PROJECT_SOURCE_DIR}/${PROJECT_NAME}.desktop DESTINATION /usr/share/applications/)
install(FILES ${PROJECT_SOURCE_DIR}/data/org.kylin.printer.gschema.xml DESTINATION /usr/share/glib-2.0/schemas/)
file(GLOB TRANS "${PROJECT_SOURCE_DIR}/translations/*.qm")
install(FILES ${TRANS} DESTINATION /usr/share/${PROJECT_NAME}/translations/)
# v10 SP1 only
install(DIRECTORY ${PROJECT_SOURCE_DIR}/data/guide/${PROJECT_NAME} DESTINATION /usr/share/kylin-user-guide/data/guide/)