-
Notifications
You must be signed in to change notification settings - Fork 214
/
CMakeLists.txt
74 lines (58 loc) · 2.83 KB
/
CMakeLists.txt
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
cmake_minimum_required (VERSION 3.0.2)
project (libpktriggercord C)
set (PK_VERSION 0.85.03)
set (PK_SOVERSION 0)
set (PK_DATADIR /usr/share/pktriggercord)
set (PK_DEBUG true)
set (PK_WARNINGS true)
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../cmake_modules/")
include (GNUInstallDirs)
find_package(INDI REQUIRED)
set (UDEVRULES_INSTALL_DIR "/lib/udev/rules.d" CACHE STRING "Base directory for udev rules")
# Build library
add_definitions (-DPKTDATADIR="${PK_DATADIR}")
add_definitions (-DVERSION="${PK_VERSION}")
include_directories (${CMAKE_CURRENT_BINARY_DIR})
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories (${CMAKE_CURRENT_SOURCE_DIR}/src/src/external/js0n)
include_directories (${INDI_INCLUDE_DIR})
# strip main function from pktriggercord
file (READ ${CMAKE_CURRENT_SOURCE_DIR}/src/pktriggercord-cli.c PK_CLI)
string (REGEX REPLACE "int main.*$" "" PK_CLI "${PK_CLI}")
file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/libpktriggercord.c "${PK_CLI}")
set (libpktriggercord_SRCS
${CMAKE_CURRENT_BINARY_DIR}/libpktriggercord.c # stripped
${CMAKE_CURRENT_SOURCE_DIR}/src/pslr.c
${CMAKE_CURRENT_SOURCE_DIR}/src/pslr_model.c
${CMAKE_CURRENT_SOURCE_DIR}/src/pslr_lens.c
${CMAKE_CURRENT_SOURCE_DIR}/src/pslr_enum.c
${CMAKE_CURRENT_SOURCE_DIR}/src/pslr_utils.c
${CMAKE_CURRENT_SOURCE_DIR}/src/pslr_log.c
${CMAKE_CURRENT_SOURCE_DIR}/src/pslr_scsi.c
${CMAKE_CURRENT_SOURCE_DIR}/src/src/external/js0n/js0n.c
${CMAKE_CURRENT_SOURCE_DIR}/src/pktriggercord-servermode.c
)
add_library (pktriggercord SHARED ${libpktriggercord_SRCS})
set_target_properties (pktriggercord PROPERTIES VERSION ${PK_VERSION} SOVERSION ${PK_SOVERSION})
# Build udev rules
add_custom_command (
OUTPUT 95-pentax.rules
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/pentax.rules ${CMAKE_CURRENT_BINARY_DIR}/95-pentax.rules
)
add_custom_command (
OUTPUT 95-samsung.rules
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/src/samsung.rules ${CMAKE_CURRENT_BINARY_DIR}/95-samsung.rules
)
add_custom_target (udev_rules ALL DEPENDS 95-pentax.rules 95-samsung.rules)
# Install udev rules
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/95-pentax.rules ${CMAKE_CURRENT_BINARY_DIR}/95-samsung.rules DESTINATION ${UDEVRULES_INSTALL_DIR})
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pentax_settings.json DESTINATION ${PK_DATADIR})
endif()
# Install header files
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION include/libpktriggercord FILES_MATCHING PATTERN "*.h")
install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/libpktriggercord)
# Install library
install (TARGETS pktriggercord DESTINATION ${CMAKE_INSTALL_LIBDIR})