--- /dev/null
+cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
+include(FeatureSummary)
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+
+project(AniDBUdpClient)
+
+set(AniDBUdpClient_VERSION "0.4.0")
+
+option(WITH_RENAMEPARSER "Build RenameParser" ON)
+add_feature_info(RenameParser WITH_RENAMEPARSER "file renaming engine")
+
+option(WITH_ENCRYPTION "Enable encryption" ON)
+add_feature_info(Encryption WITH_ENCRYPTION "ENCRYPT command support (requires QCA)")
+
+set(QT_MIN_VERSION "5.3.0")
+find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+ Core
+ Network
+ Script
+)
+
+set(AniDBUdpClient_PUBLIC_LIBS
+ Qt5::Core
+ Qt5::Network
+)
+
+set(AniDBUdpClient_SOURCES
+ client.cpp
+ abstractcommand.cpp
+ authcommand.cpp
+ encryptcommand.cpp
+ rawcommand.cpp
+ mylistaddcommand.cpp
+ logoutcommand.cpp
+ uptimecommand.cpp
+ mylistcommand.cpp
+ filecommand.cpp
+ votecommand.cpp
+ file.cpp
+ hash.cpp
+ hashproducer.cpp
+ hashconsumer.cpp
+ clientsentcommandsmodel.cpp
+ clientqueuedcommandsmodel.cpp
+ filerenamedelegate.cpp
+ clientinterface.cpp
+ myliststate.cpp
+ episodecommand.cpp
+ animecommand.cpp
+ mylistexportcommand.cpp
+ updatecommand.cpp
+)
+
+set(AniDBUdpClient_PUBLIC_HEADERS
+ client.h
+ anidbudpclient_global.h
+ aniqflags.h
+ abstractcommand.h
+ authcommand.h
+ encryptcommand.h
+ rawcommand.h
+ mylistaddcommand.h
+ logoutcommand.h
+ uptimecommand.h
+ mylistcommand.h
+ filecommand.h
+ votecommand.h
+ file.h
+ hash.h
+ hashproducer.h
+ hashconsumer.h
+ circularbuffer.h
+ clientsentcommandsmodel.h
+ clientqueuedcommandsmodel.h
+ filerenamedelegate.h
+ clientinterface.h
+ myliststate.h
+ episodecommand.h
+ animecommand.h
+ mylistexportcommand.h
+ updatecommand.h
+)
+
+set(AniDBUdpClient_CONV_HEADERS
+ include/AniDBUdpClient/Client
+ include/AniDBUdpClient/AbstractCommand
+ include/AniDBUdpClient/RawCommand
+ include/AniDBUdpClient/MyListCommand
+ include/AniDBUdpClient/MyListAddCommand
+ include/AniDBUdpClient/MyListState
+ include/AniDBUdpClient/AnimeCommand
+ include/AniDBUdpClient/EpisodeCommand
+ include/AniDBUdpClient/FileCommand
+ include/AniDBUdpClient/VoteCommand
+ include/AniDBUdpClient/UpdateCommand
+ include/AniDBUdpClient/UptimeCommand
+ include/AniDBUdpClient/MyListExportCommand
+ include/AniDBUdpClient/File
+ include/AniDBUdpClient/Hash
+ include/AniDBUdpClient/ClientSentCommandsModel
+ include/AniDBUdpClient/ClientQueuedCommandsModel
+ include/AniDBUdpClient/FileRenameDelegate
+)
+
+install(FILES ${AniDBUdpClient_CONV_HEADERS}
+ DESTINATION include/AniDBUdpClient
+)
+
+if(WITH_RENAMEPARSER)
+ set(AniDBUdpClient_RENAMEPARSER_HEADERS
+ renameparser/renameengine.h
+ renameparser/functions.h
+ renameparser/abstractparser.h
+ renameparser/ast.h
+ renameparser/debugwalk.h
+ renameparser/abstractwalk.h
+ renameparser/evaluatewalk.h
+ renameparser/analyzewalk.h
+
+ renameparser/AniAdd/renameparser.h
+ renameparser/AniAdd/renamegrammar_p.h
+ renameparser/AniAdd/lexer.h
+
+ renameparser/ECMAScript/parser.h
+ )
+ set(AniDBUdpClient_SOURCES
+ ${AniDBUdpClient_SOURCES}
+ renameparser/renameengine.cpp
+ renameparser/functions.cpp
+ renameparser/abstractparser.cpp
+ renameparser/ast.cpp
+ renameparser/debugwalk.cpp
+ renameparser/abstractwalk.cpp
+ renameparser/evaluatewalk.cpp
+ renameparser/analyzewalk.cpp
+
+ renameparser/AniAdd/renameparser.cpp
+ renameparser/AniAdd/renamegrammar.cpp
+ renameparser/AniAdd/lexer.cpp
+
+ renameparser/ECMAScript/parser.cpp
+ )
+
+ set(AniDBUdpClient_RENAMEPARSER_CONV_HEADERS
+ include/RenameParser/RenameEngine
+ )
+
+ set(AniDBUdpClient_LIBS
+ ${AniDBUdpClient_LIBS}
+ Qt5::Script
+ )
+
+ install(FILES
+ ${AniDBUdpClient_RENAMEPARSER_HEADERS}
+ ${AniDBUdpClient_RENAMEPARSER_CONV_HEADERS}
+
+ # TODO remove hack. These are installed twice for compatibility reasons
+ anidbudpclient_global.h
+ aniqflags.h
+
+ DESTINATION include/RenameParser
+ )
+
+else()
+ add_definitions(-DANIDBUDPCLIENT_NO_RENAMEPARSER)
+endif()
+
+
+if(WITH_ENCRYPTION)
+ set(QCA_NAME "QCA-qt5")
+ find_package(${QCA_NAME} CONFIG REQUIRED)
+ if (${QCA_NAME}_FOUND)
+ # TODO Runtime plugins are required
+ # (but there is no way to check for those during build time)
+ set(AniDBUdpClient_LIBS
+ ${AniDBUdpClient_LIBS}
+ # This variable is set by the QCA package script
+ ${Qca_LIBRARY}
+ )
+ else()
+ set(WITH_ENCRYPTION OFF)
+ endif()
+endif()
+
+if (NOT WITH_ENCRYPTION)
+ add_definitions(-DANIDBUDPCLIENT_NO_ENCRYPT)
+endif()
+
+
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTOUIC ON)
+set(CMAKE_AUTORCC ON)
+
+add_library(AniDBUdpClient SHARED
+ ${AniDBUdpClient_SOURCES}
+ ${AniDBUdpClient_HEADERS}
+ ${AniDBUdpClient_PUBLIC_HEADERS}
+ ${AniDBUdpClient_RENAMEPARSER_HEADERS}
+)
+set_property(TARGET AniDBUdpClient PROPERTY CXX_STANDARD 14)
+set_property(TARGET AniDBUdpClient PROPERTY PUBLIC_HEADER ${AniDBUdpClient_PUBLIC_HEADERS})
+set_property(TARGET AniDBUdpClient PROPERTY OUTPUT_NAME "anidbudpclient")
+target_link_libraries(AniDBUdpClient
+ PUBLIC ${AniDBUdpClient_PUBLIC_LIBS}
+ PRIVATE ${AniDBUdpClient_LIBS}
+)
+
+# This is the Qt generated export macro
+# TODO replace with export header?
+add_definitions(-DANIDBUDPCLIENT_LIBRARY)
+
+set(CONFIG_INSTALL_DIRECTORY "lib${LIB_SUFFIX}/cmake/AniDBUdpClient")
+
+install(TARGETS AniDBUdpClient
+ EXPORT AniDBUdpClientTargets
+ LIBRARY DESTINATION lib${LIB_SUFFIX}
+ ARCHIVE DESTINATION lib${LIB_SUFFIX}
+ RUNTIME DESTINATION bin
+# TODO revisit this when RenameParser is moved to a separate project
+ INCLUDES DESTINATION include
+ PUBLIC_HEADER DESTINATION include/AniDBUdpClient
+)
+install(FILES $<TARGET_PDB_FILE:AniDBUdpClient> DESTINATION bin OPTIONAL)
+
+install(EXPORT AniDBUdpClientTargets
+ FILE AniDBUdpClientTargets.cmake
+ NAMESPACE AniDBUdpClient::
+ DESTINATION ${CONFIG_INSTALL_DIRECTORY}
+)
+
+
+# Config file
+set(CONFIG_NAME "${PROJECT_NAME}")
+
+include(CMakePackageConfigHelpers)
+configure_package_config_file(${CONFIG_NAME}Config.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}Config.cmake
+ INSTALL_DESTINATION ${LIB_INSTALL_DIR}/${CONFIG_NAME}/cmake
+)
+write_basic_package_version_file(AniDBUdpClientConfigVersion.cmake
+ VERSION ${AniDBUdpClient_VERSION}
+ COMPATIBILITY SameMajorVersion
+)
+
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}Config.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}ConfigVersion.cmake"
+ DESTINATION ${CONFIG_INSTALL_DIRECTORY}
+)
+
+feature_summary(WHAT ALL)