forked from mtangoo/wxDatabase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.goutputstream-O6TI6X
120 lines (98 loc) · 4.33 KB
/
.goutputstream-O6TI6X
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#To Do List
#Build Types from Options -- Debug Release
#making DLL/LIB
#Add Support for Other DB than MySQL on build
#Fix the redefined error visible when verbose=1
cmake_minimum_required (VERSION 2.8)
project (wxDatabase)
# The version number.
set (wxDATABASE_VERSION_MAJOR 1)
set (wxDATABASE_VERSION_MINOR 0)
#find_program(CMAKE_MAKE_PROGRAM NAMES make mingw32-make make.exe DOC "Find a suitable make program for building under Windows/MinGW" HINTS C:/MinGW/bin )
#Set Options
option (ENABLE_MARIADB "Enable MariaDB Database" ON)
option (ENABLE_SQLITE "Enable SQLite3 Database" ON)
option (ENABLE_PGS "Enable PostGreSQL Database" OFF)
option (ENABLE_TDS "Enable MSSQL Access with TDS Database" OFF)
option (ENABLE_ODBC "Enable ODBC Access" OFF)
option (BUILD_SAMPLE "Build Sample Application" ON)
#Build type
set(CMAKE_BUILD_TYPE Release)
#to specify wxDir on non Windows you need extra check for wxWonfig
if(WIN32)
set(wxWidgets_ROOT_DIR, "YOUR wx Path")
else(WIN32)
set(wxWidgets_ROOT_DIR, /home/stefano/Documents/developer/git/wxwidgets)
set(wxWidgets_CONFIG_EXECUTABLE "${wxWidgets_ROOT_DIR}/wx-config")
endif(WIN32)
#Set Directories
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
#Core include directories
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(SOURCES) #without thise they dont work
#Core Sources
file(GLOB CORE_SRC "src/base/*.cpp")
#append to main SRC
list(APPEND SOURCES ${CORE_SRC})
file(GLOB CORE_DB_SRC "src/database/*.cpp")
#append to main SRC
list(APPEND SOURCES ${CORE_DB_SRC})
#Support for MySQL?
if (ENABLE_MARIADB)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vendors/sqlite3/sqlite3.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/vendors/mariadb/include)
#append to main SRC
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/vendors/sqlite3/sqlite3.c")
message("Custom MariaDB Found" )
#append to main SRC
file(GLOB CORE_SQLITE_SRC "src/database/sqlite3/*.cpp")
list(APPEND SOURCES ${CORE_SQLITE_SRC})
#Tell CMake to Pass this variable_requires
add_definitions(-DwxUSE_DATABASE_MYSQL=1)
endif (ENABLE_MARIADB)
#Support for SQLite3?
if (ENABLE_SQLITE)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/vendors/sqlite3/sqlite3.h)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/vendors/sqlite3/)
#append to main SRC
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/vendors/sqlite3/sqlite3.c")
message("Custom SQLite3 Found" )
#append to main SRC
file(GLOB CORE_SQLITE_SRC "src/database/sqlite3/*.cpp")
list(APPEND SOURCES ${CORE_SQLITE_SRC})
#Tell CMake to Pass this variable_requires
add_definitions(-DwxUSE_DATABASE_SQLITE=1)
else()
find_package(SQLite3 REQUIRED)
if(SQLITE3_FOUND)
#add SQLite3 include and libs
include_directories(${SQLITE3_INCLUDE_DIRS})
#Link SQLite3 Library
TARGET_LINK_LIBRARIES(${SQLITE3_LIBRARIES})
#add wxDatabase SQLite3 Include and sources for compiling
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/database/sqlite3)
#append to main SRC
file(GLOB CORE_SQLITE_SRC "src/database/sqlite3/*.cpp")
list(APPEND SOURCES ${CORE_SQLITE_SRC})
#Tell CMake to Pass this variable_requires
add_definitions(-DwxUSE_DATABASE_SQLITE=1)
endif(SQLITE3_FOUND)
endif()
endif (ENABLE_SQLITE)
#Preprocessors
add_definitions(-DWXMAKINGDLL_DATABASE) #WXMAKINGLIB_DATABASE
#Compile library
add_library(${CMAKE_PROJECT_NAME} SHARED ${SOURCES})
#Check wxWidgets first and fail if does not exist
find_package(wxWidgets REQUIRED)
if(wxWidgets_FOUND)
include(${wxWidgets_USE_FILE})
target_link_libraries(${CMAKE_PROJECT_NAME} ${wxWidgets_LIBRARIES})
else(wxWidgets_FOUND)
message( FATAL_ERROR "wxWidgets Not Found. Please define and set wxWidgets_ROOT_DIR or add it to System path" )
endif(wxWidgets_FOUND)
if(BUILD_SAMPLE) #build Sample
add_executable (wxDatabaseApp_SQLite3 ${CMAKE_CURRENT_SOURCE_DIR}/samples/sqlite3.cpp)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/build)
target_link_libraries(wxDatabaseApp_SQLite3 ${CMAKE_PROJECT_NAME} ${wxWidgets_LIBRARIES})
endif(BUILD_SAMPLE)