cmake, vscode, Qt6
authorThomas Pietrzak <thomas.pietrzak@gmail.com>
Mon, 25 Apr 2022 19:39:09 +0000 (21:39 +0200)
committerThomas Pietrzak <thomas.pietrzak@gmail.com>
Mon, 25 Apr 2022 19:39:09 +0000 (21:39 +0200)
23 files changed:
.gitignore
.gitmodules [new file with mode: 0644]
.vscode/launch.json [new file with mode: 0644]
.vscode/tasks.json [new file with mode: 0644]
CMakeLists.txt [new file with mode: 0644]
TactonDebug/AngleTester/CMakeLists.txt [new file with mode: 0644]
TactonDebug/AngleTester/angletester.cpp
TactonDebug/AngleTester/angletester.h
TactonDebug/AngleTester/main.cpp
TactonDebug/MagicCircle/CMakeLists.txt [new file with mode: 0644]
TactonDebug/MagicCircle/magiccircle.cpp
TactonDebug/MagicCircle/magiccircle.h
TactonDebug/MagicCircle/main.cpp
TactonDebug/TactonDebug/CMakeLists.txt [new file with mode: 0644]
TactonDebug/TactonDebug/main.cpp
TactonDebug/TactonDebug/tactondebug.cpp
TactonDebug/TactonDebug/tactondebug.h
TactonPlayer/ArduinoSerial [new submodule]
TactonPlayer/CMakeLists.txt [new file with mode: 0644]
TactonPlayer/Tacton.cpp
TactonPlayer/Tacton.hpp
TactonPlayer/TactonPlayer.cpp
TactonPlayer/TactonPlayer.hpp

index 4db2c13ad6d11cb45879d5b0f8c47c3320f6db7b..a3a26233e8dbab765626f972fca9a1cc71e15b6a 100644 (file)
@@ -1,8 +1,28 @@
 *.zip
+build
 
 # Created by https://www.toptal.com/developers/gitignore/api/c++,visualstudio,visualstudiocode,xcode,sublimetext,qt,qtcreator,macos,windows,linux
 # Edit at https://www.toptal.com/developers/gitignore?templates=c++,visualstudio,visualstudiocode,xcode,sublimetext,qt,qtcreator,macos,windows,linux
 
+### CMake ###
+CMakeLists.txt.user
+CMakeCache.txt
+CMakeFiles
+CMakeScripts
+Testing
+Makefile
+cmake_install.cmake
+install_manifest.txt
+compile_commands.json
+CTestTestfile.cmake
+CPack*.cmake
+_deps
+DartConfiguration.tcl
+
+### CMake Patch ###
+# External projects
+*-prefix/
+
 ### C++ ###
 # Prerequisites
 *.d
diff --git a/.gitmodules b/.gitmodules
new file mode 100644 (file)
index 0000000..b890c45
--- /dev/null
@@ -0,0 +1,3 @@
+[submodule "TactonPlayer/ArduinoSerial"]
+       path = TactonPlayer/ArduinoSerial
+       url = https://github.com/RackhamLeNoir/arduinoserial
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644 (file)
index 0000000..e0ff6cd
--- /dev/null
@@ -0,0 +1,52 @@
+{
+  // Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
+  // Pointez pour afficher la description des attributs existants.
+  // Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
+  "version": "0.2.0",
+  "configurations": [
+    {
+      "name": "Angle tester",
+      "type": "cppdbg",
+      "request": "launch",
+      "program": "${workspaceFolder}/build/TactonDebug/AngleTester/AngleTester",
+      "args": [],
+      "environment": [],
+      "cwd": "${workspaceFolder}/TactonDebug/AngleTester/",
+      "externalConsole": false,
+      "logging": {
+        "moduleLoad": false,
+        "trace": true
+      },
+      "MIMode": "lldb",
+      "showDisplayString": true
+    },
+    {
+      "name": "Tacton Debug",
+      "type": "cppdbg",
+      "request": "launch",
+      "program": "${workspaceFolder}/build/TactonDebug/TactonDebug/TactonDebug",
+      "args": [],      "cwd": "${workspaceFolder}/TactonDebug/TactonDebug/",
+      "externalConsole": false,
+      "logging": {
+        "moduleLoad": false,
+        "trace": true
+      },
+      "MIMode": "lldb",
+      "showDisplayString": true
+    },
+    {
+      "name": "Magic circle",
+      "type": "cppdbg",
+      "request": "launch",
+      "program": "${workspaceFolder}/build/TactonDebug/MagicCircle/MagicCircle",
+      "environment": [],      "cwd": "${workspaceFolder}/TactonDebug/MagicCircle/",
+      "externalConsole": false,
+      "logging": {
+        "moduleLoad": false,
+        "trace": true
+      },
+      "MIMode": "lldb",
+      "showDisplayString": true
+    }
+  ]
+}
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644 (file)
index 0000000..eb7fd53
--- /dev/null
@@ -0,0 +1,4 @@
+{
+       "version": "2.0.0",
+       "tasks": []
+}
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0d6e21c
--- /dev/null
@@ -0,0 +1,7 @@
+cmake_minimum_required(VERSION 3.0.0)
+project(TactonTools VERSION 0.1.0)
+
+add_subdirectory(TactonPlayer)
+add_subdirectory(TactonDebug/AngleTester)
+add_subdirectory(TactonDebug/MagicCircle)
+add_subdirectory(TactonDebug/TactonDebug)
diff --git a/TactonDebug/AngleTester/CMakeLists.txt b/TactonDebug/AngleTester/CMakeLists.txt
new file mode 100644 (file)
index 0000000..81a8fbd
--- /dev/null
@@ -0,0 +1,13 @@
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(APPLE AND EXISTS /usr/local/opt/qt6)
+       list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt6")
+endif()
+
+find_package(Qt6 REQUIRED COMPONENTS Widgets)
+
+add_executable(AngleTester main.cpp angletester.cpp)
+
+target_link_libraries(AngleTester PRIVATE TactonPlayer Qt6::Core Qt6::Gui Qt6::Widgets)
index e3656be78d06ede18cabe4548d63b9bbc145a57a..1d75ba728c66a6e9072016e7b5f1b1eac1961684 100644 (file)
@@ -2,7 +2,7 @@
 \r
 #include <cmath>\r
 \r
-AngleTester::AngleTester(QWidget *parent, Qt::WFlags flags)\r
+AngleTester::AngleTester(QWidget *parent, Qt::WindowFlags flags)\r
        : QMainWindow(parent, flags)\r
 {\r
        try\r
index 9fecca08ae94837518a0ecede79690ea1848123e..99f6e44cdedfdd9418d2b43bc5345b51d09ee9da 100644 (file)
@@ -1,17 +1,17 @@
 #ifndef ANGLETESTER_H\r
 #define ANGLETESTER_H\r
 \r
-#include <QtGui/QMainWindow>\r
+#include <QMainWindow>\r
 #include "ui_angletester.h"\r
 \r
-#include <TactonPlayer\TactonPlayer.hpp>\r
+#include <TactonPlayer.hpp>\r
 \r
 class AngleTester : public QMainWindow, Ui::AngleTesterClass\r
 {\r
        Q_OBJECT\r
 \r
        public:\r
-               AngleTester(QWidget *parent = 0, Qt::WFlags flags = 0);\r
+               AngleTester(QWidget *parent = 0, Qt::WindowFlags flags = Qt::Widget);\r
                ~AngleTester();\r
 \r
        public slots:\r
index d8f4cead7c74936e6a03c7aa143069775414d4c8..8c1597fdae0793d1b54c224b87f2491ffa5177e8 100644 (file)
@@ -1,5 +1,5 @@
 #include "angletester.h"\r
-#include <QtGui/QApplication>\r
+#include <QApplication>\r
 \r
 int main(int argc, char *argv[])\r
 {\r
diff --git a/TactonDebug/MagicCircle/CMakeLists.txt b/TactonDebug/MagicCircle/CMakeLists.txt
new file mode 100644 (file)
index 0000000..9b2a53d
--- /dev/null
@@ -0,0 +1,13 @@
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(APPLE AND EXISTS /usr/local/opt/qt6)
+       list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt6")
+endif()
+
+find_package(Qt6 REQUIRED COMPONENTS Widgets)
+
+add_executable(MagicCircle main.cpp magiccircle.cpp)
+
+target_link_libraries(MagicCircle PUBLIC TactonPlayer Qt6::Core Qt6::Gui Qt6::Widgets)
index 6ea4475d95315a6cdb52d6b0f97dceadf430286f..888724657e0a816e74b61365fbe34bdd4bca3fbe 100644 (file)
@@ -2,7 +2,7 @@
 \r
 #include <cmath>\r
 \r
-MagicCircle::MagicCircle(QWidget *parent, Qt::WFlags flags)\r
+MagicCircle::MagicCircle(QWidget *parent, Qt::WindowFlags flags)\r
        : QMainWindow(parent, flags), _timer(this), _angle(0), _clockwise(true)\r
 {\r
        try\r
index 3002144ea5c852dc260e0224bf94f9e6ce62ba91..f23bb4f56946abb45ae864fe69ed07a2183accfc 100644 (file)
@@ -1,19 +1,19 @@
 #ifndef MAGICCIRCLE_H\r
 #define MAGICCIRCLE_H\r
 \r
-#include <QtGui/QMainWindow>\r
+#include <QMainWindow>\r
 #include "ui_magiccircle.h"\r
 \r
 #include <QTimer>\r
 \r
-#include <TactonPlayer\TactonPlayer.hpp>\r
+#include <TactonPlayer.hpp>\r
 \r
 class MagicCircle : public QMainWindow, Ui::MagicCircleClass\r
 {\r
        Q_OBJECT\r
 \r
        public:\r
-               MagicCircle(QWidget *parent = 0, Qt::WFlags flags = 0);\r
+               MagicCircle(QWidget *parent = 0, Qt::WindowFlags flags = Qt::Widget);\r
                ~MagicCircle();\r
 \r
        public slots:\r
index 288aa7c5303b96ad70a277892e79f9d53f137e44..18df712f2ef6bf88aa2988bd0b041d81ab5c937c 100644 (file)
@@ -1,5 +1,5 @@
 #include "magiccircle.h"\r
-#include <QtGui/QApplication>\r
+#include <QApplication>\r
 \r
 int main(int argc, char *argv[])\r
 {\r
diff --git a/TactonDebug/TactonDebug/CMakeLists.txt b/TactonDebug/TactonDebug/CMakeLists.txt
new file mode 100644 (file)
index 0000000..227bbbb
--- /dev/null
@@ -0,0 +1,13 @@
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_AUTOUIC ON)
+
+if(APPLE AND EXISTS /usr/local/opt/qt6)
+       list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt6")
+endif()
+
+find_package(Qt6 REQUIRED COMPONENTS Widgets)
+
+add_executable(TactonDebug main.cpp tactondebug.cpp)
+
+target_link_libraries(TactonDebug PUBLIC TactonPlayer Qt6::Core Qt6::Gui Qt6::Widgets)
index 7cb5b80c8ee84f28edc510e5fa6015d3672bb261..8a2e3dd1ac134af4b6fcaa3b6285165692ac2954 100644 (file)
@@ -1,5 +1,5 @@
 #include "tactondebug.h"\r
-#include <QtGui/QApplication>\r
+#include <QApplication>\r
 \r
 int main(int argc, char *argv[])\r
 {\r
index e370ca70176fc1642a39ce4d34e398c51085cbcd..4ebdec38ba280c7557afdbdc13eaf1b8bee15f66 100644 (file)
@@ -5,7 +5,7 @@ int TactonDebug::MaxFrequency = 400;
 int TactonDebug::MaxAmplitude = 255;\r
 int TactonDebug::MaxDuration = 2000;\r
 \r
-TactonDebug::TactonDebug(QWidget *parent, Qt::WFlags flags)\r
+TactonDebug::TactonDebug(QWidget *parent, Qt::WindowFlags flags)\r
 :QMainWindow(parent, flags)\r
 {\r
        try\r
index ca468af3b0fa958434906f8897286f0041b486f7..c385d47a01db56d0723026f2e783151038db44d1 100644 (file)
@@ -1,17 +1,17 @@
 #ifndef TACTONDEBUG_H\r
 #define TACTONDEBUG_H\r
 \r
-#include <QtGui/QMainWindow>\r
+#include <QMainWindow>\r
 #include "ui_tactondebug.h"\r
 \r
-#include <TactonPlayer\TactonPlayer.hpp>\r
+#include <TactonPlayer.hpp>\r
 \r
 class TactonDebug : public QMainWindow, Ui::TactonDebugClass\r
 {\r
        Q_OBJECT\r
 \r
        public:\r
-               TactonDebug(QWidget *parent = 0, Qt::WFlags flags = 0);\r
+               TactonDebug(QWidget *parent = 0, Qt::WindowFlags flags = Qt::Widget);\r
                ~TactonDebug();\r
 \r
        public slots:\r
diff --git a/TactonPlayer/ArduinoSerial b/TactonPlayer/ArduinoSerial
new file mode 160000 (submodule)
index 0000000..975c6c1
--- /dev/null
@@ -0,0 +1 @@
+Subproject commit 975c6c196580d3c928e76cb1514912bd42d16315
diff --git a/TactonPlayer/CMakeLists.txt b/TactonPlayer/CMakeLists.txt
new file mode 100644 (file)
index 0000000..014e598
--- /dev/null
@@ -0,0 +1,12 @@
+add_subdirectory(ArduinoSerial)
+
+set(source_files 
+  Tacton.cpp 
+  TactonPlayer.cpp
+)
+add_library(TactonPlayer ${source_files})
+
+target_link_libraries(TactonPlayer PUBLIC ArduinoSerial)
+
+target_include_directories(TactonPlayer INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+
index 60c47af7f6529e8d123bf18bd4e1dab904a18bea..ca513a5416eba92a0254017ebdc4dbce70300c88 100644 (file)
@@ -181,28 +181,28 @@ const unsigned int Tacton::getNbFrames() const
        return _nbframes;\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setPattern(char pattern)\r
+void Tacton::setPattern(char pattern)\r
 {\r
        setPattern(0, pattern);\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setPattern(unsigned int frame, char pattern)\r
+void Tacton::setPattern(unsigned int frame, char pattern)\r
 {\r
        if (frame < _nbframes)\r
                _patterns[frame] = pattern;\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setPattern(char *pattern)\r
+void Tacton::setPattern(char *pattern)\r
 {\r
        setPattern(0, pattern);\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setPattern(const char *pattern)\r
+void Tacton::setPattern(const char *pattern)\r
 {\r
        setPattern(0, pattern);\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setPattern(unsigned int frame, char *pattern)\r
+void Tacton::setPattern(unsigned int frame, char *pattern)\r
 {\r
        if (frame < _nbframes)\r
        {\r
@@ -214,7 +214,7 @@ __declspec(dllexport) void Tacton::setPattern(unsigned int frame, char *pattern)
        }\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setPattern(unsigned int frame, const char *pattern)\r
+void Tacton::setPattern(unsigned int frame, const char *pattern)\r
 {\r
        if (frame < _nbframes)\r
        {\r
@@ -226,34 +226,34 @@ __declspec(dllexport) void Tacton::setPattern(unsigned int frame, const char *pa
        }\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setDuration(unsigned int duration)\r
+void Tacton::setDuration(unsigned int duration)\r
 {\r
        setDuration(0, duration);\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setDuration(unsigned int frame, unsigned int duration)\r
+void Tacton::setDuration(unsigned int frame, unsigned int duration)\r
 {\r
        if (frame < _nbframes)\r
                _durations[frame] = duration;\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setFrequency(unsigned int frequency)\r
+void Tacton::setFrequency(unsigned int frequency)\r
 {\r
        setFrequency(0, frequency);\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setFrequency(unsigned int frame, unsigned int frequency)\r
+void Tacton::setFrequency(unsigned int frame, unsigned int frequency)\r
 {\r
        if (frame < _nbframes)\r
                _frequencies[frame] = frequency;\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setAmplitude(unsigned int amplitude)\r
+void Tacton::setAmplitude(unsigned int amplitude)\r
 {\r
        setAmplitude(0, amplitude);\r
 }\r
 \r
-__declspec(dllexport) void Tacton::setAmplitude(unsigned int frame, unsigned int amplitude)\r
+void Tacton::setAmplitude(unsigned int frame, unsigned int amplitude)\r
 {\r
        if (frame < _nbframes)\r
                _amplitudes[frame] = amplitude;\r
index a0761354783c2f4a5cd9bedee4a8a22289633941..3f7dbc1e2b4fe48488edae3924da11e4401642c9 100644 (file)
 #define POS2_LEFT 0x04\r
 #define POS2_DOWN 0x08\r
 \r
-#ifdef __MACOSX__\r
-#define EXPORTED\r
-#else\r
+#ifdef _WIN32\r
        #ifdef _WINDLL\r
-       #define EXPORTED __declspec(dllexport)\r
+               #define EXPORTED __declspec(dllexport)\r
        #else \r
-       #define EXPORTED __declspec(dllimport)\r
+               #define EXPORTED __declspec(dllimport)\r
        #endif\r
+#else\r
+       #define EXPORTED\r
 #endif\r
 \r
 class EXPORTED Tacton \r
index 0b46a7c333290c54862675833f725d0f3c80cfe4..02a3d9fcd6b256de88a1c7f2b6f87985547d0129 100644 (file)
@@ -1,14 +1,27 @@
 #include "TactonPlayer.hpp"\r
 \r
-#include <ArduinoSerial\SerialWindows.hpp>\r
+#ifdef _WIN32\r
+       #include <SerialWindows.hpp>\r
+#elif defined(LINUX)\r
+       #include <SerialLinux.hpp>\r
+#else\r
+       #include <SerialMac.hpp>\r
+#endif\r
 \r
 #include <stdexcept>\r
+#include <cstring>\r
 \r
 TactonPlayer::TactonPlayer(const char *port)\r
 {\r
        try\r
        {\r
+#ifdef _WIN32\r
                _comport = new SerialWindows(port);\r
+#elif defined(LINUX)\r
+               _comport = new SerialLinux(port);\r
+#else\r
+               _comport = new SerialMac(port);\r
+#endif\r
        }\r
        catch(...)\r
        {\r
@@ -24,13 +37,13 @@ TactonPlayer::~TactonPlayer()
 void TactonPlayer::start()\r
 {\r
        if (_comport)\r
-               _comport->WriteData("S", 1);\r
+               _comport->WriteData((void *)("S"), 1);\r
 }\r
 \r
 void TactonPlayer::stop()\r
 {\r
        if (_comport)\r
-               _comport->WriteData("Q", 1);\r
+               _comport->WriteData((void *)("Q"), 1);\r
 }\r
 \r
 void TactonPlayer::regist(const Tacton &t)\r
@@ -185,7 +198,7 @@ void TactonPlayer::stopBuzz()
        if (!_comport)\r
                return;\r
 \r
-       _comport->WriteData("B", 1);\r
+       _comport->WriteData((void *)("B"), 1);\r
 }\r
 \r
 void TactonPlayer::debugRead(char *res, int nb) const\r
index 287316819048c4c3b83182531484a7ef87d312c7..cd326a50d4d01afaba39f05104c238e548fe2117 100644 (file)
@@ -3,16 +3,16 @@
 \r
 #include "Tacton.hpp"\r
 \r
-#ifdef __MACOSX__\r
 #include <Serial.hpp>\r
-#define EXPORTED\r
-#else\r
-#include <ArduinoSerial\Serial.hpp>\r
+\r
+#ifdef _WIN32\r
        #ifdef _WINDLL\r
-       #define EXPORTED __declspec(dllexport)\r
-       #else\r
-       #define EXPORTED __declspec(dllimport)\r
+               #define EXPORTED __declspec(dllexport)\r
+       #else \r
+               #define EXPORTED __declspec(dllimport)\r
        #endif\r
+#else\r
+       #define EXPORTED\r
 #endif\r
 \r
 class EXPORTED TactonPlayer\r