-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
159 lines (132 loc) · 3.73 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
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(couttast CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(couttast_VERSION_MAJOR "0")
set(couttast_VERSION_MINOR "6")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
#include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
# libtinytast.a only has a (week) main function.
add_library(tinytast STATIC src/tinytast.cpp)
# libcouttast.a
# Has many extended features as well as a (week) main function.
add_library(couttast STATIC
src/couttast.cpp
src/agent.cpp
src/colour.cpp
src/filter.cpp
src/format.cpp
src/parallel.cpp
src/tinyini.cpp
src/file-compare.cpp
src/xmltast.cpp
src/systemtast.cpp
#src/tast_drive.cpp
#src/tinytast.cpp
)
# A simple program to run dynamic library compileed from client unittest.
add_executable(tast_drive src/tast_drive.cpp)
target_link_libraries(tast_drive
PRIVATE dl
)
# An unittest program to test libcouttast.a itself.
add_executable(utCoutTast
utest/mock-tastmgr.cpp
utest/test-agent.cpp
utest/test-exception.cpp
utest/test-filter.cpp
utest/test-format.cpp
utest/test-parallel.cpp
utest/test-tinyini.cpp
utest/test-tinytast.cpp
utest/test-file-compare.cpp
utest/test-classtast.cpp
utest/test-unittast.cpp
utest/test-systemtast.cpp
utest/test-rename-macros.cpp
)
target_include_directories(utCoutTast
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_link_libraries(utCoutTast
PRIVATE couttast
)
# An unitttest to test tinytast.hpp only for C++98 compatibility.
add_executable(utCxx98Tast
utest/test-tinytast.cpp
utest/test-classtast.cpp
utest/test-unittast.cpp
utest/test-rename-macros.cpp
)
target_compile_definitions(utCxx98Tast PRIVATE USE_TINY_MAIN)
set_property(TARGET utCxx98Tast PROPERTY CXX_STANDARD 98)
# enable ctest, make test
enable_testing()
add_test(NAME utCoutTast
COMMAND utCoutTast
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/utest
)
add_test(NAME utCxx98Tast
COMMAND utCxx98Tast
)
option(BUILD_EXAMPLE "build example" OFF)
if(BUILD_EXAMPLE)
add_subdirectory(example)
endif()
# Only install this necessary header files to include/couttast
set(COUTTAST_HEADER
include/tinytast.hpp
include/couttast.hpp
include/unittast.hpp
include/classtast.hpp
include/tastargv.hpp
include/coutstd.hpp
include/extra-macros.hpp
include/gtest-macros.hpp
include/rename-macros.hpp
include/tinymain.hpp
include/coutdebug.hpp
include/logprint.hpp
include/private-access.hpp
include/couttast.h
include/tinyini.h
include/agent.h
include/systemtast.h
include/xmltast.h
include/file-compare.h
)
# package config
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/couttastConfig.cmake"
INSTALL_DESTINATION "lib/cmake/couttast"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/couttastConfigVersion.cmake"
VERSION "${couttast_VERSION_MAJOR}.${couttast_VERSION_MINOR}"
COMPATIBILITY AnyNewerVersion
)
# install
# to install $HOME use:
# cmake .. -DCMAKE_INSTALL_PREFIX=$HOME
message("would install to: ${CMAKE_INSTALL_PREFIX}")
install(FILES ${COUTTAST_HEADER}
DESTINATION "include/couttast"
)
install(TARGETS tinytast
DESTINATION "lib"
)
install(TARGETS couttast
DESTINATION "lib"
)
install(TARGETS tast_drive
DESTINATION "bin"
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/couttastConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/couttastConfigVersion.cmake
DESTINATION lib/cmake/couttast
)