CrucibleCheck.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
include_guard(GLOBAL) include(CheckCXXSourceCompiles) function(crucible_check_target_system_is_64_bit) message(STATUS "Checking if target system is 64-bit...") set(CMAKE_REQUIRED_QUIET TRUE) check_cxx_source_compiles( " #include <climits> static_assert(sizeof(void *) == 8); static_assert(CHAR_BIT == 8); int main() { return 0; } " CRUCIBLE_TARGET_SYSTEM_IS_64_BIT) if(CRUCIBLE_TARGET_SYSTEM_IS_64_BIT) message(STATUS " Yes!") else() message(FATAL_ERROR "Crucible only supports 64-bit targets") endif() endfunction() function(crucible_check_target_system_is_unix_like) message(STATUS "Checking if target system is Unix-like...") if(UNIX) set(CRUCIBLE_TARGET_SYSTEM_IS_UNIX_LIKE TRUE CACHE INTERNAL "") message(STATUS " Yes!") else() message(STATUS " No!") endif() endfunction() function(crucible_check_target_system_is_windows_like) message(STATUS "Checking if target system is Windows-like...") if(WIN32) set(CRUCIBLE_TARGET_SYSTEM_IS_WINDOWS_LIKE TRUE CACHE INTERNAL "") message(STATUS " Yes!") else() message(STATUS " No!") endif() endfunction() function(crucible_check_target_system_has_dirent_d_namlen) message(STATUS "Checking if target system has `struct dirent::d_namlen`...") set(CMAKE_REQUIRED_QUIET TRUE) check_cxx_source_compiles( " #include <dirent.h> int main() { struct ::dirent entry; entry.d_namlen = 0; return 0; } " CRUCIBLE_TARGET_SYSTEM_HAS_DIRENT_D_NAMLEN) if(CRUCIBLE_TARGET_SYSTEM_HAS_DIRENT_D_NAMLEN) message(STATUS " Yes!") else() message(STATUS " No!") endif() endfunction()