From: APTX Date: Thu, 23 Nov 2017 12:31:37 +0000 (+0900) Subject: Add CMake build system X-Git-Url: https://gitweb.aptx.org/?a=commitdiff_plain;h=b5cbeaf7620f6c04ff0e73b1d6cbde5dff3dc679;p=anidbudpclient.git Add CMake build system Paths in some headers got changed to always include from the project root. This should allow simpler installations of the library. --- diff --git a/.gitignore b/.gitignore index 2f8834d..ee1331f 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,8 @@ qrc_*.cpp # Directories to ignore # --------------------- +build +cmakebuild debug release @@ -63,13 +65,3 @@ lib/qtsingleapplication/examples lib/qtsingleapplication/doc .tmp qtc-gdbmacros - -# Binaries -# -------- -build/aniplayer -build/*.dll -build/*.lib -build/*.exe -build/*.so* - - diff --git a/AniDBUdpClientConfig.cmake.in b/AniDBUdpClientConfig.cmake.in new file mode 100644 index 0000000..b6fcc7c --- /dev/null +++ b/AniDBUdpClientConfig.cmake.in @@ -0,0 +1,13 @@ +@PACKAGE_INIT@ + +# TODO when CMake can automatically find transitive deps, this can be removed +include(CMakeFindDependencyMacro) + +# TODO find_dependency with components is nonstandard +find_dependency(Qt5Network) + +include("${CMAKE_CURRENT_LIST_DIR}/@CONFIG_NAME@Targets.cmake") + +set(@CONFIG_NAME@_WITH_RENAMEPARSER @WITH_RENAMEPARSER@) + +check_required_components(@CONFIG_NAME@) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e5d154e --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,251 @@ +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 $ 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) diff --git a/include/AniDBUdpClient/AbstractCommand b/include/AniDBUdpClient/AbstractCommand index 1e4030b..8585ef5 100644 --- a/include/AniDBUdpClient/AbstractCommand +++ b/include/AniDBUdpClient/AbstractCommand @@ -1 +1 @@ -#include "../../abstractcommand.h" \ No newline at end of file +#include "abstractcommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/AnimeCommand b/include/AniDBUdpClient/AnimeCommand index a9f3607..46308d8 100644 --- a/include/AniDBUdpClient/AnimeCommand +++ b/include/AniDBUdpClient/AnimeCommand @@ -1 +1 @@ -#include "../../animecommand.h" \ No newline at end of file +#include "animecommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/Client b/include/AniDBUdpClient/Client index 73445b3..a7f5447 100644 --- a/include/AniDBUdpClient/Client +++ b/include/AniDBUdpClient/Client @@ -1 +1 @@ -#include "../../client.h" \ No newline at end of file +#include "client.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/ClientQueuedCommandsModel b/include/AniDBUdpClient/ClientQueuedCommandsModel index 978dd22..89f29cc 100644 --- a/include/AniDBUdpClient/ClientQueuedCommandsModel +++ b/include/AniDBUdpClient/ClientQueuedCommandsModel @@ -1 +1 @@ -#include "../../clientqueuedcommandsmodel.h" \ No newline at end of file +#include "clientqueuedcommandsmodel.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/ClientSentCommandsModel b/include/AniDBUdpClient/ClientSentCommandsModel index 97585ef..f9a1558 100644 --- a/include/AniDBUdpClient/ClientSentCommandsModel +++ b/include/AniDBUdpClient/ClientSentCommandsModel @@ -1 +1 @@ -#include "../../clientsentcommandsmodel.h" \ No newline at end of file +#include "clientsentcommandsmodel.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/EpisodeCommand b/include/AniDBUdpClient/EpisodeCommand index 3dc21f5..3201675 100644 --- a/include/AniDBUdpClient/EpisodeCommand +++ b/include/AniDBUdpClient/EpisodeCommand @@ -1 +1 @@ -#include "../../episodecommand.h" \ No newline at end of file +#include "episodecommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/File b/include/AniDBUdpClient/File index 6431d6c..4314c22 100644 --- a/include/AniDBUdpClient/File +++ b/include/AniDBUdpClient/File @@ -1 +1 @@ -#include "../../file.h" \ No newline at end of file +#include "file.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/FileCommand b/include/AniDBUdpClient/FileCommand index cf757bf..79354ba 100644 --- a/include/AniDBUdpClient/FileCommand +++ b/include/AniDBUdpClient/FileCommand @@ -1 +1 @@ -#include "../../filecommand.h" \ No newline at end of file +#include "filecommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/FileRenameDelegate b/include/AniDBUdpClient/FileRenameDelegate index f12e405..925b4d0 100644 --- a/include/AniDBUdpClient/FileRenameDelegate +++ b/include/AniDBUdpClient/FileRenameDelegate @@ -1 +1 @@ -#include "../../filerenamedelegate.h" \ No newline at end of file +#include "filerenamedelegate.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/Hash b/include/AniDBUdpClient/Hash index 4ae187b..b4aac77 100644 --- a/include/AniDBUdpClient/Hash +++ b/include/AniDBUdpClient/Hash @@ -1 +1 @@ -#include "../../hash.h" +#include "hash.h" diff --git a/include/AniDBUdpClient/MyListAddCommand b/include/AniDBUdpClient/MyListAddCommand index 51dd0f2..0ca0412 100644 --- a/include/AniDBUdpClient/MyListAddCommand +++ b/include/AniDBUdpClient/MyListAddCommand @@ -1 +1 @@ -#include "../../mylistaddcommand.h" \ No newline at end of file +#include "mylistaddcommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/MyListCommand b/include/AniDBUdpClient/MyListCommand index 5bf1b59..b703608 100644 --- a/include/AniDBUdpClient/MyListCommand +++ b/include/AniDBUdpClient/MyListCommand @@ -1 +1 @@ -#include "../../mylistcommand.h" \ No newline at end of file +#include "mylistcommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/MyListExportCommand b/include/AniDBUdpClient/MyListExportCommand index 6a6dd63..553bed5 100644 --- a/include/AniDBUdpClient/MyListExportCommand +++ b/include/AniDBUdpClient/MyListExportCommand @@ -1 +1 @@ -#include "../../mylistexportcommand.h" \ No newline at end of file +#include "mylistexportcommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/MyListState b/include/AniDBUdpClient/MyListState index c4dc086..7b78397 100644 --- a/include/AniDBUdpClient/MyListState +++ b/include/AniDBUdpClient/MyListState @@ -1 +1 @@ -#include "../../myliststate.h" \ No newline at end of file +#include "myliststate.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/RawCommand b/include/AniDBUdpClient/RawCommand index 03bcb16..db9a20c 100644 --- a/include/AniDBUdpClient/RawCommand +++ b/include/AniDBUdpClient/RawCommand @@ -1 +1 @@ -#include "../../rawcommand.h" \ No newline at end of file +#include "rawcommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/UpdateCommand b/include/AniDBUdpClient/UpdateCommand index ee84b27..6f813fe 100644 --- a/include/AniDBUdpClient/UpdateCommand +++ b/include/AniDBUdpClient/UpdateCommand @@ -1 +1 @@ -#include "../../updatecommand.h" \ No newline at end of file +#include "updatecommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/UptimeCommand b/include/AniDBUdpClient/UptimeCommand index 24e18a1..7f24859 100644 --- a/include/AniDBUdpClient/UptimeCommand +++ b/include/AniDBUdpClient/UptimeCommand @@ -1 +1 @@ -#include "../../uptimecommand.h" \ No newline at end of file +#include "uptimecommand.h" \ No newline at end of file diff --git a/include/AniDBUdpClient/VoteCommand b/include/AniDBUdpClient/VoteCommand index 019b431..8dbb907 100644 --- a/include/AniDBUdpClient/VoteCommand +++ b/include/AniDBUdpClient/VoteCommand @@ -1 +1 @@ -#include "../../votecommand.h" \ No newline at end of file +#include "votecommand.h" \ No newline at end of file diff --git a/include/RenameParser/RenameEngine b/include/RenameParser/RenameEngine index 2015b67..943eac5 100644 --- a/include/RenameParser/RenameEngine +++ b/include/RenameParser/RenameEngine @@ -1 +1 @@ -#include "../../renameparser/renameengine.h" \ No newline at end of file +#include "renameparser/renameengine.h" \ No newline at end of file diff --git a/renameparser/abstractparser.h b/renameparser/abstractparser.h index 7ea6573..ca4ceed 100644 --- a/renameparser/abstractparser.h +++ b/renameparser/abstractparser.h @@ -1,7 +1,7 @@ #ifndef ABSTRACTPARSER_H #define ABSTRACTPARSER_H -#include "../anidbudpclient_global.h" +#include "anidbudpclient_global.h" #include #include #include diff --git a/renameparser/abstractwalk.h b/renameparser/abstractwalk.h index ce47944..64f53e6 100644 --- a/renameparser/abstractwalk.h +++ b/renameparser/abstractwalk.h @@ -1,7 +1,7 @@ #ifndef ABSTRACTWALK_H #define ABSTRACTWALK_H -#include "../anidbudpclient_global.h" +#include "anidbudpclient_global.h" #include "ast.h" #include #include diff --git a/renameparser/analyzewalk.h b/renameparser/analyzewalk.h index 478de11..6dc2421 100644 --- a/renameparser/analyzewalk.h +++ b/renameparser/analyzewalk.h @@ -1,7 +1,7 @@ #ifndef ANALYZEWALK_H #define ANALYZEWALK_H -#include "../anidbudpclient_global.h" +#include "anidbudpclient_global.h" #include "abstractwalk.h" #include diff --git a/renameparser/debugwalk.h b/renameparser/debugwalk.h index b990632..11055ae 100644 --- a/renameparser/debugwalk.h +++ b/renameparser/debugwalk.h @@ -1,7 +1,7 @@ #ifndef DEBUGWALK_H #define DEBUGWALK_H -#include "../anidbudpclient_global.h" +#include "anidbudpclient_global.h" #include "abstractwalk.h" namespace RenameParser { diff --git a/renameparser/evaluatewalk.h b/renameparser/evaluatewalk.h index 6d6345f..758b8c0 100644 --- a/renameparser/evaluatewalk.h +++ b/renameparser/evaluatewalk.h @@ -1,7 +1,7 @@ #ifndef EVALUATEWALK_H #define EVALUATEWALK_H -#include "../anidbudpclient_global.h" +#include "anidbudpclient_global.h" #include "abstractwalk.h" #include diff --git a/renameparser/renameengine.h b/renameparser/renameengine.h index 34128ad..a072984 100644 --- a/renameparser/renameengine.h +++ b/renameparser/renameengine.h @@ -4,7 +4,7 @@ #include #include -#include "../anidbudpclient_global.h" +#include "anidbudpclient_global.h" #include "abstractparser.h" #include "functions.h"