]> Some of my projects - anidbudpclient.git/commitdiff
Add CMake build system
authorAPTX <marek321@gmail.com>
Thu, 23 Nov 2017 12:31:37 +0000 (21:31 +0900)
committerAPTX <marek321@gmail.com>
Thu, 23 Nov 2017 12:31:37 +0000 (21:31 +0900)
Paths in some headers got changed to always include from the project root.
This should allow simpler installations of the library.

28 files changed:
.gitignore
AniDBUdpClientConfig.cmake.in [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
include/AniDBUdpClient/AbstractCommand
include/AniDBUdpClient/AnimeCommand
include/AniDBUdpClient/Client
include/AniDBUdpClient/ClientQueuedCommandsModel
include/AniDBUdpClient/ClientSentCommandsModel
include/AniDBUdpClient/EpisodeCommand
include/AniDBUdpClient/File
include/AniDBUdpClient/FileCommand
include/AniDBUdpClient/FileRenameDelegate
include/AniDBUdpClient/Hash
include/AniDBUdpClient/MyListAddCommand
include/AniDBUdpClient/MyListCommand
include/AniDBUdpClient/MyListExportCommand
include/AniDBUdpClient/MyListState
include/AniDBUdpClient/RawCommand
include/AniDBUdpClient/UpdateCommand
include/AniDBUdpClient/UptimeCommand
include/AniDBUdpClient/VoteCommand
include/RenameParser/RenameEngine
renameparser/abstractparser.h
renameparser/abstractwalk.h
renameparser/analyzewalk.h
renameparser/debugwalk.h
renameparser/evaluatewalk.h
renameparser/renameengine.h

index 2f8834def66edbdd0851cb93fe00a386959ed2da..ee1331f9434a6ae7a39c570d1d8fceca07a32823 100644 (file)
@@ -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 (file)
index 0000000..b6fcc7c
--- /dev/null
@@ -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 (file)
index 0000000..e5d154e
--- /dev/null
@@ -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 $<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)
index 1e4030bf6115842bd9cf67eea044d533fb71a253..8585ef56fa9772f11902cb6bb25e12cff9b56ff7 100644 (file)
@@ -1 +1 @@
-#include "../../abstractcommand.h"
\ No newline at end of file
+#include "abstractcommand.h"
\ No newline at end of file
index a9f3607f255b00246c261e9f5fbd05e495aaadf3..46308d8a4cdeab4bc6537905c6ac0b131a17a482 100644 (file)
@@ -1 +1 @@
-#include "../../animecommand.h"
\ No newline at end of file
+#include "animecommand.h"
\ No newline at end of file
index 73445b36d2bfc160e84143747885b718b7cc997f..a7f544710e65e51a9a87c514c895e7b602c563ab 100644 (file)
@@ -1 +1 @@
-#include "../../client.h"
\ No newline at end of file
+#include "client.h"
\ No newline at end of file
index 978dd2278848a964b10c858a86219c1a308f4f0b..89f29cc639de9abd0505098f005ffd95dfab187d 100644 (file)
@@ -1 +1 @@
-#include "../../clientqueuedcommandsmodel.h"
\ No newline at end of file
+#include "clientqueuedcommandsmodel.h"
\ No newline at end of file
index 97585ef117f5b589686c327f2b99fdfd8d3246ee..f9a15589157250a2624cc5f2aeb9d4f5af47a0b8 100644 (file)
@@ -1 +1 @@
-#include "../../clientsentcommandsmodel.h"
\ No newline at end of file
+#include "clientsentcommandsmodel.h"
\ No newline at end of file
index 3dc21f530a80cffe37b037c61aa7cbcfad40ec0b..32016755428eb9e03c72e8955aa2706447cf67a4 100644 (file)
@@ -1 +1 @@
-#include "../../episodecommand.h"
\ No newline at end of file
+#include "episodecommand.h"
\ No newline at end of file
index 6431d6ca5bbcbd1f79edec135c63320c9e3d5bf5..4314c228deb9637ff86445fb27a6e60d0c5bd406 100644 (file)
@@ -1 +1 @@
-#include "../../file.h"
\ No newline at end of file
+#include "file.h"
\ No newline at end of file
index cf757bf0e216d5835ff615a9e6678ae4e2f19fe1..79354ba6066592fa9692495b94ade3085ef736c5 100644 (file)
@@ -1 +1 @@
-#include "../../filecommand.h"
\ No newline at end of file
+#include "filecommand.h"
\ No newline at end of file
index f12e405beffaad3a8ae993290253fc42b2e84834..925b4d00d6b703dae5cf057c627bce3ae523843a 100644 (file)
@@ -1 +1 @@
-#include "../../filerenamedelegate.h"
\ No newline at end of file
+#include "filerenamedelegate.h"
\ No newline at end of file
index 4ae187b83bf581ee15bc292e1423b0c3451ef20d..b4aac775bfe63aa4871b1f3437ac0c2b3ddd647d 100644 (file)
@@ -1 +1 @@
-#include "../../hash.h"
+#include "hash.h"
index 51dd0f20ceb51cbc46d3145df9d7f1b08b4496e1..0ca041267818dc5cd10825041c0e8d9388f31811 100644 (file)
@@ -1 +1 @@
-#include "../../mylistaddcommand.h"
\ No newline at end of file
+#include "mylistaddcommand.h"
\ No newline at end of file
index 5bf1b59f1c0b109da90404caa9f5d3ec4d5d8e2e..b703608dbe628f63872fdd58e5efd38a278b4c95 100644 (file)
@@ -1 +1 @@
-#include "../../mylistcommand.h"
\ No newline at end of file
+#include "mylistcommand.h"
\ No newline at end of file
index 6a6dd63cbb7d4ccbbc89fddf5eae5f84a78627e9..553bed5f6bfeda235f030cc13be27021164b9f52 100644 (file)
@@ -1 +1 @@
-#include "../../mylistexportcommand.h"
\ No newline at end of file
+#include "mylistexportcommand.h"
\ No newline at end of file
index c4dc086d2a361f36830067f7b2c83dd11f9e85ec..7b78397e46b1d4dd5891e2a9e59b9c6468736ffe 100644 (file)
@@ -1 +1 @@
-#include "../../myliststate.h"
\ No newline at end of file
+#include "myliststate.h"
\ No newline at end of file
index 03bcb1680c01a99a0f67dbdc7ba99c63471cfc2a..db9a20ca1548ba89644acdd8fd6655fc551f9aaa 100644 (file)
@@ -1 +1 @@
-#include "../../rawcommand.h"
\ No newline at end of file
+#include "rawcommand.h"
\ No newline at end of file
index ee84b27dddbf7026ff75d79abd2435129c73e3fb..6f813fee1fab06f23da56a90c562d670b72b94f2 100644 (file)
@@ -1 +1 @@
-#include "../../updatecommand.h"
\ No newline at end of file
+#include "updatecommand.h"
\ No newline at end of file
index 24e18a1970ade548c089dd5fe8dba643282e2f79..7f24859af42eddcefbca3b4a6f9331ed7efbc0e0 100644 (file)
@@ -1 +1 @@
-#include "../../uptimecommand.h"
\ No newline at end of file
+#include "uptimecommand.h"
\ No newline at end of file
index 019b43129b7654cbaefde0573304b64074ad1ef4..8dbb9074d6a461ffd29058595e0223bce3926172 100644 (file)
@@ -1 +1 @@
-#include "../../votecommand.h"
\ No newline at end of file
+#include "votecommand.h"
\ No newline at end of file
index 2015b6782798f9bf760ea6c62323ece5a2e203e6..943eac5b5b6ced715aa7f76dae040d9b2eb6829f 100644 (file)
@@ -1 +1 @@
-#include "../../renameparser/renameengine.h"
\ No newline at end of file
+#include "renameparser/renameengine.h"
\ No newline at end of file
index 7ea65738a53719d4b38be13535552158f231fb6d..ca4ceed28cdb7e3ad3744846397f6d1d0dd498c2 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef ABSTRACTPARSER_H
 #define ABSTRACTPARSER_H
 
-#include "../anidbudpclient_global.h"
+#include "anidbudpclient_global.h"
 #include <QString>
 #include <QStringList>
 #include <QMap>
index ce47944b3d3ae5b7c84a41f7d018de0f75a99c8e..64f53e6d02dd52595ee62248a955f6c66fa87287 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef ABSTRACTWALK_H
 #define ABSTRACTWALK_H
 
-#include "../anidbudpclient_global.h"
+#include "anidbudpclient_global.h"
 #include "ast.h"
 #include <QSharedPointer>
 #include <QMap>
index 478de1152896d073f9fc2cc6872ef1e20a11eab0..6dc242133a3463674b1be84a31197a493db54729 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef ANALYZEWALK_H
 #define ANALYZEWALK_H
 
-#include "../anidbudpclient_global.h"
+#include "anidbudpclient_global.h"
 #include "abstractwalk.h"
 #include <QStringList>
 
index b9906328ad6c56ff60acfee46fc79734392e625f..11055ae0301c694f5c7d4e276a615ed37b71dfce 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef DEBUGWALK_H
 #define DEBUGWALK_H
 
-#include "../anidbudpclient_global.h"
+#include "anidbudpclient_global.h"
 #include "abstractwalk.h"
 
 namespace RenameParser {
index 6d6345f43a258fd76c9409274dee22ffc3c58bec..758b8c04ae0b89c23ca41ee88f08518265c12ec6 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef EVALUATEWALK_H
 #define EVALUATEWALK_H
 
-#include "../anidbudpclient_global.h"
+#include "anidbudpclient_global.h"
 #include "abstractwalk.h"
 
 #include <QStack>
index 34128ad05871f9bdb7e8e0104a41f150591f6ac5..a0729849a33915185998e24111456565ac159262 100644 (file)
@@ -4,7 +4,7 @@
 #include <QString>
 #include <QMap>
 
-#include "../anidbudpclient_global.h"
+#include "anidbudpclient_global.h"
 #include "abstractparser.h"
 #include "functions.h"