@@ -12,6 +12,7 @@ option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
12
12
13
13
set (IS_MAIN_FILE CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
14
14
option (BUILD_TESTING "Enable build of tests" IS_MAIN_FILE)
15
+ option (ENABLE_INSTALL "Enable the installation of the library" "NOT IS_MAIN_FILE" )
15
16
16
17
include ("cmake/HunterGate.cmake" )
17
18
include ("cmake/Catch.cmake" )
@@ -26,6 +27,32 @@ project(SQLiteModernCpp LANGUAGES CXX)
26
27
hunter_add_package(sqlite3)
27
28
find_package (sqlite3 CONFIG REQUIRED)
28
29
30
+ add_library (SQLiteModernCpp INTERFACE )
31
+
32
+ target_include_directories (SQLiteModernCpp INTERFACE
33
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR} /hdr>
34
+ )
35
+
36
+ include (GNUInstallDirs)
37
+
38
+ if (ENABLE_INSTALL)
39
+ install (
40
+ TARGETS SQLiteModernCpp
41
+ EXPORT SQLiteModernCppConfig
42
+ INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
43
+ )
44
+
45
+ install (
46
+ EXPORT SQLiteModernCppConfig
47
+ DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/SQLiteModernCpp"
48
+ NAMESPACE SQLiteModernCpp::
49
+ )
50
+
51
+ install (
52
+ DIRECTORY ${CMAKE_CURRENT_LIST_DIR} /hdr/
53
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
54
+ )
55
+ endif ()
29
56
30
57
if (BUILD_TESTING)
31
58
hunter_add_package(Catch)
@@ -34,22 +61,22 @@ if(BUILD_TESTING)
34
61
set (TEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /tests)
35
62
file (GLOB TEST_SOURCES ${TEST_SOURCE_DIR} /*.cc)
36
63
37
- IF (NOT ENABLE_SQLCIPHER_TESTS)
38
- list (REMOVE_ITEM TEST_SOURCES ${TEST_SOURCE_DIR} /sqlcipher.cc)
39
- ENDIF (NOT ENABLE_SQLCIPHER_TESTS)
64
+ IF (NOT ENABLE_SQLCIPHER_TESTS)
65
+ list (REMOVE_ITEM TEST_SOURCES ${TEST_SOURCE_DIR} /sqlcipher.cc)
66
+ ENDIF (NOT ENABLE_SQLCIPHER_TESTS)
40
67
41
- enable_testing ()
68
+ enable_testing ()
42
69
43
- add_executable (tests_runner ${TEST_SOURCES} )
44
- target_include_directories (tests_runner INTERFACE ${SQLITE3_INCLUDE_DIRS} )
70
+ add_executable (tests_runner ${TEST_SOURCES} )
71
+ target_include_directories (tests_runner INTERFACE ${SQLITE3_INCLUDE_DIRS} )
45
72
46
- if (ENABLE_SQLCIPHER_TESTS)
47
- target_link_libraries (tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3 -lsqlcipher)
48
- else ()
49
- target_link_libraries (tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3)
50
- endif ()
73
+ if (ENABLE_SQLCIPHER_TESTS)
74
+ target_link_libraries (tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3 -lsqlcipher)
75
+ else ()
76
+ target_link_libraries (tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3)
77
+ endif ()
51
78
52
- catch_discover_tests(tests_runner)
79
+ catch_discover_tests(tests_runner)
53
80
54
81
target_compile_options (tests_runner PUBLIC $<$<CXX_COMPILER_ID:MSVC >:/Zc:__cplusplus>)
55
82
endif ()
@@ -58,7 +85,7 @@ endif()
58
85
# YCM is the code-completion engine for (neo)vim https://github.com/Valloric/YouCompleteMe
59
86
IF (EXISTS "${CMAKE_BINARY_DIR} /compile_commands.json" )
60
87
EXECUTE_PROCESS (COMMAND ${CMAKE_COMMAND} -E copy_if_different
61
- ${CMAKE_BINARY_DIR} /compile_commands.json
62
- ${CMAKE_SOURCE_DIR} /compile_commands.json
63
- )
88
+ ${CMAKE_BINARY_DIR} /compile_commands.json
89
+ ${CMAKE_SOURCE_DIR} /compile_commands.json
90
+ )
64
91
ENDIF ()
0 commit comments