forked from bangoc/cgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
199 lines (184 loc) · 8.8 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
cmake_minimum_required(VERSION 2.8)
project(cgen)
# 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})
set(CMAKE_C_STANDARD 11)
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} -g -Wall")
endif()
if (${CMAKE_BUILD_TYPE} STREQUAL Release)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -w")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
add_subdirectory(tests)
add_subdirectory(examples)
add_subdirectory(mega)
add_library(bkcgen STATIC all.c)
include(CTest)
add_test(NAME BNLeftRotate COMMAND bn_left_rotate_ut)
add_test(NAME RBInsertDelete COMMAND rb_insert_delete_ut)
add_test(NAME BNMost COMMAND bn_most_ut)
add_test(NAME BNTransplant COMMAND bn_transplant_ut)
add_test(NAME BSSearch COMMAND bs_search_ut)
add_test(NAME BNNextPrevInorder COMMAND bn_next_prev_inorder_ut)
add_test(NAME BNForeach COMMAND bn_foreach_ut)
add_test(NAME S2I COMMAND s2i_ut)
add_test(NAME S2I2 COMMAND s2i_ut2)
add_test(NAME ArrSizeCapGrow COMMAND arr_size_cap_grow_ut)
add_test(NAME ArrPushBackGtype COMMAND arr_push_back_gtype_ut)
add_test(NAME ArrPushBackStr COMMAND arr_push_back_str_ut)
add_test(NAME SLL COMMAND sll_ut)
add_test(NAME SLL_G COMMAND sll_g_ut)
add_test(NAME ArrPushBackInt COMMAND arr_push_back_int_ut)
add_test(NAME SLL_L_Queue COMMAND sll_l_queue_ut)
add_test(NAME SLL_L_Stack COMMAND sll_l_stack_ut)
add_test(NAME GTP2WHeap COMMAND gtp2wheap_ut)
add_test(NAME D2WHeap COMMAND d2wheap_ut)
add_test(NAME GTTreeMap COMMAND gt_treemap_ut)
add_test(NAME RBBuild COMMAND rb_build_ut)
add_test(NAME RBDelete COMMAND rb_delete_ut)
add_test(NAME BSimilarTree COMMAND bn_similar_tree_ut)
add_test(NAME RBIsValid COMMAND rb_is_valid_ut)
add_test(NAME RBDeleteSimilar COMMAND rb_delete_similar_ut)
add_test(NAME RBInsertDelete1K COMMAND rb_insert_delete_1k_ut)
add_test(NAME RBRandInsertDelete COMMAND
rb_rand_insert_delete_ut 10000 1000)
add_test(NAME RBInsertDeleteDuplicates COMMAND
rb_insert_delete_duplicates_ut)
add_test(NAME S2IInsertDup COMMAND s2i_insert_dup_ut)
add_test(NAME S2ISetDup COMMAND s2i_set_dup_ut)
add_test(NAME BSSearchGTE COMMAND bs_search_gte_ut)
add_test(NAME BSSearchLTE COMMAND bs_search_lte_ut)
add_test(NAME BSSearchLteGte1K COMMAND bs_search_lte_gte_1k_ut)
add_test(NAME DLLGeneric COMMAND dll_generic_ut)
add_test(NAME DLLInt COMMAND dll_int_ut)
add_test(NAME DLLGtype COMMAND dll_gtype_ut)
add_test(NAME GBStypeI COMMAND bs_gtype_i_ut)
add_test(NAME BNEdgeHeight COMMAND bn_edge_height_ut)
add_test(NAME BNGenericInsert COMMAND bn_insert_ut)
add_test(NAME BSSearchLteGteGtype COMMAND bs_search_lte_gte_g_ut)
add_test(NAME ArrIUt COMMAND arr_i_ut)
add_test(NAME RbsIUt COMMAND rbs_i_ut)
add_test(NAME P1W COMMAND p1w_ut)
add_test(NAME HMapSmallUt COMMAND hmap_small_ut)
add_test(NAME HMapNnodeUt COMMAND hmap_nnode_ut)
add_test(NAME HMapRandiUt COMMAND hmap_randi_ut)
add_test(NAME ArrS13Ut COMMAND arr_s13_ut)
add_test(NAME GvecUT COMMAND gvec_ut)
add_test(NAME HashSetUT COMMAND hset_ut)
add_test(NAME HashMapFree0UT COMMAND hmap_free0_ut)
add_test(NAME HashSetRandUT COMMAND hset_rand_ut)
add_test(NAME GvecVoidUT COMMAND gvec_v_ut)
add_test(NAME SpacesUT COMMAND spaces_ut)
add_test(NAME SplitUT COMMAND split_ut)
add_test(NAME RbsStrUt COMMAND rbs_str_ut)
add_test(NAME RbmRandiUt COMMAND rbm_rand_i_ut 1000)
add_test(NAME RbsRandUt COMMAND rbs_rand_ut 1000)
add_test(NAME HmapGvec COMMAND hmap_gvec_ut)
add_test(NAME HmapHmap COMMAND hmap_hmap_ut)
add_test(NAME RbmGvec COMMAND rbm_gvec_ut)
add_test(NAME RbmHmap COMMAND rbm_hmap_ut)
add_test(NAME RbmPutSI COMMAND rbm_put_si_ut)
add_test(NAME HmapPutSI COMMAND hmap_put_si_ut 1000)
add_test(NAME RbmRgbRandDemo COMMAND rbm_rgb_rand_demo 1000)
add_test(NAME GtypeDemo COMMAND gtype_demo)
add_test(NAME RbmTfCfDemo COMMAND rbm_tf_cf_demo)
add_test(NAME GvecClearDemo COMMAND gvec_clear_demo)
add_test(NAME HmapClearDemo COMMAND hmap_clear_demo)
add_test(NAME HsetClearDemo COMMAND hset_clear_demo)
add_test(NAME P1WiClearDemo COMMAND p1wi_clear_demo)
add_test(NAME RbmClearDemo COMMAND rbm_clear_demo)
add_test(NAME RbsClearDemo COMMAND rbs_clear_demo)
add_test(NAME S2Wut COMMAND s2w_ut)
add_test(NAME StkSimpleUt COMMAND stk_simple_ut)
add_test(NAME QueSimpleUt COMMAND que_simple_ut)
add_test(NAME GslInsertaUt COMMAND gsl_inserta_ut)
add_test(NAME EXPArrIDemo COMMAND arr_i_demo ${CMAKE_CURRENT_SOURCE_DIR}/examples/arr/arr_i_demo.txt)
add_test(NAME EXPArrSetsizeDemo COMMAND arr_setsize_demo)
add_test(NAME EXDdemo COMMAND ddemo ${CMAKE_CURRENT_SOURCE_DIR}/examples/bs/ddemo.txt)
add_test(NAME EXGslDemo COMMAND gsl_demo ${CMAKE_CURRENT_SOURCE_DIR}/examples/gsl/gsl_demo.txt)
add_test(NAME EXGtypeDemo COMMAND gtype_demo)
add_test(NAME EXGvecClearDemo COMMAND gvec_clear_demo)
add_test(NAME EXGvecDemo COMMAND gvec_demo)
add_test(NAME EXGvecIDemo COMMAND gvec_i_demo ${CMAKE_CURRENT_SOURCE_DIR}/examples/gvec/gvec_i_demo.txt)
add_test(NAME EXGvecPPDemo COMMAND gvec_pp_demo ${CMAKE_CURRENT_SOURCE_DIR}/examples/gvec/gvec_pp_demo.txt)
add_test(NAME EXGvecSDemo COMMAND gvec_s_demo ${CMAKE_CURRENT_SOURCE_DIR}/examples/gvec/gvec_s_demo.txt)
add_test(NAME EXHgenDemo COMMAND hgen_demo)
add_test(NAME EXHmapDemo COMMAND hmap_demo)
add_test(NAME EXHmapClearDemo COMMAND hmap_clear_demo)
add_test(NAME EXHsetDemo COMMAND hset_demo)
add_test(NAME EXHsetClearDemo COMMAND hset_clear_demo)
add_test(NAME EXOOPSllDemo COMMAND SllDemo)
add_test(NAME EXOOPSllGDemo COMMAND SllG)
add_test(NAME EXOOPSllStr COMMAND SllStr)
add_test(NAME EXP1WIDemo COMMAND p1wi_demo)
add_test(NAME EXP1WIRoot COMMAND p1wi_root)
add_test(NAME EXP1WIClearDemo COMMAND p1wi_clear_demo)
add_test(NAME EXRBMClearDemo COMMAND rbm_clear_demo)
add_test(NAME EXRBMRGBRandDemo COMMAND rbm_rgb_rand_demo 1000)
add_test(NAME EXRBMSIDemo COMMAND rbm_si_demo)
add_test(NAME EXRBMRfCfDemo COMMAND rbm_tf_cf_demo)
add_test(NAME EXRBSClearDemo COMMAND rbs_clear_demo)
add_test(NAME EXRBSDemo COMMAND rbs_demo)
add_test(NAME EXCGetlineDemo COMMAND cgetline_demo ${CMAKE_CURRENT_SOURCE_DIR}/examples/utils/cgetline_demo.txt)
add_test(NAME EXCStrDupDemo COMMAND cstrdup_demo)
add_test(NAME EXDllSongs COMMAND dll_songs)
add_test(NAME EXGtypeDemoIO COMMAND gtype_demo_io ${CMAKE_CURRENT_SOURCE_DIR}/examples/gtype_demo_io.txt)
add_test(NAME EXS2IPPrint COMMAND s2i_pprint)
add_test(NAME EXS2IPPrintCustom COMMAND s2i_pprint_custom)
add_test(NAME EXStrId COMMAND str_id ${CMAKE_CURRENT_SOURCE_DIR}/examples/str_id.txt)
add_test(NAME GvecSelSort COMMAND gvec_selsort_ut)
add_test(NAME GvecInSort COMMAND gvec_insort_ut)
add_test(NAME GvecBubSort COMMAND gvec_bubsort_ut)
add_test(NAME Q2Sort COMMAND q2sort_ut 10000)
add_test(NAME Q3Sort COMMAND q3sort_ut 10000)
add_test(NAME QuickSort COMMAND quicksort_ut 100000)
add_test(NAME SortAllIdentical COMMAND sort_all_identical_ut 2000)
add_test(NAME Q2M3Sort COMMAND q2m3sort_ut 10000)
add_test(NAME HeapSort COMMAND heapsort_ut 10000)
add_test(NAME GvecMemResize COMMAND gvec_mem_resize_ut)
add_test(NAME GvecFill COMMAND gvec_fill_ut)
add_test(NAME GvecCreateFull COMMAND gvec_create_full_ut)
add_test(NAME ArrLongQsort COMMAND arr_qsort_long_ut)
add_test(NAME ArrTraverse COMMAND arr_traverse_ut)
add_test(NAME ArrFill COMMAND arr_fill_ut)
add_test(NAME ArrAssignMax COMMAND arr_assign_max_ut)
add_test(NAME ArrAssignMin COMMAND arr_assign_min_ut)
if (${CMAKE_BUILD_TYPE} STREQUAL Release AND
${CMAKE_PROJECT_NAME} STREQUAL cgen)
set(cgen_include_dest "include")
set(cgen_lib_dest "lib")
set(MERGE_CMD ${CMAKE_CURRENT_BINARY_DIR}/mega/merge)
MESSAGE(STATUS "MERGE CMD: " ${MERGE_CMD})
execute_process(COMMAND ${MERGE_CMD}
${CMAKE_CURRENT_SOURCE_DIR} all.h bkcgen.h
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${MERGE_CMD}
${CMAKE_CURRENT_SOURCE_DIR} all.c bkcgen.c
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bkcgen.h DESTINATION "${cgen_include_dest}")
install(TARGETS bkcgen DESTINATION "${cgen_lib_dest}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr")
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Nguyễn Bá Ngọc")
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION
"Thư viện cấu trúc dữ liệu và giải thuật khái quát.")
set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/bangoc/cgen")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "standard")
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
file (READ ${CMAKE_CURRENT_SOURCE_DIR}/VERSION CGEN_VERSION)
# Set a Package Version
set(CPACK_PACKAGE_VERSION "${CGEN_VERSION}")
include(CPack)
# To build a debian package
# cmake .. -DCMAKE_BUILD_TYPE=Release
# make -j 2
# make package
#
# To install the debian package
# sudo dpkg -i package.deb
endif()