forked from fnc12/sqlite_orm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
78 lines (56 loc) · 2.25 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
cmake_minimum_required (VERSION 3.16.0)
# Handling C++ standard version to use
option(SQLITE_ORM_ENABLE_CXX_17 "Enable C++ 17" OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(SQLITE_ORM_ENABLE_CXX_17)
set(CMAKE_CXX_STANDARD 17)
message(STATUS "SQLITE_ORM: Build with C++17 features")
else()
# fallback to C++14 if there is no special instruction
set(CMAKE_CXX_STANDARD 14)
message(STATUS "SQLITE_ORM: Build with C++14 features")
endif()
set(CMAKE_CXX_EXTENSIONS OFF)
# PACKAGE_VERSION is used by cpack scripts currently
# Both sqlite_orm_VERSION and PACKAGE_VERSION should be the same for now
set(sqlite_orm_VERSION "1.3.0")
set(PACKAGE_VERSION ${sqlite_orm_VERSION})
project("sqlite_orm" VERSION ${PACKAGE_VERSION})
set(CMAKE_VERBOSE_MAKEFILE ON)
message(STATUS "Configuring ${CMAKE_PROJECT_NAME} ${sqlite_orm_VERSION}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
include(CTest)
### Dependencies
add_subdirectory(dependencies)
### Main Build Targets
set(SqliteOrm_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/include")
add_library(sqlite_orm INTERFACE)
add_library(sqlite_orm::sqlite_orm ALIAS sqlite_orm)
find_package(SQLite3 REQUIRED)
target_link_libraries(sqlite_orm INTERFACE SQLite::SQLite3)
target_sources(sqlite_orm INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/sqlite_orm/sqlite_orm.h>)
target_include_directories(sqlite_orm INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
include(ucm)
if (MSVC)
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
add_compile_options(/EHsc)
add_compile_options(/Zc:__cplusplus)
if ("${CMAKE_GENERATOR}" MATCHES "(Win64|x64)")
message(STATUS "Add /bigobj flag to compiler")
add_compile_options(/bigobj)
endif()
endif()
ucm_print_flags()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
# Tests
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
add_subdirectory(tests)
endif()
option(BUILD_EXAMPLES ON)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
### Packaging
add_subdirectory(packaging)