1
0
mirror of https://github.com/woo-j/zint.git synced 2024-12-23 01:33:55 +03:00

Simpily CMakeLists

This commit is contained in:
atom 2021-07-06 18:35:04 +03:00
parent 3c1869b032
commit 3e995c70fb
5 changed files with 28 additions and 35 deletions

View File

@ -139,6 +139,11 @@ else()
find_package(Qt5Xml)
if(Qt5Widgets_FOUND AND Qt5Gui_FOUND AND Qt5UiTools_FOUND AND Qt5Xml_FOUND)
message(STATUS "Qt version: " ${Qt5Core_VERSION_STRING})
# Old Qt does not provide QT_VERSION_MAJOR
if (NOT QT_VERSION_MAJOR)
string(SUBSTRING ${Qt5Core_VERSION_STRING} 0 1 QT_VERSION_MAJOR)
endif()
add_subdirectory(backend_qt)
add_subdirectory(frontend_qt)
else()

View File

@ -4,9 +4,7 @@
project(QZint)
include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend")
set(QZint_SRCS qzint.cpp)
set(${PROJECT_NAME}_SRCS qzint.cpp)
if(USE_QT6)
qt6_wrap_cpp(QZint_SRCS qzint.h)
@ -14,20 +12,15 @@ else()
qt5_wrap_cpp(QZint_SRCS qzint.h)
endif()
add_library(QZint STATIC ${QZint_SRCS})
add_library(${PROJECT_NAME} STATIC ${QZint_SRCS})
set_target_properties(QZint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
VERSION ${ZINT_VERSION})
add_dependencies(QZint zint)
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/backend")
link_directories("${CMAKE_BINARY_DIR}/backend")
target_link_libraries(${PROJECT_NAME} zint Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Gui)
if(USE_QT6)
target_link_libraries(QZint zint Qt6::Widgets Qt6::Gui)
else()
target_link_libraries(QZint zint Qt5::Widgets Qt5::Gui)
endif()
install(TARGETS QZint ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS ${PROJECT_NAME} ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES qzint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)

View File

@ -3,20 +3,20 @@
project(zint_frontend)
set(zint_frontend_SRCS main.c)
set(${PROJECT_NAME}_SRCS main.c)
include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend")
add_executable(${PROJECT_NAME} ${zint_frontend_SRCS})
add_executable(zint_frontend ${zint_frontend_SRCS})
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/backend")
set_target_properties(zint_frontend PROPERTIES OUTPUT_NAME "zint")
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "zint")
target_link_libraries(zint_frontend zint)
target_link_libraries(${PROJECT_NAME} zint)
if(NOT HAVE_GETOPT)
target_link_libraries(zint_frontend zint_bundled_getopt)
target_link_libraries(${PROJECT_NAME} zint_bundled_getopt)
endif()
install(TARGETS zint_frontend DESTINATION "${BIN_INSTALL_DIR}" RUNTIME)
install(TARGETS ${PROJECT_NAME} DESTINATION "${BIN_INSTALL_DIR}" RUNTIME)
if(ZINT_TEST)
add_subdirectory(tests)

View File

@ -4,34 +4,29 @@
project(zint-qt)
include_directories(BEFORE "${CMAKE_SOURCE_DIR}/backend" "${CMAKE_SOURCE_DIR}/backend_qt")
set(CMAKE_AUTORCC ON)
set(zint-qt_SRCS barcodeitem.cpp main.cpp mainwindow.cpp datawindow.cpp sequencewindow.cpp exportwindow.cpp)
set(${PROJECT_NAME}_SRCS barcodeitem.cpp main.cpp mainwindow.cpp datawindow.cpp sequencewindow.cpp exportwindow.cpp)
if(USE_QT6)
qt6_wrap_cpp(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h)
qt6_wrap_ui(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
qt6_add_resources(zint-qt_SRCS resources.qrc)
else()
qt5_wrap_cpp(zint-qt_SRCS mainwindow.h datawindow.h sequencewindow.h exportwindow.h)
qt5_wrap_ui(zint-qt_SRCS mainWindow.ui extData.ui extSequence.ui extExport.ui)
qt5_add_resources(zint-qt_SRCS resources.qrc)
endif()
# grpAztec.ui grpC39.ui grpCodeOne.ui grpGrid.ui grpMQR.ui grpUltra.ui
# grpC11.ui grpC49.ui grpDAFT.ui grpHX.ui grpMSICheck.ui grpUPCA.ui
# grpC128.ui grpChannel.ui grpDBExtend.ui grpLOGMARS.ui grpPDF417.ui grpUPCEAN.ui
# grpC16k.ui grpCodabar.ui grpDM.ui grpMaxicode.ui grpQR.ui grpVIN.ui
# grpC25.ui grpCodablockF.ui grpDotCode.ui grpMicroPDF.ui grpRMQR.ui
add_executable(zint-qt ${zint-qt_SRCS})
add_dependencies(zint-qt zint QZint)
add_executable(${PROJECT_NAME} ${zint-qt_SRCS} resources.qrc)
link_directories("${CMAKE_BINARY_DIR}/backend" "${CMAKE_BINARY_DIR}/backend_qt")
target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/backend" "${CMAKE_SOURCE_DIR}/backend_qt")
if(USE_QT6)
target_link_libraries(zint-qt zint QZint Qt6::UiTools Qt6::Xml Qt6::Gui Qt6::Core)
else()
target_link_libraries(zint-qt zint QZint Qt5::UiTools Qt5::Xml Qt5::Gui Qt5::Core)
endif()
target_link_libraries(${PROJECT_NAME} zint QZint Qt${QT_VERSION_MAJOR}::UiTools Qt${QT_VERSION_MAJOR}::Xml Qt${QT_VERSION_MAJOR}::Gui Qt${QT_VERSION_MAJOR}::Core)
install(TARGETS zint-qt DESTINATION "${BIN_INSTALL_DIR}" RUNTIME)
install(TARGETS ${PROJECT_NAME} DESTINATION "${BIN_INSTALL_DIR}" RUNTIME)

View File

@ -1,4 +1,4 @@
project(zint_bundled_getopt)
add_library(zint_bundled_getopt STATIC getopt.c getopt1.c)
target_include_directories(zint_bundled_getopt PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_library(${PROJECT_NAME} STATIC getopt.c getopt1.c)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})