]> sigrok.org Git - pulseview.git/blame - CMakeLists.txt
Offer unit tests with a cmake option
[pulseview.git] / CMakeLists.txt
CommitLineData
68c4a3b3 1##
190fc91a 2## This file is part of the PulseView project.
68c4a3b3
JH
3##
4## Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
30588653 5## Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@gmail.com>
68c4a3b3
JH
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
df944399
JH
21cmake_minimum_required(VERSION 2.6)
22include(FindPkgConfig)
23
a8d3fb2d 24project(pulseview)
df944399 25
30588653 26#===============================================================================
506523c1
JH
27#= User Options
28#-------------------------------------------------------------------------------
29
30option(ENABLE_TESTS "Enable unit tests" FALSE)
31
32#===============================================================================
30588653
AG
33#= Dependencies
34#-------------------------------------------------------------------------------
35
df944399
JH
36find_package(PkgConfig)
37pkg_check_modules(PKGDEPS REQUIRED
38 libsigrokdecode>=0.1.0
0dfbf7ff 39 libsigrok>=0.2.0
df944399
JH
40)
41
4cd24a75
UH
42# On Windows/MinGW we explicitly point cmake to the Boost directory.
43if(WIN32)
951c583c 44 set(BOOST_ROOT /usr/local)
4cd24a75
UH
45endif(WIN32)
46
df944399 47find_package(Qt4 REQUIRED)
f0fa92c6 48find_package(Boost 1.46 COMPONENTS unit_test_framework REQUIRED)
df944399
JH
49
50set(VERSION 0.1.0)
51
30588653
AG
52#===============================================================================
53#= Sources
54#-------------------------------------------------------------------------------
55
a8d3fb2d 56set(pulseview_SOURCES
df944399 57 main.cpp
51e77110
JH
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
1d8dca91 68 pv/view/header.cpp
ccdd3ef5 69 pv/view/ruler.cpp
cdf7bea7
JH
70 pv/view/view.cpp
71 pv/view/viewport.cpp
df944399
JH
72)
73
a8d3fb2d 74set(pulseview_HEADERS
51e77110
JH
75 pv/about.h
76 pv/mainwindow.h
77 pv/samplingbar.h
78 pv/sigsession.h
1d8dca91 79 pv/view/header.h
ccdd3ef5 80 pv/view/ruler.h
cdf7bea7
JH
81 pv/view/view.h
82 pv/view/viewport.h
df944399
JH
83)
84
a8d3fb2d 85set(pulseview_FORMS
51e77110 86 pv/about.ui
df944399
JH
87)
88
a8d3fb2d
JH
89set(pulseview_RESOURCES
90 pulseview.qrc
df944399
JH
91)
92
a8d3fb2d 93set(pulseview_TEST_SOURCES
51e77110
JH
94 pv/datasnapshot.cpp
95 pv/logicdatasnapshot.cpp
4ceab49a 96 test/logicdatasnapshot.cpp
f0fa92c6
JH
97 test/test.cpp
98)
99
a8d3fb2d
JH
100qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS})
101qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS})
102qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
df944399
JH
103
104include(${QT_USE_FILE})
105
30588653
AG
106#===============================================================================
107#= Global Definitions
108#-------------------------------------------------------------------------------
109
df944399
JH
110add_definitions(${QT_DEFINITIONS})
111add_definitions(-DAPP_VERSION="${VERSION}")
112
30588653
AG
113#===============================================================================
114#= Global Include Directories
115#-------------------------------------------------------------------------------
116
c0d9e65d
UH
117# On Windows/MinGW we need PKGDEPS_STATIC_INCLUDE_DIRS.
118if(WIN32)
951c583c
JH
119 include_directories(
120 ${include_directories}
121 ${CMAKE_CURRENT_BINARY_DIR}
122 ${Boost_INCLUDE_DIRS}
123 ${PKGDEPS_STATIC_INCLUDE_DIRS}
124 )
c0d9e65d 125else(WIN32)
951c583c
JH
126 include_directories(
127 ${include_directories}
128 ${CMAKE_CURRENT_BINARY_DIR}
129 ${Boost_INCLUDE_DIRS}
130 ${PKGDEPS_INCLUDE_DIRS}
131 )
c0d9e65d 132endif(WIN32)
df944399 133
30588653
AG
134#===============================================================================
135#= Linker Configuration
136#-------------------------------------------------------------------------------
137
c0d9e65d
UH
138# On Windows/MinGW we need PKGDEPS_STATIC_LIBRARY_DIRS.
139if(WIN32)
951c583c
JH
140 link_directories(
141 ${Boost_LIBRARY_DIRS}
142 ${PKGDEPS_STATIC_LIBRARY_DIRS}
143 )
c0d9e65d 144else(WIN32)
951c583c
JH
145 link_directories(
146 ${Boost_LIBRARY_DIRS}
147 ${PKGDEPS_LIBRARY_DIRS}
148 )
c0d9e65d 149endif(WIN32)
df944399 150
a8d3fb2d
JH
151add_executable(pulseview
152 ${pulseview_SOURCES}
153 ${pulseview_HEADERS_MOC}
154 ${pulseview_FORMS_HEADERS}
155 ${pulseview_RESOURCES_RCC}
df944399
JH
156)
157
c0d9e65d
UH
158# On Windows/MinGW we need PKGDEPS_STATIC_LIBRARIES.
159if(WIN32)
951c583c
JH
160 target_link_libraries(pulseview
161 ${Boost_LIBRARIES}
162 ${PKGDEPS_STATIC_LIBRARIES}
163 ${QT_LIBRARIES}
164 )
c0d9e65d 165else(WIN32)
951c583c
JH
166 target_link_libraries(pulseview
167 ${Boost_LIBRARIES}
168 ${PKGDEPS_LIBRARIES}
169 ${QT_LIBRARIES}
170 )
c0d9e65d 171endif(WIN32)
f0fa92c6 172
30588653
AG
173#===============================================================================
174#= Installation
175#-------------------------------------------------------------------------------
176
bc1c1462
JH
177install(PROGRAMS pulseview DESTINATION bin/)
178
30588653
AG
179#===============================================================================
180#= Tests
181#-------------------------------------------------------------------------------
182
77e8ac52
JH
183if(ENABLE_TESTS)
184
951c583c
JH
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)
0615f1b6 208
77e8ac52 209endif(ENABLE_TESTS)