-
Notifications
You must be signed in to change notification settings - Fork 32
/
CMakeLists.txt
46 lines (40 loc) · 1.24 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
# CMakeLists.txt
cmake_minimum_required(VERSION 3.15)
project(cpp_template)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT APPLE)
# set(CMAKE_CXX_CLANG_TIDY clang-tidy)
endif()
# Find dependencies provided by vcpkg (via vcpkg.cmake)
find_package(unofficial-sqlite3 CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
set(
CPP_TEMPLATE_SOURCES
src/main.cpp
)
set(
CPP_TEMPLATE_TEST_SOURCES
src/test.cpp
)
# main target
add_executable(main ${CPP_TEMPLATE_SOURCES})
target_link_libraries(main PRIVATE unofficial::sqlite3::sqlite3 fmt::fmt-header-only)
set_property(TARGET main PROPERTY CXX_STANDARD 23)
# tests target
add_executable(tests ${CPP_TEMPLATE_TEST_SOURCES})
target_link_libraries(tests PRIVATE unofficial::sqlite3::sqlite3 fmt::fmt-header-only)
set_property(TARGET tests PROPERTY CXX_STANDARD 23)
enable_testing()
add_test(tests tests)
add_custom_target(
check-format
COMMAND clang-format --dry-run ${CPP_TEMPLATE_SOURCES} ${CPP_TEMPLATE_TEST_SOURCES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "checking format in src..."
)
add_custom_target(
format
COMMAND clang-format -i ${CPP_TEMPLATE_SOURCES} ${CPP_TEMPLATE_TEST_SOURCES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "checking format in src..."
)