-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
149 lines (116 loc) · 3.86 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#-------------------------------------------------------------------------------
# Base settings.
#-------------------------------------------------------------------------------
# Set CMake minimum required version.
cmake_minimum_required(VERSION 3.0)
# Set project information.
project(
PelcoD
VERSION 1.0.0
LANGUAGES CXX
)
# Set C++ standard version.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#-------------------------------------------------------------------------------
# Build variables settings.
#-------------------------------------------------------------------------------
# Set library target name.
set(LIBRARY_TARGET "pelcod")
# Set path to source files.
set(SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Source)
# Set library definitions.
add_definitions(-DPELCOD_LIBRARY)
#-------------------------------------------------------------------------------
# Project files settings.
#-------------------------------------------------------------------------------
# Set source header files.
set(
SOURCE_HEADER_FILES
${SOURCE_PATH}/Export.hpp
${SOURCE_PATH}/AbstractPelcoDDevice.hpp
${SOURCE_PATH}/PelcoDEDeviceUDP.hpp
)
# Set source source files.
set(
SOURCE_SOURCE_FILES
${SOURCE_PATH}/AbstractPelcoDDevice.cpp
${SOURCE_PATH}/PelcoDEDeviceUDP.cpp
)
# Set source files to list.
list(
APPEND SOURCE_FILES
${SOURCE_HEADER_FILES}
${SOURCE_SOURCE_FILES}
)
#-------------------------------------------------------------------------------
# External packages settings.
#-------------------------------------------------------------------------------
# Find Boost C++ Libraries.
find_package(
Boost 1.56
REQUIRED COMPONENTS system
)
# Print an error message if Boost C++ Libraries are not found.
if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost C++ Libraries are required to build the library")
endif()
#-------------------------------------------------------------------------------
# Include directories settings.
#-------------------------------------------------------------------------------
# Set source include directories to list.
list(
APPEND SOURCE_INCLUDE_DIRECTORIES
${SOURCE_PATH}
${Boost_INCLUDE_DIRS}
)
#-------------------------------------------------------------------------------
# External libraries settings.
#-------------------------------------------------------------------------------
# Set main external libraries to list.
list(
APPEND SOURCE_EXTERNAL_LIBRARIES
${Boost_LIBRARIES}
)
#-------------------------------------------------------------------------------
# Library target settings.
#-------------------------------------------------------------------------------
# Add library target.
add_library(
${LIBRARY_TARGET} SHARED
${SOURCE_FILES}
)
# Add library include directories.
target_include_directories(
${LIBRARY_TARGET}
PUBLIC ${SOURCE_INCLUDE_DIRECTORIES}
)
# Link library external libraries.
target_link_libraries(
${LIBRARY_TARGET}
PUBLIC ${SOURCE_EXTERNAL_LIBRARIES}
)
# Set target properties.
set_target_properties(
${LIBRARY_TARGET} PROPERTIES
VERSION ${PROJECT_VERSION_MAJOR}
SOVERSION 1
)
#-------------------------------------------------------------------------------
# Install settings.
#-------------------------------------------------------------------------------
# Define GNU standard installation directories.
include(GNUInstallDirs)
# Install binaries.
install(
TARGETS ${LIBRARY_TARGET}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
# Install include files.
install(
DIRECTORY "${SOURCE_PATH}/"
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.hpp"
)