forked from snikulov/cmake-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FindOPAL.cmake
158 lines (134 loc) · 4.37 KB
/
FindOPAL.cmake
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
150
151
152
153
154
155
156
157
#------------------------------------------------------------------------------------
# Locate OPAL library (http://www.opalvoip.org/)
# This module defines
# OPAL_FOUND, if false, do not try to link to OPAL
# OPAL_LIBRARIES
# OPAL_INCLUDE_DIRS, where to find opal headers
#
# 2013/03/19 - aagenosov
# Module created
# 2013/03/21 - aagenosov
# Added macro to define version of OPAL
# 2015/08/13 - snikulov
# Added linux support
#-------------------------------------------------------------------------------------
# get version macro
# first param - path to include
macro(opal_get_version _include_PATH version)
if (EXISTS "${_include_PATH}/opal/buildopts.h")
file(STRINGS "${_include_PATH}/opal/buildopts.h" _VER_STRING_AUX REGEX ".*#define[ ]+OPAL_VERSION[ ]+")
else()
file(STRINGS "${_include_PATH}/opal_config.h" _VER_STRING_AUX REGEX ".*#define[ ]+OPAL_VERSION[ ]+")
endif()
string(REGEX MATCHALL "[0-9]+[.][0-9]+[.][0-9]+" ${version} "${_VER_STRING_AUX}")
endmacro()
find_package(PTLib REQUIRED)
include(FindPkgConfig)
PKG_CHECK_MODULES(PC_OPAL "opal")
find_path(OPAL_INCLUDE_DIRS opal.h
PATHS
${PC_OPAL_INCLUDE_DIRS}
/usr/local/include
/usr/include
/opt/local/include
/opt/csw/include
/opt/include
$ENV{OPAL_DIR}/include
${OPAL_DIR}/include
)
if(PC_OPAL_FOUND)
set(OPAL_VERSION ${PC_OPAL_VERSION})
set(OPAL_INCLUDE_DIRS ${PC_OPAL_INCLUDE_DIRS})
find_library(OPAL_LIBRARIES
NAMES ${PC_OPAL_LIBRARIES}
PATH ${PC_OPAL_LIBRARY_DIRS})
else()
if(OPAL_USE_STATIC_LIBS)
set(opal_postfix "${opal_postfix}S")
endif()
set(OPAL_NAME_RELEASE "opal${opal_postfix}")
set(OPAL_NAME_DEBUG "opal${opal_postfix}D")
set(OPAL64_NAME_RELEASE "opal64${opal_postfix}")
set(OPAL64_NAME_DEBUG "opal64${opal_postfix}D")
find_library(OPAL_LIBRARY_RELEASE
NAMES
${OPAL_NAME_RELEASE}
${OPAL64_NAME_RELEASE}
PATHS
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
$ENV{OPAL_DIR}/lib
${OPAL_DIR}/lib
NO_DEFAULT_PATH
)
find_library(OPAL_LIBRARY_DEBUG
NAMES
${OPAL_NAME_DEBUG}
${OPAL64_NAME_DEBUG}
PATHS
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
$ENV{OPAL_DIR}/lib
${OPAL_DIR}/lib
NO_DEFAULT_PATH
)
if(OPAL_INCLUDE_DIRS)
opal_get_version(${OPAL_INCLUDE_DIRS} OPAL_VERSION)
endif()
if(OPAL_LIBRARY_DEBUG AND OPAL_LIBRARY_RELEASE)
set(OPAL_LIBRARIES
debug ${OPAL_LIBRARY_DEBUG}
optimized ${OPAL_LIBRARY_RELEASE}
CACHE STRING "OPAL Libraries")
endif()
endif()
include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set OPAL_FOUND to TRUE if
# all listed variables are TRUE
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPAL DEFAULT_MSG OPAL_LIBRARIES OPAL_INCLUDE_DIRS)
MARK_AS_ADVANCED(OPAL_INCLUDE_DIRS OPAL_LIBRARIES
OPAL_LIBRARY_DEBUG OPAL_LIBRARY_RELEASE)
if(OPAL_FOUND)
message("-- OPAL version is: ${OPAL_VERSION}")
# short hack for install and copy
if(NOT OPAL_USE_STATIC_LIBS AND CMAKE_SYSTEM_NAME STREQUAL "Windows")
find_file(OPAL_DLL_RELEASE
NAMES
${OPAL_NAME_RELEASE}.dll ${OPAL64_NAME_RELEASE}.dll
PATHS
$ENV{OPAL_DIR}/bin
${OPAL_DIR}/bin
NO_DEFAULT_PATH
)
find_file(OPAL_DLL_DEBUG
NAMES
${OPAL_NAME_DEBUG}.dll ${OPAL64_NAME_DEBUG}.dll
PATHS
$ENV{OPAL_DIR}/bin
${OPAL_DIR}/bin
NO_DEFAULT_PATH
)
get_filename_component(OPAL_RUNTIME_DIR ${OPAL_DLL_DEBUG} PATH)
MARK_AS_ADVANCED(OPAL_DLL_DEBUG OPAL_DLL_RELEASE OPAL_RUNTIME_DIR)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(PATH_TO_OPAL_PLUGINS ${OPAL_RUNTIME_DIR}/plugins)
if (EXISTS ${PATH_TO_OPAL_PLUGINS} AND IS_DIRECTORY ${PATH_TO_OPAL_PLUGINS})
file(GLOB _opal_plugins_ "${PATH_TO_OPAL_PLUGINS}/*.dll")
endif()
set(OPAL_PLUGINS)
foreach(_plugin ${_opal_plugins_})
list(APPEND OPAL_PLUGINS ${_plugin})
endforeach()
message("-- OPAL plugins: ${OPAL_PLUGINS}")
MARK_AS_ADVANCED(PATH_TO_OPAL_PLUGINS OPAL_PLUGINS)
endif()
endif()