CMakeLists.txt 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. set(TARGET serializationplugin)
  2. set(TARGET_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${TARGET})
  3. set(TARGET_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
  4. set(TARGET_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
  5. set(TARGET_BIN_DIR ${CMAKE_INSTALL_BINDIR})
  6. set(CMAKE_AUTOMOC ON)
  7. set(CMAKE_AUTORCC ON)
  8. find_package(Qt5 COMPONENTS Core REQUIRED)
  9. if(NOT DEFINED QT_QMAKE_EXECUTABLE)
  10. find_program(QT_QMAKE_EXECUTABLE "qmake")
  11. if(QT_QMAKE_EXECUTABLE STREQUAL QT_QMAKE_EXECUTABLE-NOTFOUND)
  12. message(FATAL_ERROR "Could not find qmake executable")
  13. endif()
  14. endif()
  15. file(GLOB SOURCES
  16. qtserializationplugin.cpp
  17. qprotobufjsonserializerimpl.cpp
  18. qprotobufserializerimpl.cpp)
  19. file(GLOB HEADERS
  20. qtserializationplugin.h
  21. qtserialization_global.h)
  22. add_library(${TARGET} SHARED ${SOURCES})
  23. target_link_libraries(${TARGET} PRIVATE Qt5::Core Qt5::Qml ${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf)
  24. target_compile_definitions(${TARGET} PRIVATE SERIALIZATION_LIB)
  25. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/serializeinfo.json" "${CMAKE_CURRENT_BINARY_DIR}/serializeinfo.json" COPYONLY)
  26. install(FILES "${CMAKE_CURRENT_BINARY_DIR}/serializeinfo.json" DESTINATION "$<TARGET_PROPERTY:${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf,QT_PROTOBUF_PLUGIN_PATH>")
  27. install(TARGETS ${TARGET}
  28. PUBLIC_HEADER DESTINATION "${TARGET_INCLUDE_DIR}"
  29. RUNTIME DESTINATION "$<TARGET_PROPERTY:${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf,QT_PROTOBUF_PLUGIN_PATH>"
  30. LIBRARY DESTINATION "$<TARGET_PROPERTY:${QTPROTOBUF_COMMON_NAMESPACE}::QtProtobuf,QT_PROTOBUF_PLUGIN_PATH>")