]> Some of my projects - anidbudpclient.git/commitdiff
Add CMake build system
authorAPTX <redacted>
Thu, 23 Nov 2017 12:31:37 +0000 (21:31 +0900)
committerAPTX <redacted>
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 2f8834d..ee1331f 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 1e4030b..8585ef5 100644 (file)
@@ -1 +1 @@
-#include "../../abstractcommand.h"
\ No newline at end of file
+#include "abstractcommand.h"
\ No newline at end of file
index a9f3607..46308d8 100644 (file)
@@ -1 +1 @@
-#include "../../animecommand.h"
\ No newline at end of file
+#include "animecommand.h"
\ No newline at end of file
index 73445b3..a7f5447 100644 (file)
@@ -1 +1 @@
-#include "../../client.h"
\ No newline at end of file
+#include "client.h"
\ No newline at end of file
index 978dd22..89f29cc 100644 (file)
@@ -1 +1 @@
-#include "../../clientqueuedcommandsmodel.h"
\ No newline at end of file
+#include "clientqueuedcommandsmodel.h"
\ No newline at end of file
index 97585ef..f9a1558 100644 (file)
@@ -1 +1 @@
-#include "../../clientsentcommandsmodel.h"
\ No newline at end of file
+#include "clientsentcommandsmodel.h"
\ No newline at end of file
index 3dc21f5..3201675 100644 (file)
@@ -1 +1 @@
-#include "../../episodecommand.h"
\ No newline at end of file
+#include "episodecommand.h"
\ No newline at end of file
index 6431d6c..4314c22 100644 (file)
@@ -1 +1 @@
-#include "../../file.h"
\ No newline at end of file
+#include "file.h"
\ No newline at end of file
index cf757bf..79354ba 100644 (file)
@@ -1 +1 @@
-#include "../../filecommand.h"
\ No newline at end of file
+#include "filecommand.h"
\ No newline at end of file
index f12e405..925b4d0 100644 (file)
@@ -1 +1 @@
-#include "../../filerenamedelegate.h"
\ No newline at end of file
+#include "filerenamedelegate.h"
\ No newline at end of file
index 4ae187b..b4aac77 100644 (file)
@@ -1 +1 @@
-#include "../../hash.h"
+#include "hash.h"
index 51dd0f2..0ca0412 100644 (file)
@@ -1 +1 @@
-#include "../../mylistaddcommand.h"
\ No newline at end of file
+#include "mylistaddcommand.h"
\ No newline at end of file
index 5bf1b59..b703608 100644 (file)
@@ -1 +1 @@
-#include "../../mylistcommand.h"
\ No newline at end of file
+#include "mylistcommand.h"
\ No newline at end of file
index 6a6dd63..553bed5 100644 (file)
@@ -1 +1 @@
-#include "../../mylistexportcommand.h"
\ No newline at end of file
+#include "mylistexportcommand.h"
\ No newline at end of file
index c4dc086..7b78397 100644 (file)
@@ -1 +1 @@
-#include "../../myliststate.h"
\ No newline at end of file
+#include "myliststate.h"
\ No newline at end of file
index 03bcb16..db9a20c 100644 (file)
@@ -1 +1 @@
-#include "../../rawcommand.h"
\ No newline at end of file
+#include "rawcommand.h"
\ No newline at end of file
index ee84b27..6f813fe 100644 (file)
@@ -1 +1 @@
-#include "../../updatecommand.h"
\ No newline at end of file
+#include "updatecommand.h"
\ No newline at end of file
index 24e18a1..7f24859 100644 (file)
@@ -1 +1 @@
-#include "../../uptimecommand.h"
\ No newline at end of file
+#include "uptimecommand.h"
\ No newline at end of file
index 019b431..8dbb907 100644 (file)
@@ -1 +1 @@
-#include "../../votecommand.h"
\ No newline at end of file
+#include "votecommand.h"
\ No newline at end of file
index 2015b67..943eac5 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 7ea6573..ca4ceed 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 ce47944..64f53e6 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 478de11..6dc2421 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 b990632..11055ae 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 6d6345f..758b8c0 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 34128ad..a072984 100644 (file)
@@ -4,7 +4,7 @@
 #include <QString>
 #include <QMap>
 
-#include "../anidbudpclient_global.h"
+#include "anidbudpclient_global.h"
 #include "abstractparser.h"
 #include "functions.h"