-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
97 lines (73 loc) · 2.91 KB
/
Copy pathCMakeLists.txt
File metadata and controls
97 lines (73 loc) · 2.91 KB
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
cmake_minimum_required (VERSION 2.8)
# project name
set(PROJECT_NAME ORM)
project(${PROJECT_NAME})
# setup version numbers
set(VERSION_MAJOR 0)
set(VERSION_MINOR 4)
set(VERSION_PATCH 3)
include(cmake/macro.cmake)
include(cmake/compiler.cmake)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules;${CMAKE_SOURCE_DIR}")
# add the header path
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
# set_option(ORM_COLUMN_PRIMARY_KEY "pk" str "The column name for the table primary keys")
set_option(ORM_BUILD_SUPPORT_SQLITE3 TRUE BOOL "TRUE to build support for sqlite3 backends, FALSE to ignore them")
set_option(ORM_BUILD_SUPPORT_MYSQL FALSE BOOL "TRUE to build support for Mysql backends, FALSE to ignore them")
set_option(ORM_BUILD_EXAMPLES TRUE BOOL "TRUE to build the examples, FALSE to ignore them")
set_option(ORM_BUILD_DOC TRUE BOOL "TRUE to generate the API documentation, FALSE to ignore it")
if(ORM_BUILD_SUPPORT_SQLITE3)
if(UNIX)
find_library(LIB_PTHREAD pthread)
set(LIBS ${LIBS} ${LIB_PTHREAD})
endif()
add_definitions(-DSQLITE_OMIT_LOAD_EXTENSION)
endif()
if(ORM_BUILD_SUPPORT_MYSQL)
find_package(MySQL REQUIRED)
include_directories(${MYSQL_INCLUDE_DIR})
set(LIBS ${LIBS} ${MYSQL_LIBRARIES})
endif()
set(WARNING "")
set(FLAGS "")
set(CMAKE_CXX_FLAGS "")
set(CMAKE_C_FLAGS "")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(LIB_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_SOURCE_DIR}/lib )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_SOURCE_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_SOURCE_DIR}/lib )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
if(COMPILER_NAME STREQUAL "msvc")
#add_definitions("/Za")
add_definitions("/EHsc")
add_definitions("/DORM_USE_MSVC")
# Workaround for "error LNK2026: module unsafe for SAFESEH"
# when compiling with certain externally compiled libraries with VS2012.
# This disables safe exception handling by default.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
else()
add_definitions("-g")
set(CMAKE_CXX_FLAGS "-std=c++11")
endif()
if(ORM_COLUMN_PRIMARY_KEY)
add_definitions(-DORM_COLUMN_PRIMARY_KEY="${ORM_COLUMN_PRIMARY_KEY}")
endif()
#add dependencies
include_directories(extlibs)
# add the subdirectories
add_subdirectory(src/ORM)
#build exemples
if(ORM_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
#build doc
if(ORM_BUILD_DOC)
add_subdirectory(doc)
endif()