forked from flacon/shdtool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
funcs.cmake
75 lines (55 loc) · 2.36 KB
/
funcs.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
71
72
73
74
75
# Generate glue_modes.c ************************
function(create_glue_modules _OUT_FILE)
file(WRITE ${_OUT_FILE} "/* This file is automatically generated by cmake.\n * Do not edit by hand!\n */\n\n")
file(APPEND ${_OUT_FILE} "#include \"shdtool.h\"\n\n")
foreach(F ${SOURCES})
get_filename_component(F ${F} NAME_WE)
string(FIND ${F} "mode_" MATCH)
if( ${MATCH} EQUAL 0)
file(APPEND ${_OUT_FILE} "extern mode_module ${F};\n")
endif()
endforeach()
file(APPEND ${_OUT_FILE} "\nmode_module *st_modes[] = {\n")
foreach(F ${SOURCES})
get_filename_component(F ${F} NAME_WE)
string(FIND ${F} "mode_" MATCH)
if( ${MATCH} EQUAL 0)
file(APPEND ${_OUT_FILE} " &${F},\n")
endif()
endforeach()
file(APPEND ${_OUT_FILE} " NULL\n")
file(APPEND ${_OUT_FILE} "};")
endfunction()
# Generate glue_formats.c **********************
function(create_glue_formats _OUT_FILE)
file(WRITE ${_OUT_FILE} "/* This file is automatically generated by cmake.\n * Do not edit by hand!\n */\n\n")
file(APPEND ${_OUT_FILE} "#include \"shdtool.h\"\n\n")
foreach(F ${SOURCES})
get_filename_component(F ${F} NAME_WE)
string(FIND ${F} "format_" MATCH)
if( ${MATCH} EQUAL 0)
file(APPEND ${_OUT_FILE} "extern format_module ${F};\n")
endif()
endforeach()
file(APPEND ${_OUT_FILE} "\nformat_module *st_formats[] = {\n")
foreach(F ${SOURCES})
get_filename_component(F ${F} NAME_WE)
string(FIND ${F} "format_" MATCH)
if( ${MATCH} EQUAL 0)
file(APPEND ${_OUT_FILE} " &${F},\n")
endif()
endforeach()
file(APPEND ${_OUT_FILE} " NULL\n")
file(APPEND ${_OUT_FILE} "};")
endfunction()
# Man page **************************************
function(create_man _MAN_NAME _IN_FILE)
get_filename_component(NAME ${_MAN_NAME} NAME_WE)
get_filename_component(NUM ${_MAN_NAME} EXT)
string(SUBSTRING ${NUM} 1, -1, NUM)
configure_file("${_IN_FILE}" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.${NUM}" @ONLY)
add_custom_command(TARGET ${PROJECT_NAME}
COMMAND gzip -c "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.${NUM}" > "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.${NUM}.gz"
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.${NUM}.gz" DESTINATION share/man/man${NUM})
endfunction()