File: FindACE.cmake

package info (click to toggle)
ycm-cmake-modules 0.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,640 kB
  • sloc: python: 319; sh: 181; makefile: 22
file content (255 lines) | stat: -rw-r--r-- 9,824 bytes parent folder | download
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# SPDX-FileCopyrightText: 2012-2021 Istituto Italiano di Tecnologia (IIT)
# SPDX-FileCopyrightText: 2009 RobotCub Consortium
# SPDX-License-Identifier: BSD-3-Clause

#[=======================================================================[.rst:
FindACE
-------

Try to find the ACE library

Targets set::

  ACE::ACE (links the ACE library)
  ACE::ACE_INLINE (INTERFACE library for ACE inlines only)

Variables set::

  ACE_FOUND           - System has ACE library
  ACE_LIBRARIES       - ACE link libraries
  ACE_INCLUDE_DIRS    - ACE library include directories
  ACE_DEFINITIONS     - Additional compiler flags for ACE library
  ACE_VERSION         - ACE library version
  ACE_MAJOR_VERSION   - ACE major version
  ACE_MINOR_VERSION   - ACE minor version
  ACE_BETA_VERSION    - ACE beta version

Options variables::

  ACE_INLINE (default ON)
    The ACE::ACE target passes __ACE_INLINE__ by default, this can be
    changed by setting ACE_INLINE = OFF.
    The ACE_DEFINITIONS variable is also influenced by the same option.
#]=======================================================================]


include(StandardFindModule)
standard_find_module(ACE ACE SKIP_CMAKE_CONFIG NOT_REQUIRED)

########################################################################
## Find include directory
find_path(ACE_INCLUDE_DIR
          NAMES ace/ACE.h
          PATHS $ENV{ACE_ROOT}
                $ENV{ACE_ROOT}/include
                /usr/include
                /usr/local/include
          DOC "directory containing ace/ACE.h for ACE library")
mark_as_advanced(ACE_INCLUDE_DIR)

set(ACE_INCLUDE_DIRS ${ACE_INCLUDE_DIR})

########################################################################
## Find libraries
find_library(ACE_ACE_LIBRARY_RELEASE
             NAMES ACE
                   ace
             PATHS $ENV{ACE_ROOT}/lib
                   $ENV{ACE_ROOT}
                   /usr/lib
                   /usr/local/lib
             DOC "ACE library file")

find_library(ACE_ACE_LIBRARY_DEBUG
             NAMES ACEd
                   aced
             PATHS $ENV{ACE_ROOT}/lib
                   $ENV{ACE_ROOT}
                   /usr/lib
                   /usr/local/lib
             DOC "ACE library file (debug version)")

include(SelectLibraryConfigurations)
select_library_configurations(ACE_ACE)

set(ACE_LIBRARIES ${ACE_ACE_LIBRARY})

########################################################################
## Definitions

if (NOT DEFINED ACE_INLINE OR ACE_INLINE)
  set(ACE_DEFINITIONS "__ACE_INLINE__")
endif()

########################################################################
## OS-specific extra linkage

# Solaris needs some extra libraries that may not have been found already
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  set(ACE_EXTRA_LIBRARIES socket rt nsl)
endif(CMAKE_SYSTEM_NAME STREQUAL "SunOS")

# ACE package doesn't specify that pthread and rt are needed, which is
# a problem for users of GoLD.  Link pthread (just on Linux for now).
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  set(ACE_EXTRA_LIBRARIES pthread rt)
endif(CMAKE_SYSTEM_NAME STREQUAL "Linux")

# Windows needs some extra libraries
if(WIN32 AND NOT CYGWIN)
  set(ACE_EXTRA_LIBRARIES winmm)
endif(WIN32 AND NOT CYGWIN)

# Mingw needs some extra libraries
if(MINGW)
  set(ACE_EXTRA_LIBRARIES winmm ws2_32 wsock32)
endif(MINGW)

list(APPEND ACE_LIBRARIES ${ACE_EXTRA_LIBRARIES})

########################################################################
## Set up flags and complain to user if necessary
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ACE FOUND_VAR ACE_FOUND
                                      REQUIRED_VARS ACE_LIBRARIES ACE_INCLUDE_DIRS
                                      VERSION_VAR ACE_VERSION)

########################################################################
# Set package properties if FeatureSummary was included
if(COMMAND set_package_properties)
  set_package_properties(ACE PROPERTIES DESCRIPTION "The ADAPTIVE Communication Environment"
                                        URL "http://www.cs.wustl.edu/~schmidt/ACE.html")
endif()

########################################################################
# Stop here if ACE was not found
if(NOT ACE_FOUND)
  return()
endif()

########################################################################
## Read version from ace/Version.h file
if(EXISTS "${ACE_INCLUDE_DIR}/ace/Version.h")
  file(STRINGS "${ACE_INCLUDE_DIR}/ace/Version.h" _contents REGEX "#define ACE_[A-Z]+_VERSION[ \t]+")

  if(_contents)
    string(REGEX REPLACE ".*#define ACE_MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" ACE_MAJOR_VERSION "${_contents}")
    string(REGEX REPLACE ".*#define ACE_MINOR_VERSION[ \t]+([0-9]+).*" "\\1" ACE_MINOR_VERSION "${_contents}")
    string(REGEX REPLACE ".*#define ACE_BETA_VERSION[ \t]+([0-9]+).*" "\\1" ACE_BETA_VERSION "${_contents}")

    if(NOT ACE_MAJOR_VERSION MATCHES "[0-9]+")
      message(FATAL_ERROR "Version parsing failed for ACE_MAJOR_VERSION!")
    endif()
    if(NOT ACE_MINOR_VERSION MATCHES "[0-9]+")
      message(FATAL_ERROR "Version parsing failed for ACE_MINOR_VERSION!")
    endif()
    if(NOT ACE_BETA_VERSION MATCHES "[0-9]+")
    message(FATAL_ERROR "Version parsing failed for ACE_BETA_VERSION!")
    endif()
  endif()
  set(ACE_VERSION "${ACE_MAJOR_VERSION}.${ACE_MINOR_VERSION}.${ACE_BETA_VERSION}")
endif()

########################################################################
## If ACE was found, check if some features are available

# Create and populate the ACE::ACE target
if(NOT TARGET ACE::ACE)
  add_library(ACE::ACE UNKNOWN IMPORTED)
  set_target_properties(ACE::ACE PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ACE_INCLUDE_DIRS}")
  set_target_properties(ACE::ACE PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${ACE_INCLUDE_DIRS}")
  set_target_properties(ACE::ACE PROPERTIES INTERFACE_LINK_LIBRARIES "${ACE_EXTRA_LIBRARIES}")
  if (NOT DEFINED ACE_INLINE OR ACE_INLINE)
    set_target_properties(ACE::ACE PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__ACE_INLINE__")
  endif()

  if(ACE_ACE_LIBRARY_RELEASE)
    set_property(TARGET ACE::ACE APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
    set_target_properties(ACE::ACE PROPERTIES IMPORTED_LOCATION_RELEASE "${ACE_ACE_LIBRARY_RELEASE}")
    set_target_properties(ACE::ACE PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "CXX")
  endif()

  if(ACE_ACE_LIBRARY_DEBUG)
    set_property(TARGET ACE::ACE APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
    set_target_properties(ACE::ACE PROPERTIES IMPORTED_LOCATION_DEBUG "${ACE_ACE_LIBRARY_DEBUG}")
    set_target_properties(ACE::ACE PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "CXX")
  endif()
endif()
# Create and populate the ACE::ACE_INLINE target
if(NOT TARGET ACE::ACE_INLINE)
  add_library(ACE::ACE_INLINE INTERFACE IMPORTED)
  set_target_properties(ACE::ACE_INLINE PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${ACE_INCLUDE_DIRS}")
  set_target_properties(ACE::ACE_INLINE PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${ACE_INCLUDE_DIRS}")
  set_target_properties(ACE::ACE_INLINE PROPERTIES INTERFACE_LINK_LIBRARIES "${ACE_EXTRA_LIBRARIES}")
  set_target_properties(ACE::ACE_INLINE PROPERTIES INTERFACE_COMPILE_DEFINITIONS "__ACE_INLINE__")
endif()

########################################################################
## Compatibility with older versions

if (NOT COMMAND _FindACE_Deprecated)
  # If set, save variables for later
  set(_CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_TRY_COMPILE_CONFIGURATION})
  set(_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
  set(_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})

  include (CheckCXXSourceCompiles)

  # "__ACE_INLINE__" is needed in some configurations
  set(_ACE_NEEDS_INLINE_CPP "
  #include <ace/OS_NS_unistd.h>
  #include <ace/Time_Value.h>
  void time_delay(double seconds) {
      ACE_Time_Value tv;
      tv.sec (long(seconds));
      tv.usec (long((seconds-long(seconds)) * 1.0e6));
      ACE_OS::sleep(tv);
  }
  int main(int argc, char *argv[]) {
      time_delay(1);
      return 0;
  }
  ")
  set(CMAKE_REQUIRED_INCLUDES ${ACE_INCLUDE_DIRS})
  set(CMAKE_REQUIRED_LIBRARIES ${ACE_LIBRARIES})
  if(ACE_ACE_LIBRARY_RELEASE)
    set(CMAKE_TRY_COMPILE_CONFIGURATION "Release")
    check_cxx_source_compiles("${_ACE_NEEDS_INLINE_CPP}" ACE_COMPILES_WITHOUT_INLINE_RELEASE)
  endif()
  if(ACE_ACE_LIBRARY_DEBUG)
    set(CMAKE_TRY_COMPILE_CONFIGURATION "Debug")
    check_cxx_source_compiles("${_ACE_NEEDS_INLINE_CPP}" ACE_COMPILES_WITHOUT_INLINE_DEBUG)
  endif()

  # Reset variables to their original values
  set(CMAKE_TRY_COMPILE_CONFIGURATION ${_CMAKE_TRY_COMPILE_CONFIGURATION})
  set(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES})
  set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES})
  unset(_CMAKE_TRY_COMPILE_CONFIGURATION)
  unset(_CMAKE_REQUIRED_INCLUDES)
  unset(_CMAKE_REQUIRED_LIBRARIES)

  function(_FindACE_Deprecated _variable _access _value _current_list_file _stack)
    message(DEPRECATION "${_variable} is deprecated")
  endfunction()

  set(ACE_LIBRARY_RELEASE ${ACE_ACE_LIBRARY_RELEASE})
  set(ACE_LIBRARY_DEBUG ${ACE_ACE_LIBRARY_DEBUG})
  set(ACE_LIBRARY ${ACE_ACE_LIBRARY})
  set(ACE_HAS_STRING_HASH 1)

  # Check for ACE_INET_Addr::is_loopback
  if("${ACE_VERSION}" VERSION_LESS "5.4.8")
    set(ACE_ADDR_HAS_LOOPBACK_METHOD 0)
  else()
    set(ACE_ADDR_HAS_LOOPBACK_METHOD 1)
  endif()

  variable_watch(ACE_LIBRARY_RELEASE _FindACE_Deprecated)
  variable_watch(ACE_LIBRARY_DEBUG _FindACE_Deprecated)
  variable_watch(ACE_LIBRARY _FindACE_Deprecated)
  variable_watch(ACE_HAS_STRING_HASH _FindACE_Deprecated)
  variable_watch(ACE_ADDR_HAS_LOOPBACK_METHOD _FindACE_Deprecated)
  variable_watch(ACE_COMPILES_WITHOUT_INLINE_RELEASE _FindACE_Deprecated)
  variable_watch(ACE_COMPILES_WITHOUT_INLINE_DEBUG _FindACE_Deprecated)
endif()