-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
144 lines (123 loc) · 4.64 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
cmake_minimum_required(VERSION 2.8)
option(EDBA_ENABLE_TESTS "Add targets for test building. In case of standalone build this would be done always" OFF)
option(EDBA_BACKEND_SQLITE3_DONT_USE_AMALGAMATION "Don`t try to use sqlite3 amalgamation shipped with edba" OFF)
option(EDBA_BACKEND_SHARED "Use backends as shared libraries for shared version of core library" ON)
option(EDBA_S_BACKEND_SHARED "Use backends as shared libraries for static version of core library" OFF)
option(EDBA_ENABLE "Enable shared versions of core libraries" ON)
option(EDBA_S_ENABLE "Enable static version of core libraries" ON)
# Use own helpers
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# Figure out if we are included from another cmake
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
message(STATUS "Easy database access library - STANDALONE mode")
set(EDBA_STANDALONE_BUILD 1)
else()
message(STATUS "Easy database access library - INCLUSIVE mode")
set(EDBA_STANDALONE_BUILD 0)
endif()
# Find boost
add_definitions(-DBOOST_ALL_DYN_LINK=1)
find_package(Boost 1.48.0 COMPONENTS date_time locale thread system unit_test_framework REQUIRED)
set(edba_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR};${Boost_INCLUDE_DIRS}" CACHE INTERNAL "edba include dirs")
if(EDBA_STANDALONE_BUILD)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/stage/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/stage/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/stage/lib)
endif()
# Add some compiler definitions
add_definitions(-DEDBA_BACKEND_LIB_PREFIX="${CMAKE_SHARED_LIBRARY_PREFIX}" -DEDBA_BACKEND_LIB_SUFFIX="${CMAKE_SHARED_LIBRARY_SUFFIX}")
if (WIN32)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -DBOOST_ALL_NO_LIB)
endif (WIN32)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8)
add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden)
endif()
endif()
# Path for self and boost headers
include_directories(${edba_INCLUDE_DIRS})
set(sources
edba/detail/exports.hpp
edba/detail/utils.hpp
edba/detail/utils.cpp
edba/detail/handle.hpp
edba/detail/bind_by_name_helper.hpp
edba/conn_info.hpp
edba/conn_info.cpp
edba/driver_manager.hpp
edba/driver_manager.cpp
edba/edba.hpp
edba/errors.hpp
edba/session.hpp
edba/session_monitor.hpp
edba/session_pool.hpp
edba/session_pool.cpp
edba/statement.hpp
edba/string_ref.hpp
edba/types.hpp
edba/transaction.hpp
edba/rowset.hpp
edba/backend/interfaces.hpp
edba/backend/implementation_base.hpp
edba/backend/implementation_base.cpp
edba/backend/statistics.hpp
edba/backend/statistics.cpp
edba/types_support/std_shared_ptr.hpp
edba/types_support/std_unique_ptr.hpp
edba/types_support/std_tuple.hpp
edba/types_support/boost_shared_ptr.hpp
edba/types_support/boost_scoped_ptr.hpp
edba/types_support/boost_tuple.hpp
edba/types_support/boost_optional.hpp
edba/types_support/boost_fusion.hpp
edba/types_support/boost_gregorian_date.hpp
edba/types_support/boost_posix_time_ptime.hpp
)
if(EDBA_ENABLE)
add_library(edba SHARED ${sources})
if (WIN32)
target_link_libraries(edba ${Boost_LIBRARIES})
else()
target_link_libraries(edba ${Boost_LIBRARIES} dl)
endif()
if(EDBA_BACKEND_SHARED)
set_target_properties(edba PROPERTIES COMPILE_DEFINITIONS "EDBA_BACKEND_SHARED")
endif()
endif()
if(EDBA_S_ENABLE)
add_library(edba_s STATIC ${sources})
set_target_properties(edba_s PROPERTIES COMPILE_DEFINITIONS "edba_STATIC")
if(EDBA_S_BACKEND_SHARED)
set_target_properties(edba_s PROPERTIES COMPILE_DEFINITIONS "EDBA_BACKEND_SHARED")
endif()
endif()
foreach(src ${sources})
string(REGEX REPLACE "(.*)/.*" "\\1" dir ${src})
string(REPLACE "/" "\\" msvc_folder ${dir})
source_group(${msvc_folder} FILES ${src})
endforeach(src ${sources})
function(edba_install_targets)
if(EDBA_STANDALONE_BUILD)
install(TARGETS ${ARGV}
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
else()
foreach(var ${ARGV})
list(FIND PROJECTS_INSTALL_LIST ${var} found)
if(NOT found EQUAL -1)
install(TARGETS ${var} RUNTIME DESTINATION .)
endif()
endforeach(var)
endif()
endfunction(edba_install_targets)
add_subdirectory(backends)
if(EDBA_STANDALONE_BUILD OR EDBA_ENABLE_TESTS)
add_subdirectory(tests)
endif()
if(EDBA_ENABLE AND EDBA_BACKEND_LIBS)
target_link_libraries(edba ${EDBA_BACKEND_LIBS})
endif()
set(edba_LIBRARIES edba CACHE INTERNAL "edba shared library")
set(edba_s_LIBRARIES edba_s ${EDBA_S_BACKEND_LIBS} "all libraries required to link with edba static core")
edba_install_targets(edba)