-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruby-c-extension-examples.cmake
55 lines (45 loc) · 1.63 KB
/
ruby-c-extension-examples.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
set(THIRD_PARTY ${CMAKE_CURRENT_SOURCE_DIR}/tests/ruby-c-extension-examples/ThirdParty)
if(APPLE)
execute_process(COMMAND uname -m OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
set(RUBY_VERSIONS 2.7 3.2)
foreach(VERSION ${RUBY_VERSIONS})
# version
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)" _ ${VERSION})
set(SU_Ruby_${VERSION}_VERSION ${VERSION}.0)
set(SU_Ruby_${VERSION}_VERSION_MAJOR ${CMAKE_MATCH_1})
set(SU_Ruby_${VERSION}_VERSION_MINOR ${CMAKE_MATCH_2})
set(SU_Ruby_${VERSION}_VERSION_PATCH 0)
# set(SU_Ruby_${VERSION}_EXECUTABLE) # Not applicable
# includes
if(WIN32)
set(SU_Ruby_${VERSION}_INCLUDE_DIRS
${THIRD_PARTY}/include/ruby/${VERSION}/win32_x64
)
elseif(APPLE)
set(SU_Ruby_${VERSION}_INCLUDE_DIRS
${THIRD_PARTY}/include/ruby/${VERSION}/mac
${THIRD_PARTY_INCLUDE}/${VERSION}/mac/${ARCHITECTURE}-darwin
)
endif()
# libs
if(WIN32)
set(SU_Ruby_${VERSION}_LIBRARIES ${THIRD_PARTY}/lib/win32/x64-ucrt-ruby${SU_Ruby_${VERSION}_VERSION_MAJOR}${SU_Ruby_${VERSION}_VERSION_MINOR}0.lib)
elseif(APPLE)
set(SU_Ruby_${VERSION}_LIBRARIES ${THIRD_PARTY}/lib/mac/${VERSION}/Ruby.framework/Ruby)
endif()
if(EXISTS ${SU_Ruby_${VERSION}_LIBRARIES})
set(SU_Ruby_${VERSION}_FOUND TRUE)
endif()
endforeach()
# override for exceptions that don't follow naming conventions
if(WIN32)
set(SU_Ruby_2.7_LIBRARIES ${THIRD_PARTY}/lib/win32/x64-msvcrt-ruby270.lib)
elseif(APPLE)
set(SU_Ruby_2.7_LIBRARIES ${THIRD_PARTY}/lib/mac/2.7-universal/Ruby.framework/Ruby)
endif()
foreach(VERSION ${RUBY_VERSIONS})
if(EXISTS ${SU_Ruby_${VERSION}_LIBRARIES})
set(SU_Ruby_${VERSION}_FOUND TRUE)
endif()
endforeach()