-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeature.cmake
64 lines (49 loc) · 1.75 KB
/
feature.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
################
## Features
#########################
MACRO(FEATURE_CHECK_LIB_EXIST out_result lib_name)
set(feature_filename "${CMAKE_BINARY_DIR}/feature_check.c")
set(FEATUTE_CHECK_STRING "
int main(void) {
return 0;
}")
file(WRITE ${feature_filename} "${FEATUTE_CHECK_STRING}")
try_compile(${out_result} "${CMAKE_BINARY_DIR}" "${feature_filename}"
CMAKE_FLAGS "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
"-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}"
LINK_LIBRARIES "${lib_name}"
)
IF(${${out_result}})
message(STATUS "Library check \"${lib_name}\": exist")
ELSE()
message(STATUS "Library check \"${lib_name}\": not exist")
ENDIF()
file(REMOVE ${feature_filename})
unset(FEATUTE_CHECK_STRING)
unset(feature_filename)
ENDMACRO()
MACRO(FEATURE_CHECK_HEADERS_EXIST out_result check_name header_list)
set(feature_filename "${CMAKE_BINARY_DIR}/feature_check.c")
set(FEATUTE_CHECK_STRING "")
FOREACH(item ${header_list})
set(FEATUTE_CHECK_STRING "${FEATUTE_CHECK_STRING}#include \"${item}\"\n")
ENDFOREACH()
set(FEATUTE_CHECK_STRING "
${FEATUTE_CHECK_STRING}
int main(void) {
return 0;
}")
file(WRITE ${feature_filename} "${FEATUTE_CHECK_STRING}")
try_compile(${out_result} "${CMAKE_BINARY_DIR}" "${feature_filename}"
CMAKE_FLAGS "-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}"
"-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}"
)
IF(${${out_result}})
message(STATUS "Includes check \"${check_name}\": exist")
ELSE()
message(STATUS "Includes check \"${check_name}\": not exist")
ENDIF()
file(REMOVE ${feature_filename})
unset(FEATUTE_CHECK_STRING)
unset(feature_filename)
ENDMACRO()