From e3fc62dd35bdbe07baee9577b194d606b2ef741f Mon Sep 17 00:00:00 2001 From: Pierre Proske Date: Mon, 6 Feb 2023 13:19:57 +1100 Subject: [PATCH] More fixes, should be working now --- CMakeLists.txt | 9 +++++++-- include/SQLiteCpp/SQLiteCppExport.h | 6 ++++-- sqlite3/CMakeLists.txt | 12 ++++++++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16f7fc4..0282847 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,9 +17,14 @@ endif () message(STATUS "Using c++ standard c++${CMAKE_CXX_STANDARD}") set(CMAKE_CXX_STANDARD_REQUIRED ON) -option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" ON) if(BUILD_SHARED_LIBS) -add_definitions(-DSQLITECPP_COMPILE_DLL -DSQLITECPP_EXPORT) + if(WIN32) + message("defining SQLITECPP_COMPILE_DLL") + add_definitions("-DSQLITECPP_COMPILE_DLL") + if(SQLITECPP_DLL_EXPORT) + add_definitions("-DSQLITECPP_DLL_EXPORT") + endif() + endif() endif() message (STATUS "CMake version: ${CMAKE_VERSION}") diff --git a/include/SQLiteCpp/SQLiteCppExport.h b/include/SQLiteCpp/SQLiteCppExport.h index 7242c9d..63d1e0f 100644 --- a/include/SQLiteCpp/SQLiteCppExport.h +++ b/include/SQLiteCpp/SQLiteCppExport.h @@ -19,11 +19,13 @@ /* Windows DLL export/import */ #if defined(WIN32) && defined(SQLITECPP_COMPILE_DLL) - #ifdef SQLITECPP_EXPORT + #if defined(SQLITECPP_DLL_EXPORT) #define DLL_API __declspec(dllexport) #pragma message("Exporting symbols") #else #define DLL_API __declspec(dllimport) #pragma message("Importing symbols") - #endif + #endif +#else + #define DLL_API #endif diff --git a/sqlite3/CMakeLists.txt b/sqlite3/CMakeLists.txt index 0efc3ee..ef222e9 100644 --- a/sqlite3/CMakeLists.txt +++ b/sqlite3/CMakeLists.txt @@ -11,6 +11,18 @@ add_library(sqlite3 sqlite3.h ) +if(WIN32) + if(BUILD_SHARED_LIBS) + if(SQLITECPP_DLL_EXPORT) + message("Adding __declspec(dllexport)") + add_definitions("-DSQLITE_API=__declspec(dllexport)") + else() + message("Adding __declspec(dllimport)") + add_definitions("-DSQLITE_API=__declspec(dllimport)") + endif() + endif() +endif() + add_library(SQLite::SQLite3 ALIAS sqlite3) target_include_directories(sqlite3