summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: 1ed3e4074a055cccfb448c2e671dd1679455daa0 (plain)
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
project(pcidev C)

set(RELEASE "0")
set(PCIDEV_VERSION "0.0.1")
set(PCIDEV_ABI_VERSION "0")

cmake_minimum_required(VERSION 2.6)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

add_definitions("-fPIC --std=gnu99 -Wall -O2 -gdwarf-2 -g3  -fno-omit-frame-pointer")

find_package(PkgConfig REQUIRED)
find_package(Threads REQUIRED)

pkg_check_modules(PCILIB pcitool>=0.2 REQUIRED)
exec_program("pkg-config --variable=plugindir pcitool" OUTPUT_VARIABLE PCILIB_PLUGIN_DIR)
exec_program("pkg-config --variable=datadir pcitool" OUTPUT_VARIABLE PCILIB_DATA_DIR)
exec_program("pkg-config --variable=modeldir pcitool" OUTPUT_VARIABLE PCILIB_MODEL_DIR)


include(cmake/version.cmake)
VERSION_TO_VARS(${PCIDEV_VERSION} PCIDEV_VERSION_MAJOR PCIDEV_VERSION_MINOR PCIDEV_VERSION_MICRO)

include(GNUInstallDirs)

add_subdirectory(xml)
#add_subdirectory(apps)

include_directories(
    ${CMAKE_SOURCE_DIR}
    ${CMAKE_BINARY_DIR}
    ${UFODECODE_INCLUDE_DIRS}
    ${PCILIB_INCLUDE_DIRS}
)

link_directories(
    ${UFODECODE_LIBRARY_DIRS}
    ${PCILIB_LIBRARY_DIRS}
)

#set(HEADERS ${HEADERS} model.h registers.h events.h env.h private.h pcidev.h version.h)
#add_library(pcidev SHARED model.c registers.c events.c env.c)

set(HEADERS ${HEADERS} model.h registers.h dma.h events.h env.h dma_private.h private.h pcidev.h version.h)
add_library(pcidev SHARED model.c registers.c dma.c events.c env.c)

target_link_libraries(pcidev ${PCILIB_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${UFODECODE_LIBRARIES} )

install(FILES pcidev.h
    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(TARGETS pcidev
    DESTINATION ${PCILIB_PLUGIN_DIR}
)

set(TARNAME "pcidev")
set(PACKAGE_VERSION ${PCIDEV_VERSION})
set(PACKAGE_NAME "${TARNAME}")
set(PACKAGE_TARNAME "${TARNAME}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "http://ufo.kit.edu/ufo/newticket")

set(CPACK_SOURCE_GENERATOR "TBZ2")
set(CPACK_PACKAGE_CONTACT "Suren A. Chilingaryan <csa@suren.me>")
if (${RELEASE} GREATER 0)
    set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}.${RELEASE}")
else (${RELEASE} GREATER 0)
    set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
endif (${RELEASE} GREATER 0)
set(CPACK_SOURCE_IGNORE_FILES "/.bzr/;CMakeFiles;_CPack_Packages;cmake_install.cmake;CPack.*.cmake;CMakeCache.txt;install_manifest.txt;config.h$;.pc$;Makefile;.tar.bz2$;~$;${CPACK_SOURCE_IGNORE_FILES}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}")
include(CPack)

add_custom_target(dist_clean COMMAND ${CMAKE_MAKE_PROGRAM} clean WORKING_DIRECTORY ${CMAKE_CURRENT_DIR})
add_custom_target(dist DEPENDS dist_clean COMMAND ${CMAKE_MAKE_PROGRAM} package_source)


configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcidev.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pcidev.pc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pcidev.spec.in ${CMAKE_CURRENT_BINARY_DIR}/pcidev.spec)

install(FILES 
    ${CMAKE_CURRENT_BINARY_DIR}/pcidev.pc 
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)