-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathmodbuspp-config.cmake.in
76 lines (64 loc) · 3.05 KB
/
modbuspp-config.cmake.in
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
# Copyright © 2018-2019 Pascal JEAN, All rights reserved.
# This file is part of the libmodbuspp Project.
#
# The libmodbuspp Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# The libmodbuspp Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with the libmodbuspp Library; if not, see <http://www.gnu.org/licenses/>.
# - Config file for the modbuspp package
# It defines the following variables
# MODBUSPP_INCLUDE_DIRS - include directories for modbuspp
# MODBUSPP_LIBRARY_DIRS - where to find libraries
# MODBUSPP_DATA_DIR - where to find modbuspp data
# MODBUSPP_LIBRARIES - libraries to link against
# MODBUSPP_CFLAGS - all required cflags
# MODBUSPP_LDFLAGS - all required ldflags
set(CMAKE_MODULE_PATH @MODBUSPP_INSTALL_CMAKE_DIR@ ${CMAKE_MODULE_PATH})
# Compute paths
get_filename_component(MODBUSPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules (LIBMODBUS lib@LIBMODBUS_NAME@>=@LIBMODBUS_MIN_VERSION@)
unset(MODBUSPP_INCLUDE_DIRS)
foreach(RELATIVE_PATH @CONF_INCLUDE_DIRS@)
set(ABSOLUTE_PATH)
get_filename_component(ABSOLUTE_PATH "${RELATIVE_PATH}" ABSOLUTE)
list(APPEND MODBUSPP_INCLUDE_DIRS "${ABSOLUTE_PATH}")
endforeach()
list(APPEND MODBUSPP_INCLUDE_DIRS "${LIBMODBUS_INCLUDE_DIRS}")
unset(MODBUSPP_LIBRARY_DIRS)
foreach(RELATIVE_PATH @CONF_LIB_DIRS@)
set(ABSOLUTE_PATH)
get_filename_component(ABSOLUTE_PATH "${RELATIVE_PATH}" ABSOLUTE)
list(APPEND MODBUSPP_LIBRARY_DIRS "${ABSOLUTE_PATH}")
list(APPEND MODBUSPP_LDFLAGS "-L${ABSOLUTE_PATH}")
endforeach()
list(APPEND MODBUSPP_LIBRARY_DIRS "${LIBMODBUS_LIBDIR}")
set(MODBUSPP_LDFLAGS -lmodbuspp ${LIBMODBUS_LDFLAGS} -lpthread)
# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET modbuspp-shared AND NOT TARGET modbuspp-static)
include("${MODBUSPP_CMAKE_DIR}/modbuspp.cmake")
endif()
# These are IMPORTED targets created by modbuspp.cmake
set(MODBUSPP_LIBRARIES modbuspp Threads::Threads ${LIBMODBUS_LIBRARIES})
unset(MODBUSPP_CFLAGS)
foreach(item ${MODBUSPP_INCLUDE_DIRS})
list(APPEND MODBUSPP_CFLAGS "-I${item}")
endforeach()
set(CMAKE_MODULE_PATH "${MODBUSPP_CMAKE_DIR}")
#message(STATUS "MODBUSPP_CMAKE_DIR=${MODBUSPP_CMAKE_DIR}")
#message(STATUS "MODBUSPP_INCLUDE_DIRS=${MODBUSPP_INCLUDE_DIRS}")
#message(STATUS "MODBUSPP_LIBRARY_DIRS=${MODBUSPP_LIBRARY_DIRS}")
#message(STATUS "MODBUSPP_LIBRARIES=${MODBUSPP_LIBRARIES}")
#message(STATUS "MODBUSPP_CFLAGS=${MODBUSPP_CFLAGS}")
#message(STATUS "MODBUSPP_LDFLAGS=${MODBUSPP_LDFLAGS}")