blob: 65e54634972601aff515f3bd705e5894fd7b150d (
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
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
|
# - Find UMUNDO
# This module checks if UMundo is installed and determines where the
# include files and libraries are. This code sets the following
# variables:
#
# UMUNDO_INCLUDE_DIR = The full path to the umundo headers
# UMUNDO_LIBRARIES = All umundo libraries for release and debug builds
#
# Example:
# find_package(UMUNDO REQUIRED util serial rpc)
# include_directories(${UMUNDO_INCLUDE_DIR})
#
# is this a 64Bit host?
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(64BIT_LIB_POSTFIX 64)
else()
set(64BIT_LIB_POSTFIX "")
endif()
###################################################
# where to search for umundo headers and libraries
###################################################
set(_UMUNDO_LIB_SEARCHPATH
"/usr/local"
"/opt/local"
"C:/Program Files (x86)/uMundo"
"C:/Program Files/uMundo"
)
###################################################
# find the umundo header files
###################################################
FIND_PATH(UMUNDO_INCLUDE_DIR umundo/core.h
PATH_SUFFIXES include
PATHS ${_UMUNDO_LIB_SEARCHPATH}
ENV UMUNDO_INCLUDE_DIR
)
###################################################
# get a list of components the user requested
###################################################
set(_UMUNDO_COMPONENTS_TO_PROCESS)
foreach(_UMUNDO_COMPONENT ${UMUNDO_FIND_COMPONENTS})
STRING(TOUPPER ${_UMUNDO_COMPONENT} _UMUNDO_COMPONENT_UC)
list(APPEND _UMUNDO_COMPONENTS_TO_PROCESS ${_UMUNDO_COMPONENT_UC})
endforeach()
# is the convenience library requested?
list(FIND _UMUNDO_COMPONENTS_TO_PROCESS "CONVENIENCE" FOUND_ITEM)
if (FOUND_ITEM GREATER -1)
set(_UMUNDO_COMPONENTS_TO_PROCESS "CONVENIENCE")
else()
list(APPEND _UMUNDO_COMPONENTS_TO_PROCESS "CORE")
endif()
list(REMOVE_DUPLICATES _UMUNDO_COMPONENTS_TO_PROCESS)
###################################################
# iterate components and try to find libraries
# in debug and release configuration. For release
# we prefer MinSizeRel, for debug we prefer
# RelWithDebInfo.
###################################################
SET(UMUNDO_LIBRARIES)
foreach (_UMUNDO_COMPONENT ${_UMUNDO_COMPONENTS_TO_PROCESS})
SET(_CURR_COMPONENT "UMUNDO_${_UMUNDO_COMPONENT}_LIBRARY")
if (_UMUNDO_COMPONENT STREQUAL "CONVENIENCE")
STRING(TOLOWER "${64BIT_LIB_POSTFIX}" _UMUNDO_COMPONENT_LC)
else()
STRING(TOLOWER ${_UMUNDO_COMPONENT}${64BIT_LIB_POSTFIX} _UMUNDO_COMPONENT_LC)
endif()
# prefer MinSizeRel libraries
FIND_LIBRARY(${_CURR_COMPONENT}
PATH_SUFFIXES lib
NAMES umundo${_UMUNDO_COMPONENT_LC}_s
PATHS ${_UMUNDO_LIB_SEARCHPATH}
ENV UMUNDO_LIB_DIR
)
if (${_CURR_COMPONENT})
list(APPEND UMUNDO_LIBRARIES optimized ${${_CURR_COMPONENT}})
else()
# if no minsize libraries were found try normal release
FIND_LIBRARY(${_CURR_COMPONENT}
PATH_SUFFIXES lib
NAMES umundo${_UMUNDO_COMPONENT_LC}
PATHS ${_UMUNDO_LIB_SEARCHPATH}
ENV UMUNDO_LIB_DIR
)
if (${_CURR_COMPONENT})
list(APPEND UMUNDO_LIBRARIES optimized ${${_CURR_COMPONENT}})
endif()
endif()
# prefer RelWithDebInfo libraries
FIND_LIBRARY(${_CURR_COMPONENT}_DEBUG
PATH_SUFFIXES lib
NAMES umundo${_UMUNDO_COMPONENT_LC}_rd
PATHS ${_UMUNDO_LIB_SEARCHPATH}
ENV UMUNDO_LIB_DIR
)
if (${_CURR_COMPONENT}_DEBUG)
list(APPEND UMUNDO_LIBRARIES debug ${${_CURR_COMPONENT}_DEBUG})
else()
FIND_LIBRARY(${_CURR_COMPONENT}_DEBUG
PATH_SUFFIXES lib
NAMES umundo${_UMUNDO_COMPONENT_LC}_d
PATHS ${_UMUNDO_LIB_SEARCHPATH}
ENV UMUNDO_LIB_DIR
)
if (${_CURR_COMPONENT}_DEBUG)
list(APPEND UMUNDO_LIBRARIES debug ${${_CURR_COMPONENT}_DEBUG})
endif()
endif()
if (NOT ${_CURR_COMPONENT} AND NOT ${_CURR_COMPONENT}_DEBUG)
message(STATUS "Could not find umundo component ${_UMUNDO_COMPONENT}")
endif()
endforeach()
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(UMUNDO DEFAULT_MSG UMUNDO_LIBRARIES UMUNDO_INCLUDE_DIR)
MARK_AS_ADVANCED(UMUNDO_INCLUDE_DIR UMUNDO_LIBRARIES)
|