-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
81 lines (63 loc) · 2.05 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
# ---------------------------------------------------------------------------- #
# CMake configuration
cmake_minimum_required(VERSION 2.8)
# ---------------------------------------------------------------------------- #
# Project configuration
# Define the top-level project
project(triehard CXX)
enable_testing()
# Compiler config
set(CMAKE_CXX_FLAGS "-Wall -std=c++1y")
include_directories(.)
# ---------------------------------------------------------------------------- #
# Build
# Add the triehard library
add_library(triehard triehard.cpp)
# ---------------------------------------------------------------------------- #
# Testing
# This macro will create unit tests for a module.
macro(add_unit_test mod file)
set(tgt ${mod}.${file})
add_executable(${tgt} ${mod}.test/${file}.cpp)
target_link_libraries(${tgt} triehard)
add_test(test.${tgt} ${tgt})
endmacro()
# Add a test suite.
add_unit_test(triehard init)
add_unit_test(triehard insert)
add_unit_test(triehard count)
add_unit_test(triehard fetch)
add_unit_test(triehard erase)
add_unit_test(triehard size)
add_unit_test(triehard empty)
# ---------------------------------------------------------------------------- #
# Submission
# The make_manifest macro creates targets that generate a PDF of
# your code for grading.
macro(make_manifest)
# Complete the paths to all files
set(src "")
set(doc "")
foreach(i ${ARGV})
# Make sure the file has its absolute path.
set(f ${CMAKE_CURRENT_SOURCE_DIR}/${i})
# What kind of file are we talking about?
# We're going to process them a little differently.
get_filename_component(ext ${i} EXT)
if (${ext} STREQUAL ".md")
list(APPEND doc ${f})
else()
list(APPEND src ${f})
endif()
endforeach()
# Generate the manifest target
set(outdoc "${CMAKE_CURRENT_BINARY_DIR}/doc.html")
add_custom_target(manifest
COMMAND pandoc ${doc} -o ${outdoc}
COMMAND a2ps -Afill -o manifest.ps ${outdoc} ${src}
COMMAND ps2pdf manifest.ps)
endmacro()
# Add files to be submitted and graded.
make_manifest(
README.md
)