1
1
#[=======================================================================[.rst:
2
- Findmath
2
+ FindSwiftMath
3
3
------------
4
4
5
5
Find the Swift `_math` module interface, deferring to mathConfig.cmake when
@@ -23,73 +23,63 @@ Hint Variables
23
23
This only affects Linux and Windows builds.
24
24
Apple builds always use the library provided by the SDK.
25
25
26
- ``math_STATIC``
27
- Look for the libmath static archive instead of the dynamic library.
28
-
29
26
Result Variables
30
27
^^^^^^^^^^^^^^^^
31
28
32
- The module may set the following variables if `math_DIR ` is not set.
29
+ The module may set the following variables if `SwiftMath_DIR ` is not set.
33
30
34
- ``math_FOUND ``
31
+ ``SwiftMath_FOUND ``
35
32
true if the `_math` module interface (and required library) were found.
36
33
37
- ``math_INCLUDE_DIR ``
34
+ ``SwiftMath_INCLUDE_DIR ``
38
35
The directory containing the `_math.swiftinterface` file
39
36
40
- ``math_LIBRARIES `` OR ``math_IMPLIB ``
37
+ ``SwiftMath_LIBRARIES `` OR ``SwiftMath_IMPLIB ``
41
38
the libraries to be linked
42
39
43
40
#]=======================================================================]
44
41
45
42
# If the math_DIR is specified, look there instead. The cmake-generated
46
43
# config file is more accurate, but requires that the SDK has one available.
47
- if (math_DIR )
48
- if (math_FIND_REQUIRED )
44
+ if (SwiftMath_DIR )
45
+ if (SwiftMath_FIND_REQUIRED )
49
46
list (APPEND args REQUIRED )
50
47
endif ()
51
- if (math_FIND_QUIETLY )
48
+ if (SwiftMath_FIND_QUIETLY )
52
49
list (APPEND args QUIET )
53
50
endif ()
54
- find_package (math NO_MODULE ${args} )
51
+ find_package (SwiftMath NO_MODULE ${args} )
55
52
return ()
56
53
endif ()
57
54
58
55
include (FindPackageHandleStandardArgs )
59
56
include (PlatformInfo )
60
57
61
58
if (APPLE )
62
- find_path (math_INCLUDE_DIR
59
+ find_path (SwiftMath_INCLUDE_DIR
63
60
NAMES _math.swiftmodule
64
61
PATHS ${CMAKE_OSX_SYSROOT} /usr/lib/swift )
65
- find_path (math_IMPLIB
62
+ find_path (SwiftMath_IMPLIB
66
63
NAMES libm.tbd
67
64
PATHS usr/lib )
68
- add_library (math SHARED IMPORTED GLOBAL )
69
- set_target_properties (math PROPERTIES
70
- IMPORTED_IMPLIB ${math_IMPLIB }
71
- INTERFACE_INCLUDE_DIRECTORIES ${math_INCLUDE_DIR } )
72
- find_package_handle_standard_args (math DEFAULT_MSG
73
- math_IMPLIB math_INCLUDE_DIR )
65
+ add_library (SwiftMath SHARED IMPORTED GLOBAL )
66
+ set_target_properties (SwiftMath PROPERTIES
67
+ IMPORTED_IMPLIB ${SwiftMath_IMPLIB }
68
+ INTERFACE_INCLUDE_DIRECTORIES ${SwiftMath_INCLUDE_DIR } )
69
+ find_package_handle_standard_args (SwiftMath DEFAULT_MSG
70
+ SwiftMath_IMPLIB SwiftMath_INCLUDE_DIR )
74
71
elseif (LINUX )
75
- find_path (math_INCLUDE_DIR
72
+ find_path (SwiftMath_INCLUDE_DIR
76
73
glibc.modulemap
77
74
PATHS ${Swift_SDKROOT} /usr/lib/swift/linux/${SwiftSupplemental_ARCH_SUBDIR} )
78
- find_path (math_GLIBC_DIR
75
+ find_path (SwiftMath_GLIBC_DIR
79
76
Glibc.swiftmodule
80
77
PATHS ${Swift_SDKROOT} /usr/lib/swift/linux )
81
- find_library (math_LIBRARY NAMES m )
82
- if (math_STATIC )
83
- add_library (math STATIC IMPORTED GLOBAL )
84
- else ()
85
- add_library (math SHARED IMPORTED GLOBAL )
86
- endif ()
87
- set_target_properties (math PROPERTIES
88
- IMPORTED_LOCATION ${math_LIBRARY}
89
- INTERFACE_INCLUDE_DIRECTORIES ${math_INCLUDE_DIR} ${math_GLIBC_DIR} )
90
- find_package_handle_standard_args (math DEFAULT_MSG
91
- math_LIBRARY math_INCLUDE_DIR )
78
+ add_library (SwiftMath INTERFACE IMPORTED GLOBAL )
79
+ set_target_properties (SwiftMath PROPERTIES
80
+ INTERFACE_INCLUDE_DIRECTORIES ${SwiftMath_INCLUDE_DIR} ${SwiftMath_GLIBC_DIR} )
81
+ find_package_handle_standard_args (SwiftMath DEFAULT_MSG SwiftMath_INCLUDE_DIR )
92
82
else ()
93
83
# TODO: Windows
94
- message (FATAL_ERROR "Findmath .cmake module search not implemented for targeted platform\n " )
84
+ message (FATAL_ERROR "FindSwiftMath .cmake module search not implemented for targeted platform\n " )
95
85
endif ()
0 commit comments