aboutsummaryrefslogtreecommitdiff
path: root/Plugin.cmake
diff options
context:
space:
mode:
authorRichard Knight <q@1bpm.net>2021-07-21 22:22:01 +0100
committerRichard Knight <q@1bpm.net>2021-07-21 22:22:01 +0100
commitf71024077af151e0eeb37151fb0754e61ee9a2ea (patch)
tree89b59784cc7a0064ecd20ce783488a9522d8ff76 /Plugin.cmake
parent1b40e87a3f54a70d4994262dd7fad4297caaeca3 (diff)
downloadcsound-sqldb-f71024077af151e0eeb37151fb0754e61ee9a2ea.tar.gz
csound-sqldb-f71024077af151e0eeb37151fb0754e61ee9a2ea.tar.bz2
csound-sqldb-f71024077af151e0eeb37151fb0754e61ee9a2ea.zip
new cmake approach
Diffstat (limited to 'Plugin.cmake')
-rw-r--r--Plugin.cmake45
1 files changed, 45 insertions, 0 deletions
diff --git a/Plugin.cmake b/Plugin.cmake
new file mode 100644
index 0000000..b02b9b6
--- /dev/null
+++ b/Plugin.cmake
@@ -0,0 +1,45 @@
+set(PLUGIN_NAME sqldb)
+
+# Dependencies
+find_package(PostgreSQL)
+find_package(Sqlite3)
+find_package(MySQL)
+
+# Check databases available
+if(NOT PostgreSQL_FOUND AND NOT SQLITE3_FOUND AND NOT MYSQLCONNECTORCPP_FOUND)
+ message(FATAL_ERROR "No database libraries could be found")
+endif()
+
+# Source files
+set(CPPFILES src/opcodes.cpp)
+set(INCLUDES ${CSOUND_INCLUDE_DIRS} "include")
+set(LIBS "")
+
+if(PostgreSQL_FOUND)
+ message(STATUS "Using PostgreSQL")
+ list(APPEND CPPFILES "src/postgresql.cpp")
+ list(APPEND INCLUDES ${PostgreSQL_INCLUDE_DIRS})
+ list(APPEND LIBS ${PostgreSQL_LIBRARES})
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_POSTGRES")
+endif()
+
+if(SQLITE3_FOUND)
+ message(STATUS "Using SQLite3")
+ list(APPEND CPPFILES "src/sqlite3.cpp")
+ list(APPEND INCLUDES ${SQLITE3_INCLUDE_DIRS})
+ list(APPEND LIBS ${SQLITE3_LIBRARIES})
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_SQLITE")
+endif()
+
+if(MYSQLCONNECTORCPP_FOUND)
+ message(STATUS "Using MySQL")
+ list(APPEND CPPFILES "src/mysql.cpp")
+ list(APPEND INCLUDES ${MYSQLCONNECTORCPP_INCLUDE_DIRS})
+ list(APPEND LIBS ${MYSQLCONNECTORCPP_LIBRARIES})
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBUILD_MYSQL")
+endif()
+
+
+make_plugin(${PLUGIN_NAME} "${CPPFILES}" ${LIBS})
+target_include_directories(${PLUGIN_NAME} PRIVATE ${INCLUDES})
+