- update cmake to 3.11 for compatibility with latest cmake

- make mysql required to build, simplify linking a bit
This commit is contained in:
T1ti
2025-09-15 23:35:18 +02:00
parent 3e7961645a
commit 0a85e625fa
10 changed files with 73 additions and 55 deletions

View File

@@ -6,8 +6,9 @@
# ░███ ░░█████ ░░███ ███ ░░███ ░░███ ░░███ ░░███ ░███ ░███ ░███ ░███ ░███ ░ █ ░███ ███
# █████ ░░█████ ░░░███████░ ░░█████████ ░░█████████ █████ █████ █████ █████ ██████████ ██████████
#░░░░░ ░░░░░ ░░░░░░░ ░░░░░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░░ ░░░░░░░░░░
CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
CMAKE_MINIMUM_REQUIRED(VERSION 3.11)
CMAKE_POLICY(SET CMP0057 NEW) # "Support new IN_LIST if() operator."
cmake_policy(SET CMP0135 NEW)
SET(CMAKE_CXX_STANDARD 20)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -87,7 +88,7 @@ SET(LIBARY_OUTPUT_PATH bin)
SET(EXTERNAL_SOURCE_DIR src/external)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
OPTION(USE_SQL "Enable sql uid save ? (require mysql installed)" OFF)
# OPTION(USE_SQL "Enable sql uid save ? (require mysql installed)" OFF)
OPTION(VALIDATE_OPENGL_PROGRAMS "Validate Opengl programs" OFF)
IF(VALIDATE_OPENGL_PROGRAMS)
@@ -116,7 +117,7 @@ FetchContent_MakeAvailable(FastNoise2)
FIND_PACKAGE(Sol2 REQUIRED)
FIND_PACKAGE(Qt5 COMPONENTS Widgets OpenGLExtensions Gui Network Xml Multimedia REQUIRED)
IF(USE_SQL)
# IF(USE_SQL)
FIND_LIBRARY(MYSQL_LIBRARY NAMES libmysql
HINTS "${CMAKE_SOURCE_DIR}/../Noggit3libs/mysql")
FIND_LIBRARY(MYSQLCPPCONN_LIBRARY NAMES mysqlcppconn
@@ -124,6 +125,13 @@ IF(USE_SQL)
FIND_PATH(MYSQLCPPCONN_INCLUDE NAMES cppconn/driver.h
HINTS "${CMAKE_SOURCE_DIR}/../Noggit3libs/mysql/connector")
# Ensure we always include the parent of 'cppconn' folder
if(EXISTS "${MYSQLCPPCONN_INCLUDE}/cppconn")
set(MYSQLCPPCONN_INCLUDE "${MYSQLCPPCONN_INCLUDE}")
elseif(EXISTS "${MYSQLCPPCONN_INCLUDE}/driver.h")
get_filename_component(MYSQLCPPCONN_INCLUDE "${MYSQLCPPCONN_INCLUDE}" DIRECTORY)
endif()
IF(MYSQL_LIBRARY AND MYSQLCPPCONN_LIBRARY AND MYSQLCPPCONN_INCLUDE)
ADD_DEFINITIONS(-DUSE_MYSQL_UID_STORAGE)
SET (mysql_sources src/mysql/mysql.cpp)
@@ -132,7 +140,7 @@ IF(USE_SQL)
ELSE()
MESSAGE(FATAL_ERROR "MySQL lib or connector not found")
ENDIF()
ENDIF()
# ENDIF()
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/qt-color-widgets")
ADD_SUBDIRECTORY("${EXTERNAL_SOURCE_DIR}/framelesshelper")

View File

@@ -57,14 +57,14 @@ recent version).
* build INSTALL
* Repeat for both release and debug.
### MySQL (Optional) ###
Optional, required for MySQL GUID Storage builds.
### MySQL ###
Required for MySQL GUID Storage builds.
download MySQL server https://dev.mysql.com/downloads/installer/
and MySQL C++ Connector https://dev.mysql.com/downloads/connector/cpp/
* open CMake GUI
* enable `USE_SQL`
* set `MYSQL_LIBRARY` (path) to `libmysql.lib` from your MYSQL server install.
e.g `"C:/Program Files/MySQL/MySQL Server 8.0/lib/libmysql.lib"`
Note : In new connector versions, developments components aren't included by default anymore in the "Typical" setting, you need to enable `Legacy JDBC API->Development Components` during installation.
* set `MYSQLCPPCONN_INCLUDE` (path) to the folder containing `cppconn/driver.h` from your MYSQL Connector C++ install.
e.g `"C:/Program Files/MySQL/Connector C++ 8.0/include/jdbc"`
* set `MYSQLCPPCONN_LIBRARY` (path) to `mysqlcppconn.lib` from your MYSQL Connector C++ install.

2
cmake

Submodule cmake updated: 7a5741adae...32da4c01dc

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.11)
# version 3.4 is required as other do not work with C++14 and clang
project(NodeEditor CXX)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.11)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
include(GetGitRevisionDescription)
git_describe(GitTagVersion --tags)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.11)
project(QtAdvancedDockingSystem LANGUAGES CXX VERSION ${VERSION_SHORT})
find_package(Qt5 5.5 COMPONENTS Core Gui Widgets REQUIRED)
if (UNIX AND NOT APPLE)

View File

@@ -1,6 +1,6 @@
# http://www.linux-magazin.de/Heft-Abo/Ausgaben/2007/02/Mal-ausspannen
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.11)
set ( LIBNOISE_VERSION "1.0.0-cmake" )

View File

@@ -32,7 +32,7 @@ src/color_preview.cpp
src/color_selector.cpp
src/color_utils.cpp
src/color_wheel.cpp
src/color_widgets.qrc
# src/color_widgets.qrc
src/gradient_slider.cpp
src/hue_slider.cpp
src/swatch.cpp
@@ -59,10 +59,11 @@ qt-color-widgets/swatch.hpp
qt5_wrap_cpp(SOURCES ${HEADERS})
qt5_wrap_ui(SOURCES src/color_dialog.ui src/color_palette_widget.ui)
qt5_add_resources(SOURCES src/color_widgets.qrc)
# qt5_add_resources(SOURCES src/color_widgets.qrc)
qt5_add_resources(QRC_SOURCES src/color_widgets.qrc)
# Library
add_library(ColorWidgets-qt5 ${SOURCES})
add_library(ColorWidgets-qt5 ${SOURCES} ${QRC_SOURCES})
target_link_libraries(ColorWidgets-qt5 Qt5::Widgets)
target_include_directories (ColorWidgets-qt5 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories (ColorWidgets-qt5 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

View File

@@ -1,5 +1,5 @@
# Cmake config largely taken from catch2
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.11)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
cmake_policy(SET CMP0135 NEW)

View File

@@ -5,50 +5,54 @@
#include <QtCore/QSettings>
#include <driver.h>
#include <prepared_statement.h>
// #include <cppconn/driver.h>
// #include <cppconn/prepared_statement.h>
#include <cppconn/driver.h>
#include <cppconn/prepared_statement.h>
#include <cppconn/exception.h>
namespace
{
std::unique_ptr<sql::Connection> connect()
{
QSettings settings;
QSettings settings;
// if using release SQL binaries in debug mode it will crash https://bugs.mysql.com/bug.php?id=91238 unless using sql strings
// tcp://127.0.0.1:3306
sql::SQLString hostname = "tcp://" + settings.value("project/mysql/server").toString().toStdString() + ":" + settings.value("project/mysql/port", "3306").toString().toStdString();
sql::SQLString userName = settings.value("project/mysql/user").toString().toStdString();
sql::SQLString password = settings.value("project/mysql/pwd").toString().toStdString();
sql::SQLString schema = settings.value("project/mysql/db").toString().toStdString();
// if using release SQL binaries in debug mode it will crash https://bugs.mysql.com/bug.php?id=91238 unless using sql strings
// tcp://127.0.0.1:3306
const sql::SQLString hostname = "tcp://" + settings.value("project/mysql/server").toString().toStdString() + ":" + settings.value("project/mysql/port", "3306").toString().toStdString();
const sql::SQLString userName = settings.value("project/mysql/user").toString().toStdString();
const sql::SQLString password = settings.value("project/mysql/pwd").toString().toStdString();
const sql::SQLString schema = settings.value("project/mysql/db").toString().toStdString();
try
{
std::unique_ptr<sql::Connection> Con(get_driver_instance()->connect(hostname, userName, password));
try
{
std::unique_ptr<sql::Connection> Con(get_driver_instance()->connect(hostname, userName, password));
// crete database if it doesn't exist
std::string createdb_statement = "CREATE DATABASE IF NOT EXISTS " + schema;
std::unique_ptr<sql::PreparedStatement> dbpstmt(Con->prepareStatement(createdb_statement));
std::unique_ptr<sql::ResultSet> res(dbpstmt->executeQuery());
Con->setSchema(schema);
// crete database if it doesn't exist
std::string createdb_statement = "CREATE DATABASE IF NOT EXISTS " + schema;
std::unique_ptr<sql::PreparedStatement> dbpstmt(Con->prepareStatement(createdb_statement));
std::unique_ptr<sql::ResultSet> res(dbpstmt->executeQuery());
Con->setSchema(schema);
// create table if it doesn't exist, querries from src/sql
std::unique_ptr<sql::PreparedStatement> tablepstmt(Con->prepareStatement("CREATE TABLE IF NOT EXISTS `UIDs` ("
"`_map_id` int(11) NOT NULL,"
"`UID` int(11) NOT NULL,"
"PRIMARY KEY(`_map_id`)"
") ENGINE = InnoDB DEFAULT CHARSET = latin1;"));
std::unique_ptr<sql::ResultSet> tableres(tablepstmt->executeQuery());
// create table if it doesn't exist, querries from src/sql
std::unique_ptr<sql::PreparedStatement> tablepstmt(Con->prepareStatement("CREATE TABLE IF NOT EXISTS `UIDs` ("
"`_map_id` int(11) NOT NULL,"
"`UID` int(11) NOT NULL,"
"PRIMARY KEY(`_map_id`)"
") ENGINE = InnoDB DEFAULT CHARSET = latin1;"));
std::unique_ptr<sql::ResultSet> tableres(tablepstmt->executeQuery());
return Con;
}
catch (sql::SQLException& e)
{
return Con;
}
catch (sql::SQLException& e)
{
return nullptr;
}
return nullptr;
}
catch (std::exception& e)
{
std::cerr << "SQL Other exception: " << e.what() << std::endl;
return nullptr;
}
}
}
@@ -58,17 +62,17 @@ namespace mysql
{
QSettings settings;
// if using release SQL binaries in debug mode it will crash https://bugs.mysql.com/bug.php?id=91238 unless using sql strings
sql::SQLString hostname = "tcp://" + settings.value("project/mysql/server").toString().toStdString() + ":" + settings.value("project/mysql/port", "3306").toString().toStdString();
sql::SQLString userName = settings.value("project/mysql/user").toString().toStdString();
sql::SQLString password = settings.value("project/mysql/pwd").toString().toStdString();
sql::SQLString schema = settings.value("project/mysql/db").toString().toStdString();
const sql::SQLString hostname = "tcp://" + settings.value("project/mysql/server").toString().toStdString() + ":" + settings.value("project/mysql/port", "3306").toString().toStdString();
const sql::SQLString userName = settings.value("project/mysql/user").toString().toStdString();
const sql::SQLString password = settings.value("project/mysql/pwd").toString().toStdString();
QMessageBox prompt;
prompt.setWindowFlag(Qt::WindowStaysOnTopHint);
try
{
std::unique_ptr<sql::Connection> Con(get_driver_instance()->connect(hostname, userName, password));
sql::Driver* driver = get_driver_instance();
sql::Connection* connection = driver->connect(hostname, userName, password);
std::unique_ptr<sql::Connection> Con(connection);
prompt.setIcon(QMessageBox::Information);
prompt.setText("Succesfully connected to MySQL database.");
@@ -97,6 +101,11 @@ namespace mysql
return false;
}
catch (std::exception& e)
{
std::cerr << "SQL Other exception: " << e.what() << std::endl;
return false;
}
}
bool hasMaxUIDStoredDB(std::size_t mapID)