@@ -10,6 +10,9 @@ set(HUNTER_TLS_VERIFY ON)
1010
1111option (HUNTER_ENABLED "Enable Hunter package manager support" ON )
1212
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+
1316include ("cmake/HunterGate.cmake" )
1417include ("cmake/Catch.cmake" )
1518
@@ -20,34 +23,36 @@ HunterGate(
2023
2124project (SqliteModernCpp)
2225
23- hunter_add_package(Catch)
2426hunter_add_package(sqlite3)
25-
26- find_package (Catch2 CONFIG REQUIRED)
2727find_package (sqlite3 CONFIG REQUIRED)
2828
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)
3136
3237IF (NOT ENABLE_SQLCIPHER_TESTS)
3338 list (REMOVE_ITEM TEST_SOURCES ${TEST_SOURCE_DIR} /sqlcipher.cc)
3439ENDIF (NOT ENABLE_SQLCIPHER_TESTS)
3540
3641enable_testing ()
3742
38- add_library (sqlite_modern_cpp INTERFACE )
39- target_include_directories (sqlite_modern_cpp INTERFACE hdr/)
40-
4143add_executable (tests_runner ${TEST_SOURCES} )
4244target_include_directories (tests_runner INTERFACE ${SQLITE3_INCLUDE_DIRS} )
45+
4346if (ENABLE_SQLCIPHER_TESTS)
4447 target_link_libraries (tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3 -lsqlcipher)
4548else ()
4649 target_link_libraries (tests_runner Catch2::Catch2 sqlite_modern_cpp sqlite3::sqlite3)
4750endif ()
4851
4952catch_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 ()
5156
5257# Place the file in the source directory, permitting us to place a single configuration file for YCM there.
5358# YCM is the code-completion engine for (neo)vim https://github.com/Valloric/YouCompleteMe
0 commit comments