CMakeLists.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # CMakeLists.txt for QXlsx Library
  2. cmake_minimum_required(VERSION 3.14)
  3. project(QXlsx LANGUAGES CXX)
  4. set(CMAKE_INCLUDE_CURRENT_DIR ON)
  5. set(CMAKE_AUTOUIC ON)
  6. set(CMAKE_AUTOMOC ON)
  7. set(CMAKE_AUTORCC ON)
  8. set(CMAKE_CXX_STANDARD 11)
  9. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  10. find_package(QT NAMES Qt6 Qt5 COMPONENTS Core Gui REQUIRED)
  11. find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Gui REQUIRED)
  12. if(NOT DEFINED ${QXLSX_PARENTPATH})
  13. set(QXLSX_PARENTPATH ${CMAKE_CURRENT_SOURCE_DIR}/../)
  14. endif(NOT DEFINED ${QXLSX_PARENTPATH})
  15. if(NOT DEFINED ${QXLSX_HEADERPATH})
  16. set(QXLSX_HEADERPATH ${CMAKE_CURRENT_SOURCE_DIR}/../QXlsx/header/)
  17. endif(NOT DEFINED ${QXLSX_HEADERPATH})
  18. if(NOT DEFINED ${QXLSX_SOURCEPATH})
  19. set(QXLSX_SOURCEPATH ${CMAKE_CURRENT_SOURCE_DIR}/../QXlsx/source/)
  20. endif(NOT DEFINED ${QXLSX_SOURCEPATH})
  21. message("Current Path of QXlsx")
  22. message(${QXLSX_PARENTPATH})
  23. message(${QXLSX_HEADERPATH})
  24. message(${QXLSX_SOURCEPATH})
  25. file(GLOB QXLSX_CPP "${QXLSX_SOURCEPATH}/*.cpp")
  26. file(GLOB QXLSX_H "${QXLSX_HEADERPATH}/*.h")
  27. set(SRC_FILES ${QXLSX_CPP})
  28. list(APPEND SRC_FILES ${QXLSX_H})
  29. add_library(QXlsx STATIC
  30. ${SRC_FILES} )
  31. target_include_directories(QXlsx PRIVATE ${QXLSX_HEADERPATH})
  32. target_link_libraries(${PROJECT_NAME}
  33. Qt${QT_VERSION_MAJOR}::Core
  34. Qt${QT_VERSION_MAJOR}::GuiPrivate
  35. )
  36. target_compile_definitions(QXlsx PRIVATE QXLSX_LIBRARY)