]> sigrok.org Git - pulseview.git/blob - CMakeLists.txt
Offer unit tests with a cmake option
[pulseview.git] / CMakeLists.txt
1 ##
2 ## This file is part of the PulseView project.
3 ##
4 ## Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 ## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
6 ##
7 ## This program is free software: you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation, either version 2 of the License, or
10 ## (at your option) any later version.
11 ##
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ## GNU General Public License for more details.
16 ##
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 ##
20
21 cmake_minimum_required(VERSION 2.6)
22 include(FindPkgConfig)
23
24 project(pulseview)
25
26 #===============================================================================
27 #= User Options
28 #-------------------------------------------------------------------------------
29
30 option(ENABLE_TESTS "Enable unit tests" FALSE)
31
32 #===============================================================================
33 #= Dependencies
34 #-------------------------------------------------------------------------------
35
36 find_package(PkgConfig)
37 pkg_check_modules(PKGDEPS REQUIRED
38         libsigrokdecode>=0.1.0
39         libsigrok>=0.2.0
40 )
41
42 # On Windows/MinGW we explicitly point cmake to the Boost directory.
43 if(WIN32)
44         set(BOOST_ROOT /usr/local)
45 endif(WIN32)
46
47 find_package(Qt4 REQUIRED)
48 find_package(Boost 1.46 COMPONENTS unit_test_framework REQUIRED)
49
50 set(VERSION 0.1.0)
51
52 #===============================================================================
53 #= Sources
54 #-------------------------------------------------------------------------------
55
56 set(pulseview_SOURCES
57         main.cpp
58         pv/about.cpp
59         pv/datasnapshot.cpp
60         pv/logicdata.cpp
61         pv/logicdatasnapshot.cpp
62         pv/logicsignal.cpp
63         pv/mainwindow.cpp
64         pv/samplingbar.cpp
65         pv/signaldata.cpp
66         pv/sigsession.cpp
67         pv/signal.cpp
68         pv/view/header.cpp
69         pv/view/ruler.cpp
70         pv/view/view.cpp
71         pv/view/viewport.cpp
72 )
73
74 set(pulseview_HEADERS
75         pv/about.h
76         pv/mainwindow.h
77         pv/samplingbar.h
78         pv/sigsession.h
79         pv/view/header.h
80         pv/view/ruler.h
81         pv/view/view.h
82         pv/view/viewport.h
83 )
84
85 set(pulseview_FORMS
86         pv/about.ui
87 )
88
89 set(pulseview_RESOURCES
90         pulseview.qrc
91 )
92
93 set(pulseview_TEST_SOURCES
94         pv/datasnapshot.cpp
95         pv/logicdatasnapshot.cpp
96         test/logicdatasnapshot.cpp
97         test/test.cpp
98 )
99
100 qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS})
101 qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS})
102 qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
103
104 include(${QT_USE_FILE})
105
106 #===============================================================================
107 #= Global Definitions
108 #-------------------------------------------------------------------------------
109
110 add_definitions(${QT_DEFINITIONS})
111 add_definitions(-DAPP_VERSION="${VERSION}")
112
113 #===============================================================================
114 #= Global Include Directories
115 #-------------------------------------------------------------------------------
116
117 # On Windows/MinGW we need PKGDEPS_STATIC_INCLUDE_DIRS.
118 if(WIN32)
119         include_directories(
120                 ${include_directories}
121                 ${CMAKE_CURRENT_BINARY_DIR}
122                 ${Boost_INCLUDE_DIRS}
123                 ${PKGDEPS_STATIC_INCLUDE_DIRS}
124         )
125 else(WIN32)
126         include_directories(
127                 ${include_directories}
128                 ${CMAKE_CURRENT_BINARY_DIR}
129                 ${Boost_INCLUDE_DIRS}
130                 ${PKGDEPS_INCLUDE_DIRS}
131         )
132 endif(WIN32)
133
134 #===============================================================================
135 #= Linker Configuration
136 #-------------------------------------------------------------------------------
137
138 # On Windows/MinGW we need PKGDEPS_STATIC_LIBRARY_DIRS.
139 if(WIN32)
140         link_directories(
141                 ${Boost_LIBRARY_DIRS}
142                 ${PKGDEPS_STATIC_LIBRARY_DIRS}
143         )
144 else(WIN32)
145         link_directories(
146                 ${Boost_LIBRARY_DIRS}
147                 ${PKGDEPS_LIBRARY_DIRS}
148         )
149 endif(WIN32)
150
151 add_executable(pulseview
152         ${pulseview_SOURCES}
153         ${pulseview_HEADERS_MOC}
154         ${pulseview_FORMS_HEADERS}
155         ${pulseview_RESOURCES_RCC}
156 )
157
158 # On Windows/MinGW we need PKGDEPS_STATIC_LIBRARIES.
159 if(WIN32)
160         target_link_libraries(pulseview
161                 ${Boost_LIBRARIES}
162                 ${PKGDEPS_STATIC_LIBRARIES}
163                 ${QT_LIBRARIES}
164         )
165 else(WIN32)
166         target_link_libraries(pulseview
167                 ${Boost_LIBRARIES}
168                 ${PKGDEPS_LIBRARIES}
169                 ${QT_LIBRARIES}
170         )
171 endif(WIN32)
172
173 #===============================================================================
174 #= Installation
175 #-------------------------------------------------------------------------------
176
177 install(PROGRAMS pulseview DESTINATION bin/)
178
179 #===============================================================================
180 #= Tests
181 #-------------------------------------------------------------------------------
182
183 if(ENABLE_TESTS)
184
185         add_definitions(-DBOOST_TEST_DYN_LINK)
186
187         add_executable(pulseview-test
188                 ${pulseview_TEST_SOURCES}
189         )
190
191         # On Windows/MinGW we need PKGDEPS_STATIC_LIBRARIES.
192         if(WIN32)
193                 target_link_libraries(pulseview-test
194                         ${Boost_LIBRARIES}
195                         ${PKGDEPS_STATIC_LIBRARIES}
196                         ${QT_LIBRARIES}
197                 )
198         else(WIN32)
199                 target_link_libraries(pulseview-test
200                         ${Boost_LIBRARIES}
201                         ${PKGDEPS_LIBRARIES}
202                         ${QT_LIBRARIES}
203                 )
204         endif(WIN32)
205
206         enable_testing()
207         add_test(test ${CMAKE_CURRENT_BINARY_DIR}/pulseview-test)
208
209 endif(ENABLE_TESTS)