blob: ffd50c9b14c98d412bbb564d2c9f6cbd20ee244e (
plain) (
blame)
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
79
80
81
82
83
84
85
86
87
|
## CMakeLists.txt - Build recipe -----------------------------------*- CMake -*-
##
## This file is part of ck, the config keeper
##
## -----------------------------------------------------------------------------
##
## Copyright (C) 2018 Anastasis Grammenos
## GPLv3 (see LICENCE for the full notice)
##
## -------------------------------------------------------------------------- */
cmake_minimum_required (VERSION 3.5.6)
project(ck C)
set(CMAKE_C_COMPILER clang)
option(CK_ASAN "Build with asan")
# compiler flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
if(CK_ASAN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
endif(CK_ASAN)
# Set project directories
set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(RES_DIR ${CMAKE_CURRENT_SOURCE_DIR}/res)
set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)
set(UNIT_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/unit)
# Set source code locations
set(ckBin_src ${SRC_DIR}/ck.c)
set(ckUnitTest_src ${UNIT_TEST_DIR}/ck-test.c)
set(ckLib_src
${SRC_DIR}/actionparser.c
${SRC_DIR}/actions.c
${SRC_DIR}/actionhelper.c
${SRC_DIR}/confparser.c
${SRC_DIR}/dblayer.c
${SRC_DIR}/dbhelper.c
${SRC_DIR}/ckutil.c
${SRC_DIR}/cklist.c
)
set(ckLib_hdr
${SRC_DIR}/actionparser.h
${SRC_DIR}/actions.h
${SRC_DIR}/actionhelper.h
${SRC_DIR}/confparser.h
${SRC_DIR}/dblayer.h
${SRC_DIR}/dbhelper.h
${SRC_DIR}/ckutil.h
${SRC_DIR}/cklist.h
)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${RES_DIR}/cmake)
find_package(SQLite3)
# Include directories
include_directories(${SRC_DIR})
include_directories(${PROJECT_BINARY_DIR})
include_directories(${CMAKE_BINARY_DIR})
include_directories(${SQLITE3_INCLUDE_DIRS})
# Create the shared library
add_library (ckLib SHARED
${ckLib_src}
${ckLib_hdr}
)
# Link
add_executable(ck ${ckBin_src})
target_link_libraries(ck ckLib)
target_link_libraries(ck ${SQLITE3_LIBRARIES})
## unit test
add_executable(ck-test ${ckUnitTest_src})
target_link_libraries(ck-test ckLib)
target_link_libraries(ck-test ${SQLITE3_LIBRARIES})
# copy test files
set(BIN_TESTS_DIR ${CMAKE_BINARY_DIR}/res/tests)
set(PROJECT_TESTING_GROUNDS ${CMAKE_BINARY_DIR}/test_files)
configure_file(${TESTS_DIR}/init ${BIN_TESTS_DIR}/init @ONLY)
configure_file(${TESTS_DIR}/add ${BIN_TESTS_DIR}/add @ONLY)
configure_file(${TESTS_DIR}/list ${BIN_TESTS_DIR}/list @ONLY)
# check_ck
configure_file(${RES_DIR}/check_ck check_ck @ONLY)
|