]> sigrok.org Git - pulseview.git/blob - CMakeLists.txt
Added section headers to CMakeLists.txt
[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 #= Dependencies
28 #-------------------------------------------------------------------------------
29
30 find_package(PkgConfig)
31 pkg_check_modules(PKGDEPS REQUIRED
32         libsigrokdecode>=0.1.0
33         libsigrok>=0.2.0
34 )
35
36 # On Windows/MinGW we explicitly point cmake to the Boost directory.
37 if(WIN32)
38         set(BOOST_ROOT /usr/local)
39 endif(WIN32)
40
41 find_package(Qt4 REQUIRED)
42 find_package(Boost 1.46 COMPONENTS unit_test_framework REQUIRED)
43
44 set(VERSION 0.1.0)
45
46 #===============================================================================
47 #= Sources
48 #-------------------------------------------------------------------------------
49
50 set(pulseview_SOURCES
51         main.cpp
52         pv/about.cpp
53         pv/datasnapshot.cpp
54         pv/logicdata.cpp
55         pv/logicdatasnapshot.cpp
56         pv/logicsignal.cpp
57         pv/mainwindow.cpp
58         pv/samplingbar.cpp
59         pv/signaldata.cpp
60         pv/sigsession.cpp
61         pv/signal.cpp
62         pv/view/header.cpp
63         pv/view/ruler.cpp
64         pv/view/view.cpp
65         pv/view/viewport.cpp
66 )
67
68 set(pulseview_HEADERS
69         pv/about.h
70         pv/mainwindow.h
71         pv/samplingbar.h
72         pv/sigsession.h
73         pv/view/header.h
74         pv/view/ruler.h
75         pv/view/view.h
76         pv/view/viewport.h
77 )
78
79 set(pulseview_FORMS
80         pv/about.ui
81 )
82
83 set(pulseview_RESOURCES
84         pulseview.qrc
85 )
86
87 set(pulseview_TEST_SOURCES
88         pv/datasnapshot.cpp
89         pv/logicdatasnapshot.cpp
90         test/logicdatasnapshot.cpp
91         test/test.cpp
92 )
93
94 qt4_wrap_cpp(pulseview_HEADERS_MOC ${pulseview_HEADERS})
95 qt4_wrap_ui(pulseview_FORMS_HEADERS ${pulseview_FORMS})
96 qt4_add_resources(pulseview_RESOURCES_RCC ${pulseview_RESOURCES})
97
98 include(${QT_USE_FILE})
99
100 #===============================================================================
101 #= Global Definitions
102 #-------------------------------------------------------------------------------
103
104 add_definitions(${QT_DEFINITIONS})
105 add_definitions(-DAPP_VERSION="${VERSION}")
106
107 #===============================================================================
108 #= Global Include Directories
109 #-------------------------------------------------------------------------------
110
111 # On Windows/MinGW we need PKGDEPS_STATIC_INCLUDE_DIRS.
112 if(WIN32)
113         include_directories(
114                 ${include_directories}
115                 ${CMAKE_CURRENT_BINARY_DIR}
116                 ${Boost_INCLUDE_DIRS}
117                 ${PKGDEPS_STATIC_INCLUDE_DIRS}
118         )
119 else(WIN32)
120         include_directories(
121                 ${include_directories}
122                 ${CMAKE_CURRENT_BINARY_DIR}
123                 ${Boost_INCLUDE_DIRS}
124                 ${PKGDEPS_INCLUDE_DIRS}
125         )
126 endif(WIN32)
127
128 #===============================================================================
129 #= Linker Configuration
130 #-------------------------------------------------------------------------------
131
132 # On Windows/MinGW we need PKGDEPS_STATIC_LIBRARY_DIRS.
133 if(WIN32)
134         link_directories(
135                 ${Boost_LIBRARY_DIRS}
136                 ${PKGDEPS_STATIC_LIBRARY_DIRS}
137         )
138 else(WIN32)
139         link_directories(
140                 ${Boost_LIBRARY_DIRS}
141                 ${PKGDEPS_LIBRARY_DIRS}
142         )
143 endif(WIN32)
144
145 add_executable(pulseview
146         ${pulseview_SOURCES}
147         ${pulseview_HEADERS_MOC}
148         ${pulseview_FORMS_HEADERS}
149         ${pulseview_RESOURCES_RCC}
150 )
151
152 # On Windows/MinGW we need PKGDEPS_STATIC_LIBRARIES.
153 if(WIN32)
154         target_link_libraries(pulseview
155                 ${Boost_LIBRARIES}
156                 ${PKGDEPS_STATIC_LIBRARIES}
157                 ${QT_LIBRARIES}
158         )
159 else(WIN32)
160         target_link_libraries(pulseview
161                 ${Boost_LIBRARIES}
162                 ${PKGDEPS_LIBRARIES}
163                 ${QT_LIBRARIES}
164         )
165 endif(WIN32)
166
167 #===============================================================================
168 #= Installation
169 #-------------------------------------------------------------------------------
170
171 install(PROGRAMS pulseview DESTINATION bin/)
172
173 #===============================================================================
174 #= Tests
175 #-------------------------------------------------------------------------------
176
177 if(ENABLE_TESTS)
178
179         add_definitions(-DBOOST_TEST_DYN_LINK)
180
181         add_executable(pulseview-test
182                 ${pulseview_TEST_SOURCES}
183         )
184
185         # On Windows/MinGW we need PKGDEPS_STATIC_LIBRARIES.
186         if(WIN32)
187                 target_link_libraries(pulseview-test
188                         ${Boost_LIBRARIES}
189                         ${PKGDEPS_STATIC_LIBRARIES}
190                         ${QT_LIBRARIES}
191                 )
192         else(WIN32)
193                 target_link_libraries(pulseview-test
194                         ${Boost_LIBRARIES}
195                         ${PKGDEPS_LIBRARIES}
196                         ${QT_LIBRARIES}
197                 )
198         endif(WIN32)
199
200         enable_testing()
201         add_test(test ${CMAKE_CURRENT_BINARY_DIR}/pulseview-test)
202
203 endif(ENABLE_TESTS)