@@ -10,6 +10,9 @@ set(HUNTER_TLS_VERIFY ON)
10
10
11
11
option (HUNTER_ENABLED "Enable Hunter package manager support" ON )
12
12
13
+ set (IS_MAIN_FILE CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
14
+ option (BUILD_TESTING "Enable build of tests" IS_MAIN_FILE)
15
+
13
16
include ("cmake/HunterGate.cmake" )
14
17
include ("cmake/Catch.cmake" )
15
18
@@ -20,34 +23,36 @@ HunterGate(
20
23
21
24
project (SqliteModernCpp)
22
25
23
- hunter_add_package(Catch)
24
26
hunter_add_package(sqlite3)
25
-
26
- find_package (Catch2 CONFIG REQUIRED)
27
27
find_package (sqlite3 CONFIG REQUIRED)
28
28
29
- set (TEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /tests)
30
- file (GLOB TEST_SOURCES ${TEST_SOURCE_DIR} /*.cc)
29
+
30
+ if (BUILD_TESTING)
31
+ hunter_add_package(Catch)
32
+ find_package (Catch2 CONFIG REQUIRED)
33
+
34
+ set (TEST_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} /tests)
35
+ file (GLOB TEST_SOURCES ${TEST_SOURCE_DIR} /*.cc)
31
36
32
37
IF (NOT ENABLE_SQLCIPHER_TESTS)
33
38
list (REMOVE_ITEM TEST_SOURCES ${TEST_SOURCE_DIR} /sqlcipher.cc)
34
39
ENDIF (NOT ENABLE_SQLCIPHER_TESTS)
35
40
36
41
enable_testing ()
37
42
38
- add_library (sqlite_modern_cpp INTERFACE )
39
- target_include_directories (sqlite_modern_cpp INTERFACE hdr/)
40
-
41
43
add_executable (tests_runner ${TEST_SOURCES} )
42
44
target_include_directories (tests_runner INTERFACE ${SQLITE3_INCLUDE_DIRS} )
45
+
43
46
if (ENABLE_SQLCIPHER_TESTS)
44
47
target_link_libraries (tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3 -lsqlcipher)
45
48
else ()
46
49
target_link_libraries (tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3)
47
50
endif ()
48
51
49
52
catch_discover_tests(tests_runner)
50
- target_compile_options (tests_runner PUBLIC $<$<CXX_COMPILER_ID:MSVC >:/Zc:__cplusplus> )
53
+
54
+ target_compile_options (tests_runner PUBLIC $<$<CXX_COMPILER_ID:MSVC >:/Zc:__cplusplus>)
55
+ endif ()
51
56
52
57
# Place the file in the source directory, permitting us to place a single configuration file for YCM there.
53
58
# YCM is the code-completion engine for (neo)vim https://github.com/Valloric/YouCompleteMe
0 commit comments