-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
94 lines (80 loc) · 2.69 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
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
88
89
90
91
92
93
94
cmake_minimum_required(VERSION 3.22)
project(mini_library VERSION 0.0.1 LANGUAGES C)
set(CMAKE_C_STANDARD 11)
# ON by default, use -DNOWARN=ON/OFF in Cmake command to turn ON/OFF
option(BENCH_OP "Optimization (O1, O2, O3) benchmark" OFF)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif (NOT CMAKE_BUILD_TYPE)
if (${CMAKE_BUILD_TYPE} STREQUAL Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
endif()
if (${CMAKE_BUILD_TYPE} STREQUAL Release)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -w")
endif()
### library ###
add_library(minilib
array/array_list.c
array/array_list.h
core/heap.c
core/heap.h
core/type.c
core/type.h
list/double_linked_list.c
list/double_linked_list.h
list/queue.c
list/queue.h
list/single_linked_list.c
list/single_linked_list.h
list/stack.c
list/stack.h
tree/binary_tree.c
tree/binary_tree.h
tree/tree.c
tree/tree.h
sort/selection_sort.c
sort/selection_sort.h
sort/merge_sort.c
sort/merge_sort.h
sort/heap_sort.c
sort/heap_sort.h
sort/quick_sort.c
sort/quick_sort.h
search/binary_search.c
search/binary_search.h
map/hash_map.c
map/hash_map.h
core/hash.h
core/hash.c
)
### test ###
add_subdirectory(tests)
### install ###
if (${CMAKE_BUILD_TYPE} STREQUAL Release AND
${CMAKE_PROJECT_NAME} STREQUAL mini)
set(mini_include_dest "include")
set(mini_lib_dest "lib")
set(MERGE_CMD ${CMAKE_CURRENT_BINARY_DIR}/mega-unit/merge)
MESSAGE(STATUS "MERGE CMD: " ${MERGE_CMD})
execute_process(COMMAND ${MERGE_CMD}
${CMAKE_CURRENT_SOURCE_DIR} mini.h minilib.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${MERGE_CMD}
${CMAKE_CURRENT_SOURCE_DIR} mini.c minilib.c
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/minilib.h DESTINATION "${mini_include_dest}")
install(TARGETS minilib DESTINATION "${mini_lib_dest}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Bùi Hoàng Tú")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION
"Thư viện cấu trúc dữ liệu mini.")
set(CMAKE_PROJECT_HOMEPAGE_URL "")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "standard")
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
file (READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION MINI_VERSION)
# Set a Package Version
set(CPACK_PACKAGE_VERSION "${MINI_VERSION}")
include(CPack)
endif()