-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
228 lines (182 loc) · 5.94 KB
/
CMakeLists.txt
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
cmake_minimum_required (VERSION 2.8)
project (yborm)
option (DEP_LIBS_ROOT "Path where dependency liraries (libxml2, sqlite3, cppunit, etc.) are installed"
"c:/yborm/dep_libs")
option (BOOST_ROOT "Path where Boost C++ libs are installed" "c:/boost")
option (USE_QT "Build YB.ORM against Qt" OFF)
option (SQLITE3_SRC "Path to SQLite3 amalgamation sources")
if (CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations -Wno-unused-local-typedefs -Wno-format-security")
endif()
if (UNIX)
find_path (BOOST_INCLUDEDIR boost/lexical_cast.hpp /usr/include)
else ()
find_path (BOOST_INCLUDEDIR boost/lexical_cast.hpp ${BOOST_ROOT})
endif ()
if (NOT USE_QT)
# find boost + libxml2
if (MSVC)
set (Boost_USE_STATIC_LIBS ON)
else ()
set (Boost_USE_STATIC_LIBS OFF)
endif ()
set (Boost_USE_MULTITHREADED ON)
#set (Boost_NO_SYSTEM_PATHS ON)
#set (Boost_DEBUG ON)
# You may need to explicitly set the following for MSVC 2013:
#set (Boost_COMPILER -vc120)
set (Boost_ADDITIONAL_VERSIONS "1.33.1" "1.38" "1.30.0" "1.46.1")
if (UNIX)
set (BOOST_LIBRARYDIR "/usr/lib")
endif ()
find_package (Boost 1.33.1 COMPONENTS system thread date_time chrono)
if ((NOT Boost_DATE_TIME_LIBRARY) OR (NOT Boost_THREAD_LIBRARY))
message (FATAL_ERROR "Boost not found")
endif ()
if (Boost_SYSTEM_LIBRARY)
set (YB_BOOST_LIBS ${Boost_SYSTEM_LIBRARY})
endif ()
if (Boost_CHRONO_LIBRARY)
set (YB_BOOST_LIBS ${YB_BOOST_LIBS} ${Boost_CHRONO_LIBRARY})
endif ()
set (YB_BOOST_LIBS ${YB_BOOST_LIBS} ${Boost_THREAD_LIBRARY}
${Boost_DATE_TIME_LIBRARY})
# find includes
if (UNIX)
find_path (ICONV_INCLUDES iconv.h /usr/include)
else ()
find_path (ICONV_INCLUDES iconv.h ${DEP_LIBS_ROOT}/include)
endif ()
if (UNIX)
find_path (LIBXML2_INCLUDES libxml/xmlwriter.h /usr/include/libxml2)
else ()
find_path (LIBXML2_INCLUDES libxml/xmlwriter.h ${DEP_LIBS_ROOT}/include)
endif ()
# find libs
if (MSVC)
find_library (ICONV_LIBS iconv ${DEP_LIBS_ROOT}/lib)
elseif (BORLAND)
find_library (ICONV_LIBS iconvomf ${DEP_LIBS_ROOT}/lib)
endif ()
if (UNIX)
find_library (LIBXML2_LIBS xml2)
elseif (MSVC)
find_library (LIBXML2_LIBS libxml2 ${DEP_LIBS_ROOT}/lib)
elseif (BORLAND)
find_library (LIBXML2_LIBS libxml2omf ${DEP_LIBS_ROOT}/lib)
else ()
find_library (LIBXML2_LIBS libxml2 ${DEP_LIBS_ROOT}/bin)
endif ()
else (USE_QT)
string (COMPARE EQUAL "${USE_QT}" "5" USE_QT5)
if (USE_QT5)
message (STATUS "DEBUG: Qt5 requested")
cmake_policy (SET CMP0028 NEW)
cmake_policy (SET CMP0020 NEW)
find_package (Qt5 5.0.2 REQUIRED Core Xml Sql)
message (STATUS
"DEBUG: Qt5Core_INCLUDE_DIRS=${Qt5Core_INCLUDE_DIRS}")
message (STATUS
"DEBUG: Qt5Core_LIBRARIES=${Qt5Core_LIBRARIES}")
message (STATUS
"DEBUG: Qt5Core_EXECUTABLE_COMPILE_FLAGS=${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
include_directories (
${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS}
${Qt5Sql_INCLUDE_DIRS})
set (QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Sql_LIBRARIES})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Core_EXECUTABLE_COMPILE_FLAGS}")
else (USE_QT5)
message (STATUS "DEBUG: Qt4 assumed")
find_package (Qt4 4.4.0 REQUIRED QtCore QtXml QtSql)
include (${QT_USE_FILE})
endif ()
add_definitions (-DYB_USE_QT)
endif ()
if (UNIX)
find_library (ODBC_LIBS odbc)
elseif (BORLAND)
find_library (ODBC_LIBS odbc32 c:/Borland/BCC55/Lib/PSDK)
elseif (MSVC)
find_library (ODBC_LIBS odbc32)
elseif (MINGW)
set (ODBC_LIBS -lodbc32 CACHE STRING "odbc32 lib" FORCE)
endif ()
add_definitions (-DYB_USE_ODBC)
set (USE_ODBC ON)
if (SQLITE3_SRC)
find_path (SQLITE3_INCLUDEDIR sqlite3.h ${SQLITE3_SRC})
find_path (SQLITE3_SINGLE_SOURCE sqlite3.c ${SQLITE3_SRC})
set (SQLITE3_LIBS "")
else ()
if (SQLITE3_INCLUDEDIR)
find_path (SQLITE3_INCLUDEDIR sqlite3.h ${SQLITE3_INCLUDEDIR})
elseif (UNIX)
find_path (SQLITE3_INCLUDEDIR sqlite3.h /usr/include)
else ()
find_path (SQLITE3_INCLUDEDIR sqlite3.h ${DEP_LIBS_ROOT}/include)
endif ()
if (SQLITE3_LIBDIR)
find_library (SQLITE3_LIBS sqlite3 ${SQLITE3_LIBDIR})
elseif (UNIX)
find_library (SQLITE3_LIBS sqlite3)
elseif (BORLAND)
find_library (SQLITE3_LIBS sqlite3omf ${DEP_LIBS_ROOT}/lib)
else ()
find_library (SQLITE3_LIBS sqlite3 ${DEP_LIBS_ROOT}/lib ${DEP_LIBS_ROOT}/bin)
endif ()
endif ()
if (SQLITE3_INCLUDEDIR AND (SQLITE3_LIBS OR SQLITE3_SINGLE_SOURCE))
add_definitions (-DYB_USE_SQLITE3)
set (USE_SQLITE3 ON)
else ()
set (SQLITE3_LIBS "")
set (SQLITE3_INCLUDEDIR "")
set (USE_SQLITE3 OFF)
endif ()
if (SOCI_INCLUDEDIR)
find_path (SOCI_INCLUDEDIR soci.h ${SOCI_INCLUDEDIR})
elseif (UNIX)
find_path (SOCI_INCLUDEDIR soci.h /usr/include/soci /usr/local/include/soci)
else ()
find_path (SOCI_INCLUDEDIR soci.h ${DEP_LIBS_ROOT}/include)
endif ()
if (SOCI_LIBDIR)
find_library (SOCI_LIBS soci_core ${SOCI_LIBDIR})
elseif (UNIX)
find_library (SOCI_LIBS soci_core)
else ()
find_library (SOCI_LIBS soci ${DEP_LIBS_ROOT}/lib ${DEP_LIBS_ROOT}/bin)
endif ()
if (SOCI_INCLUDEDIR AND SOCI_LIBS)
add_definitions (-DYB_USE_SOCI)
set (USE_SOCI ON)
else ()
set (SOCI_LIBS "")
set (SOCI_INCLUDEDIR "")
set (USE_SOCI OFF)
endif ()
if (BOOST_INCLUDEDIR AND (NOT BORLAND))
add_definitions (-DYB_USE_TUPLE)
endif()
if (UNIX)
find_path (CPPUNIT_INCLUDES cppunit/TestCase.h /usr/include)
else ()
find_path (CPPUNIT_INCLUDES cppunit/TestCase.h ${DEP_LIBS_ROOT}/include)
endif ()
if (UNIX)
find_library (CPPUNIT_LIBS cppunit)
elseif (MSVC)
find_library (CPPUNIT_LIBS cppunitd_dll ${DEP_LIBS_ROOT}/lib)
elseif (BORLAND)
find_library (CPPUNIT_LIBS cppunitd_bc5_dll ${DEP_LIBS_ROOT}/lib)
else ()
find_library (CPPUNIT_LIBS cppunit ${DEP_LIBS_ROOT}/lib)
endif ()
install (FILES
CHANGES COPYING
DESTINATION doc)
add_subdirectory (include)
add_subdirectory (src)
add_subdirectory (tests)
add_subdirectory (examples)
add_subdirectory (doc)