1+ # Copyright 2018 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2+ #
3+ # Licensed under the Apache License, Version 2.0 (the "License");
4+ # you may not use this file except in compliance with the License.
5+ # You may obtain a copy of the License at
6+ #
7+ # http://www.apache.org/licenses/LICENSE-2.0
8+ #
9+ # Unless required by applicable law or agreed to in writing, software
10+ # distributed under the License is distributed on an "AS IS" BASIS,
11+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ # See the License for the specific language governing permissions and
13+ # limitations under the License.
14+
15+ ###############################################################################
16+ #
17+ # CMake module for finding eProsima MICROXRCEDDS_AGENT.
18+ #
19+ # Output variables:
20+ #
21+ # - MicroXRCEDDS_Agent_FOUND: flag indicating if the package was found
22+ # - MicroXRCEDDS_Agent_INCLUDE_DIR: Paths to the header files
23+ #
24+ # Example usage:
25+ #
26+ # find_package(uros_agent_cmake_module REQUIRED)
27+ # find_package(MicroXRCEDDS_Agent MODULE)
28+ # # use MicroXRCEDDS_Agent_* variables
29+ #
30+ ###############################################################################
31+
32+ # lint_cmake: -convention/filename, -package/stdargs
33+
34+ set (MicroXRCEDDS_Agent_FOUND FALSE )
35+
36+ find_package (microxrcedds_agent REQUIRED CONFIG )
37+ find_package (fastcdr REQUIRED CONFIG )
38+ find_package (fastrtps REQUIRED CONFIG )
39+
40+ find_path (MicroXRCEDDS_Agent_INCLUDE_DIR NAMES uxr )
41+
42+ string (REGEX MATCH "^[0-9]+\\ .[0-9]+" microxrcedds_agent_MAJOR_MINOR_VERSION "${microxrcedds_agent_VERSION} " )
43+ string (REGEX MATCH "^[0-9]+\\ .[0-9]+" fastcdr_MAJOR_MINOR_VERSION "${fastcdr_VERSION} " )
44+ string (REGEX MATCH "^[0-9]+\\ .[0-9]+" fastrtps_MAJOR_MINOR_VERSION "${fastrtps_VERSION} " )
45+
46+ ##
47+ find_library (MicroXRCEDDS_Agent_LIBRARY_RELEASE
48+ NAMES microxrcedds_agent-${microxrcedds_agent_MAJOR_MINOR_VERSION} microxrcedds_agent )
49+
50+ find_library (MicroXRCEDDS_Agent_LIBRARY_DEBUG
51+ NAMES microxrcedds_agentd-${microxrcedds_agent_MAJOR_MINOR_VERSION} microxrcedds_agentd )
52+
53+ if (MicroXRCEDDS_Agent_LIBRARY_RELEASE AND MicroXRCEDDS_Agent_LIBRARY_DEBUG)
54+ set (MicroXRCEDDS_Agent_LIBRARIES
55+ optimized ${MicroXRCEDDS_Agent_LIBRARY_RELEASE}
56+ debug ${MicroXRCEDDS_Agent_LIBRARY_DEBUG}
57+ )
58+ elseif (MicroXRCEDDS_Agent_LIBRARY_RELEASE)
59+ set (MicroXRCEDDS_Agent_LIBRARIES
60+ ${MicroXRCEDDS_Agent_LIBRARY_RELEASE}
61+ )
62+ elseif (MicroXRCEDDS_Agent_LIBRARY_DEBUG)
63+ set (MicroXRCEDDS_Agent_LIBRARIES
64+ ${MicroXRCEDDS_Agent_LIBRARY_DEBUG}
65+ )
66+ else ()
67+ set (MicroXRCEDDS_Agent_LIBRARIES "" )
68+ endif ()
69+
70+ ##
71+ find_library (FastRTPS_LIBRARY_RELEASE
72+ NAMES fastrtps-${fastrtps_MAJOR_MINOR_VERSION} fastrtps )
73+
74+ find_library (FastRTPS_LIBRARY_DEBUG
75+ NAMES fastrtpsd-${fastrtps_MAJOR_MINOR_VERSION} fastrtpsd )
76+
77+ if (FastRTPS_LIBRARY_RELEASE AND FastRTPS_LIBRARY_DEBUG)
78+ set (FastRTPS_LIBRARIES
79+ optimized ${FastRTPS_LIBRARY_RELEASE}
80+ debug ${FastRTPS_LIBRARY_DEBUG}
81+ )
82+ elseif (FastRTPS_LIBRARY_RELEASE)
83+ set (FastRTPS_LIBRARIES
84+ ${MicroXRCEDDS_Agent_LIBRARY_RELEASE}
85+ )
86+ elseif (FastRTPS_LIBRARY_DEBUG)
87+ set (FastRTPS_LIBRARIES
88+ ${MicroXRCEDDS_Agent_LIBRARY_DEBUG}
89+ )
90+ else ()
91+ set (FastRTPS_LIBRARIES "" )
92+ endif ()
93+
94+ ##
95+ find_library (FastCDR_LIBRARY_RELEASE
96+ NAMES fastcdr-${fastcdr_MAJOR_MINOR_VERSION} fastcdr )
97+
98+ find_library (FastCDR_LIBRARY_DEBUG
99+ NAMES fastcdrd-${fastcdr_MAJOR_MINOR_VERSION} fastcdrd )
100+
101+ if (FastCDR_LIBRARY_RELEASE AND FastCDR_LIBRARY_DEBUG)
102+ set (FastCDR_LIBRARIES
103+ optimized ${FastCDR_LIBRARY_RELEASE}
104+ debug ${FastCDR_LIBRARY_DEBUG}
105+ )
106+ elseif (FastCDR_LIBRARY_RELEASE)
107+ set (FastCDR_LIBRARIES
108+ ${FastCDR_LIBRARY_RELEASE}
109+ )
110+ elseif (FastCDR_LIBRARY_DEBUG)
111+ set (FastCDR_LIBRARIES
112+ ${FastCDR_LIBRARY_DEBUG}
113+ )
114+ else ()
115+ set (FastCDR_LIBRARIES "" )
116+ endif ()
117+
118+ include (FindPackageHandleStandardArgs )
119+ find_package_handle_standard_args (MicroXRCEDDS_Agent
120+ FOUND_VAR MicroXRCEDDS_Agent_FOUND
121+ REQUIRED_VARS
122+ MicroXRCEDDS_Agent_INCLUDE_DIR
123+ MicroXRCEDDS_Agent_LIBRARIES
124+ )
0 commit comments