/alps/pcitool

To get this branch, use:
bzr branch http://darksoft.org/webbzr/alps/pcitool
370 by Suren A. Chilingaryan
RPM generation
1
project(pcitool C)
126 by Suren A. Chilingaryan
multithread preprocessing of ipecamera frames and code reorganization
2
396 by Suren A. Chilingaryan
Fix build if the source was exported from bazaar as zip archive (i.e. .bzr directory is missing and build.h is not present)
3
set(RELEASE "3")
367 by Suren A. Chilingaryan
Further improvements of Python scripting and web-interface API for register manipulations by Vasiliy Chernov
4
set(PCILIB_VERSION "0.2.7")
241 by Suren A. Chilingaryan
Further adjustments to get ready for independent event plugins
5
set(PCILIB_ABI_VERSION "2")
126 by Suren A. Chilingaryan
multithread preprocessing of ipecamera frames and code reorganization
6
346.1.10 by Vasilii Chernov
1. Cmakelists - move copy xml folder command to root file
7
cmake_minimum_required(VERSION 2.8)
324 by Suren A. Chilingaryan
Documentation update
8
#set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH true)
9
#set(CMAKE_PREFIX_PATH ${CMAKE_SYSTEM_PREFIX_PATH})
126 by Suren A. Chilingaryan
multithread preprocessing of ipecamera frames and code reorganization
10
346.1.16 by Vasilii Chernov
1. Add cmake BUILD_PYTHON_MODULES option.
11
set(DISABLE_PCITOOL FALSE CACHE BOOL "Build only the library")
353 by Suren A. Chilingaryan
Merge Python scripting support from Vasiliy Chernov
12
set(DISABLE_PYTHON FALSE CACHE BOOL "Disable python scripting support") 
372 by Suren A. Chilingaryan
Integrate last part of Python code from Vasiliy Chernov
13
set(DISABLE_SERVERS FALSE CACHE BOOL "Disable Web API support") 
152 by Suren A. Chilingaryan
build scripts: allow to build the library without pcitool
14
253 by Suren A. Chilingaryan
Include version information in all API descriptions
15
#list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
152 by Suren A. Chilingaryan
build scripts: allow to build the library without pcitool
16
387 by Suren A. Chilingaryan
Use GNUInstallDirs to detect install directories (should fix problems on Debian/Ubuntu)
17
18
include(GNUInstallDirs)
19
include(CheckIncludeFiles)
20
21
include(cmake/tools.cmake)
22
include(cmake/version.cmake)
23
VERSION_TO_VARS(${PCILIB_VERSION} PCILIB_VERSION_MAJOR PCILIB_VERSION_MINOR PCILIB_VERSION_MICRO)
24
25
set(EXTRA_SYSTEM_LIBS -lrt)
26
add_definitions("-fPIC --std=c99 -Wall -O2 -gdwarf-2 -g3 -fno-omit-frame-pointer")
27
#add_definitions("-fPIC --std=c99 -Wall -O2")
28
29
find_package(PkgConfig REQUIRED)
30
find_package(Threads REQUIRED)
31
find_package(Doxygen)
370 by Suren A. Chilingaryan
RPM generation
32
33
if (NOT DEFINED PCILIB_PLUGIN_DIR)
388 by Suren A. Chilingaryan
Use GNUInstallDirs
34
    set(PCILIB_PLUGIN_DIR "${CMAKE_INSTALL_FULL_LIBDIR}/pcilib" CACHE PATH "Directory to install plugins")
370 by Suren A. Chilingaryan
RPM generation
35
endif (NOT DEFINED PCILIB_PLUGIN_DIR)
36
37
if (NOT DEFINED PCILIB_DATA_DIR)
388 by Suren A. Chilingaryan
Use GNUInstallDirs
38
    set(PCILIB_DATA_DIR "${CMAKE_INSTALL_FULL_DATAROOTDIR}/pcilib" CACHE PATH "Directory to install data files")
370 by Suren A. Chilingaryan
RPM generation
39
endif (NOT DEFINED PCILIB_DATA_DIR)
40
41
if (NOT DEFINED PCILIB_MODEL_DIR)
42
    set(PCILIB_MODEL_DIR "${PCILIB_DATA_DIR}/models" CACHE PATH "Directory to install XML models")
43
endif (NOT DEFINED PCILIB_MODEL_DIR)
44
372 by Suren A. Chilingaryan
Integrate last part of Python code from Vasiliy Chernov
45
if (NOT DEFINED PCILIB_SERVER_DIR)
46
    set(PCILIB_SERVER_DIR "${PCILIB_DATA_DIR}/pyserver" CACHE PATH "Directory to install python server")
47
endif (NOT DEFINED PCILIB_SERVER_DIR)
48
370 by Suren A. Chilingaryan
RPM generation
49
if (NOT DEFINED PCILIB_DOC_DIR)
50
    set(PCILIB_DOC_DIR "${CMAKE_CURRENT_BINARY_DIR}/docs/" CACHE PATH "Directory to install documentation")
51
endif (NOT DEFINED PCILIB_DOC_DIR)
52
    
53
if (NOT DEFINED PCILIB_DEBUG_DIR)
54
    set(PCILIB_DEBUG_DIR "." CACHE PATH "Directory to write debug information")
55
endif (NOT DEFINED PCILIB_DEBUG_DIR)
56
388 by Suren A. Chilingaryan
Use GNUInstallDirs
57
SET(ENV{PKG_CONFIG_PATH} "${CMAKE_INSTALL_LIBDIR}/pkgconfig:$ENV{PKG_CONFIG_PATH}")
302 by Suren A. Chilingaryan
Fixes out-of-source builds and minor build issues
58
353 by Suren A. Chilingaryan
Merge Python scripting support from Vasiliy Chernov
59
if (NOT DISABLE_PYTHON)
367 by Suren A. Chilingaryan
Further improvements of Python scripting and web-interface API for register manipulations by Vasiliy Chernov
60
    set(PYTHON_VERSION 2.7 CACHE STRING "python version")
61
346.1.35 by Vasilii Chernov
Add Python3 support
62
    find_package(PythonInterp ${PYTHON_VERSION} REQUIRED)
367 by Suren A. Chilingaryan
Further improvements of Python scripting and web-interface API for register manipulations by Vasiliy Chernov
63
    find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT REQUIRED)
64
353 by Suren A. Chilingaryan
Merge Python scripting support from Vasiliy Chernov
65
    find_package(SWIG REQUIRED)
359 by Suren A. Chilingaryan
Altenrative way to detect location where python modules should be installed
66
    if (NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING)
67
	message (FATAL_ERROR "Version mismatch between python interpreter and libraries")
68
    endif (NOT PYTHON_VERSION_STRING VERSION_EQUAL PYTHONLIBS_VERSION_STRING)
69
388 by Suren A. Chilingaryan
Use GNUInstallDirs
70
#    execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "from sysconfig import get_path; print get_path('platlib')" OUTPUT_VARIABLE PCILIB_PYTHON_SITEDIR OUTPUT_STRIP_TRAILING_WHITESPACE)
359 by Suren A. Chilingaryan
Altenrative way to detect location where python modules should be installed
71
    
388 by Suren A. Chilingaryan
Use GNUInstallDirs
72
    if (NOT DEFINED PCILIB_PYTHON_SITEDIR)
370 by Suren A. Chilingaryan
RPM generation
73
	execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "import site; print (site.PREFIXES[-1])" OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
74
	file (TO_CMAKE_PATH "${PYTHON_PREFIX}" PYTHON_PREFIX)
389 by Suren A. Chilingaryan
Better detection of Python site-dir
75
76
#	execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "import site; print (site.getsitepackages()[0])" OUTPUT_VARIABLE PYTHON_SITE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
77
#	file (TO_CMAKE_PATH "${PYTHON_SITE_DIR}" PYTHON_SITE_DIR)
78
#	string (REGEX REPLACE "^${PYTHON_PREFIX}/" "${CMAKE_INSTALL_PREFIX}/" PYTHON_SITE_DIR "${PYTHON_SITE_DIR}")
79
80
	execute_process (COMMAND ${PYTHON_EXECUTABLE} -c "import site; list = [dir for dir in site.getsitepackages() if dir.startswith('${CMAKE_INSTALL_PREFIX}')]; liblist = [dir for dir in list if dir.startswith('${CMAKE_INSTALL_PREFIX}/lib')]; print liblist[0] if liblist else list[0] if list else site.getsitepackages()[0]" OUTPUT_VARIABLE PYTHON_SITE_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
81
	message(${PYTHON_SITE_DIR})
370 by Suren A. Chilingaryan
RPM generation
82
	file (TO_CMAKE_PATH "${PYTHON_SITE_DIR}" PYTHON_SITE_DIR)
359 by Suren A. Chilingaryan
Altenrative way to detect location where python modules should be installed
83
388 by Suren A. Chilingaryan
Use GNUInstallDirs
84
	set(PCILIB_PYTHON_SITEDIR ${PYTHON_SITE_DIR} CACHE PATH "path to install python module")
85
    endif (NOT DEFINED PCILIB_PYTHON_SITEDIR)
359 by Suren A. Chilingaryan
Altenrative way to detect location where python modules should be installed
86
353 by Suren A. Chilingaryan
Merge Python scripting support from Vasiliy Chernov
87
    set(HAVE_PYTHON TRUE)
88
endif (NOT DISABLE_PYTHON)
126 by Suren A. Chilingaryan
multithread preprocessing of ipecamera frames and code reorganization
89
372 by Suren A. Chilingaryan
Integrate last part of Python code from Vasiliy Chernov
90
if (NOT HAVE_PYTHON)
91
    set(DISABLE_SERVERS TRUE)
92
endif (NOT HAVE_PYTHON)
93
303 by Suren A. Chilingaryan
Initial integration of XML support
94
check_include_files(stdatomic.h HAVE_STDATOMIC_H)
95
307 by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far)
96
find_path(UTHASH_INCLUDE_DIRS uthash.h PATH_SUFFIXES uthash)
97
if (UTHASH_INCLUDE_DIRS)
98
    message ("uthash is found at ${UTHASH_INCLUDE_DIRS}")
99
else (UTHASH_INCLUDE_DIRS)
100
    message (FATAL_ERROR "uthash is not found...")
101
endif (UTHASH_INCLUDE_DIRS)
102
303 by Suren A. Chilingaryan
Initial integration of XML support
103
pkg_check_modules(LIBXML2 libxml-2.0 REQUIRED)
104
126 by Suren A. Chilingaryan
multithread preprocessing of ipecamera frames and code reorganization
105
#Check in sibling directory
152 by Suren A. Chilingaryan
build scripts: allow to build the library without pcitool
106
if (NOT DISABLE_PCITOOL)
107
    pkg_check_modules(FASTWRITER fastwriter REQUIRED)
108
endif (NOT DISABLE_PCITOOL)
126 by Suren A. Chilingaryan
multithread preprocessing of ipecamera frames and code reorganization
109
241 by Suren A. Chilingaryan
Further adjustments to get ready for independent event plugins
110
306 by Suren A. Chilingaryan
Reorder statements in CMakeLists.txt properly
111
add_subdirectory(dma)
112
add_subdirectory(protocols)
307 by Suren A. Chilingaryan
Finalyze XML support and provide initial support for views (only descriptions so far)
113
add_subdirectory(views)
306 by Suren A. Chilingaryan
Reorder statements in CMakeLists.txt properly
114
add_subdirectory(pcilib)
115
add_subdirectory(pcitool)
116
add_subdirectory(apps)
117
add_subdirectory(xml)
118
353 by Suren A. Chilingaryan
Merge Python scripting support from Vasiliy Chernov
119
if (HAVE_PYTHON)
120
    add_subdirectory(pywrap)
121
endif (HAVE_PYTHON)
346.1.16 by Vasilii Chernov
1. Add cmake BUILD_PYTHON_MODULES option.
122
374 by Suren A. Chilingaryan
Handle build.h in releases
123
set_target_properties(pcilib PROPERTIES VERSION ${PCILIB_VERSION} SOVERSION ${PCILIB_ABI_VERSION})
370 by Suren A. Chilingaryan
RPM generation
124
add_custom_target(docs
125
    COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/docs/Doxyfile 
126
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/docs
127
    COMMENT "Generating API documentation with Doxygen" VERBATIM
128
)
129
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "docs/html")
130
241 by Suren A. Chilingaryan
Further adjustments to get ready for independent event plugins
131
install(FILES 
261 by Suren A. Chilingaryan
Add doxygen configuration
132
    ${CMAKE_CURRENT_BINARY_DIR}/misc/pcitool.pc
388 by Suren A. Chilingaryan
Use GNUInstallDirs
133
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
241 by Suren A. Chilingaryan
Further adjustments to get ready for independent event plugins
134
)
253 by Suren A. Chilingaryan
Include version information in all API descriptions
135
372 by Suren A. Chilingaryan
Integrate last part of Python code from Vasiliy Chernov
136
if (NOT DISABLE_SERVERS)
346.1.39 by Vasilii Chernov
Add python servers instalation step. Add systemd config files generation for python servers.
137
   #install Python servers
138
   file(GLOB DEPLOY_FILES_AND_DIRS "${CMAKE_SOURCE_DIR}/pyserver/*")
139
   foreach(ITEM ${DEPLOY_FILES_AND_DIRS})
372 by Suren A. Chilingaryan
Integrate last part of Python code from Vasiliy Chernov
140
	if( IS_DIRECTORY "${ITEM}" )
141
	    list(APPEND DIRS_TO_DEPLOY "${ITEM}")
142
        else()
143
    	    list(APPEND FILES_TO_DEPLOY "${ITEM}")
144
        endif()
145
    endforeach()
146
    install(FILES ${FILES_TO_DEPLOY} DESTINATION ${PCILIB_SERVER_DIR})
147
    install(DIRECTORY ${DIRS_TO_DEPLOY} DESTINATION ${PCILIB_SERVER_DIR})
148
endif (NOT DISABLE_SERVERS)
346.1.39 by Vasilii Chernov
Add python servers instalation step. Add systemd config files generation for python servers.
149
374 by Suren A. Chilingaryan
Handle build.h in releases
150
151
152
set(TARNAME "pcitool")
153
set(PACKAGE_VERSION ${PCILIB_VERSION})
154
set(PACKAGE_NAME "${TARNAME}")
155
set(PACKAGE_TARNAME "${TARNAME}")
156
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
157
set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket")
158
159
set(CPACK_SOURCE_GENERATOR "TBZ2")
160
set(CPACK_PACKAGE_CONTACT "Suren A. Chilingaryan <csa@suren.me>")
161
if (${RELEASE} GREATER 0)
162
    set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}.${RELEASE}")
163
else (${RELEASE} GREATER 0)
164
    set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
165
endif (${RELEASE} GREATER 0)
399 by Suren A. Chilingaryan
Fix building of driver if pcilib is built out-of-source
166
#set(CPACK_SOURCE_IGNORE_FILES "([^d]|d[^r])[^/]*/Makefile;${CPACK_SOURCE_IGNORE_FILES}")
167
set(CPACK_SOURCE_IGNORE_FILES "/build/;/.bzr/;CMakeFiles;_CPack_Packages;cmake_install.cmake;CPack.*.cmake;CMakeCache.txt;install_manifest.txt;common.mk;pcilib/config.h$;.pc$;Makefile$;__pycache__;.pyc$;.tar.bz2$;~$;${CPACK_SOURCE_IGNORE_FILES}")
374 by Suren A. Chilingaryan
Handle build.h in releases
168
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
169
include(CPack)
170
171
# In releases, we just keep the pre-generated build.h 
396 by Suren A. Chilingaryan
Fix build if the source was exported from bazaar as zip archive (i.e. .bzr directory is missing and build.h is not present)
172
if(EXISTS ${CMAKE_SOURCE_DIR}/.bzr/ OR NOT EXISTS ${CMAKE_SOURCE_DIR}/pcilib/build.h)
374 by Suren A. Chilingaryan
Handle build.h in releases
173
    add_custom_target(build
174
	COMMAND ${CMAKE_COMMAND} -DPCILIB_SOURCE_DIR=${CMAKE_SOURCE_DIR} -DPCILIB_BINARY_DIR=${CMAKE_BINARY_DIR} -P ${CMAKE_SOURCE_DIR}/cmake/build.cmake
175
	WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
176
    )
177
    add_dependencies(pcilib build)
178
    add_dependencies(pci build)
179
180
	# We need to generate build.h for source releases
382 by Suren A. Chilingaryan
Fix dist_clean target
181
    add_custom_target(dist_clean make clean -C driver
182
	COMMAND ${CMAKE_MAKE_PROGRAM} clean 
183
	WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
184
    )
374 by Suren A. Chilingaryan
Handle build.h in releases
185
    add_custom_target(dist_prepare DEPENDS dist_clean
186
	COMMAND ${CMAKE_COMMAND} -DPCILIB_SOURCE_DIR=${CMAKE_SOURCE_DIR} -DPCILIB_BINARY_DIR=${CMAKE_SOURCE_DIR} -DPCILIB_RELEASE=${CPACK_PACKAGE_VERSION} -P ${CMAKE_SOURCE_DIR}/cmake/build.cmake
187
	WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
188
    )
189
    add_custom_target(dist DEPENDS dist_prepare COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
190
191
    set_source_files_properties(${CMAKE_BINARY_DIR}/pcilib/build.h PROPERTIES GENERATED TRUE)
192
    set_source_files_properties(${CMAKE_SOURCE_DIR}/pcilib/build.h PROPERTIES GENERATED TRUE)
396 by Suren A. Chilingaryan
Fix build if the source was exported from bazaar as zip archive (i.e. .bzr directory is missing and build.h is not present)
193
endif(EXISTS ${CMAKE_SOURCE_DIR}/.bzr/ OR NOT EXISTS ${CMAKE_SOURCE_DIR}/pcilib/build.h)
374 by Suren A. Chilingaryan
Handle build.h in releases
194
195
if (NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
196
    file(COPY ${CMAKE_SOURCE_DIR}/xml DESTINATION ${CMAKE_BINARY_DIR})
197
    file(COPY ${CMAKE_SOURCE_DIR}/pyserver DESTINATION ${CMAKE_BINARY_DIR})
198
    file(COPY ${CMAKE_SOURCE_DIR}/pci
199
	 DESTINATION ${CMAKE_BINARY_DIR}
200
	 FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
201
    )
202
    file(COPY ${CMAKE_SOURCE_DIR}/run
203
	 DESTINATION ${CMAKE_BINARY_DIR}
204
	 FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
205
    )
206
endif(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
207
399 by Suren A. Chilingaryan
Fix building of driver if pcilib is built out-of-source
208
configure_file(${CMAKE_SOURCE_DIR}/driver/Makefile.in ${CMAKE_SOURCE_DIR}/driver/Makefile)
209
configure_file(${CMAKE_SOURCE_DIR}/pcitool.spec.in ${CMAKE_BINARY_DIR}/pcitool.spec)
210
configure_file(${CMAKE_SOURCE_DIR}/misc/dkms.conf.in ${CMAKE_BINARY_DIR}/misc/dkms.conf)
211
configure_file(${CMAKE_SOURCE_DIR}/misc/pcitool.pc.in ${CMAKE_BINARY_DIR}/misc/pcitool.pc)
212
configure_file(${CMAKE_SOURCE_DIR}/pcilib/config.h.in ${CMAKE_BINARY_DIR}/pcilib/config.h)
213
configure_file(${CMAKE_SOURCE_DIR}/pcilib/version.h.in ${CMAKE_BINARY_DIR}/pcilib/version.h)
214
configure_file(${CMAKE_SOURCE_DIR}/docs/Doxyfile.in ${CMAKE_BINARY_DIR}/docs/Doxyfile)
374 by Suren A. Chilingaryan
Handle build.h in releases
215
if (NOT DISABLE_SERVERS)
399 by Suren A. Chilingaryan
Fix building of driver if pcilib is built out-of-source
216
    configure_file(${CMAKE_SOURCE_DIR}/misc/pcilib_api.service.in ${CMAKE_BINARY_DIR}/misc/pcilib_api.service)
217
    configure_file(${CMAKE_SOURCE_DIR}/misc/pcilib_html.service.in ${CMAKE_BINARY_DIR}/misc/pcilib_html.service)
218
    configure_file(${CMAKE_SOURCE_DIR}/misc/pcilib.sysconfig.in ${CMAKE_BINARY_DIR}/misc/pcilib.sysconfig)
374 by Suren A. Chilingaryan
Handle build.h in releases
219
endif (NOT DISABLE_SERVERS)
220
377 by Suren A. Chilingaryan
Clean-up python files during the clean and do not delete driver Makefile while packaging
221
PYTHON_CLEAN_LIST("${CMAKE_BINARY_DIR}/xml" XML_PY_FILES)
222
PYTHON_CLEAN_LIST("${CMAKE_BINARY_DIR}/pyserver" SERVER_PY_FILES)
223
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${XML_PY_FILES};${SERVER_PY_FILES}")
374 by Suren A. Chilingaryan
Handle build.h in releases
224
253 by Suren A. Chilingaryan
Include version information in all API descriptions
225
message("-- Configured pcitool ${PCILIB_VERSION_MAJOR}.${PCILIB_VERSION_MINOR}.${PCILIB_VERSION_MICRO} with public ABI ${PCILIB_ABI_VERSION}")