summaryrefslogtreecommitdiff
path: root/Userland/Utilities/CMakeLists.txt
blob: 00b62ffd80ff12b2a090413c70231e28a41dc23a (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
file(GLOB CMD_SOURCES  CONFIGURE_DEPENDS "*.cpp")
list(APPEND SPECIAL_TARGETS test install)
list(APPEND REQUIRED_TARGETS
    arp base64 basename cat chmod chown clear comm cp cut date dd df diff dirname dmesg du echo env expr false fgrep
    file find grep groups head host hostname id ifconfig kill killall ln logout ls mkdir mount mv nproc
    pgrep pidof ping pmap ps readlink realpath reboot rm rmdir seq shutdown sleep sort stat stty su tail test
    touch tr true umount uname uniq uptime w wc which whoami xargs yes less
)
list(APPEND RECOMMENDED_TARGETS
    adjtime aplay asctl bt checksum chres cksum copy fortune gunzip gzip init keymap lsirq lsof lspci man mknod mktemp
    modload modunload nc netstat notify ntpquery open pape passwd pls printf pro shot tar tt unzip zip
)

# FIXME: Support specifying component dependencies for utilities (e.g. WebSocket for telws)

foreach(CMD_SRC ${CMD_SOURCES})
    get_filename_component(CMD_NAME ${CMD_SRC} NAME_WE)
    if (CMD_NAME IN_LIST SPECIAL_TARGETS)
        set(TARGET_NAME "${CMD_NAME}-bin")
    else()
        set(TARGET_NAME "${CMD_NAME}")
    endif()
    if(CMD_NAME IN_LIST REQUIRED_TARGETS)
        serenity_component(
            ${CMD_NAME}
            REQUIRED
            TARGETS ${TARGET_NAME}
        )
    elseif(CMD_NAME IN_LIST RECOMMENDED_TARGETS)
        serenity_component(
            ${CMD_NAME}
            RECOMMENDED
            TARGETS ${TARGET_NAME}
        )
    else()
        serenity_component(
            ${CMD_NAME}
            TARGETS ${TARGET_NAME}
        )
    endif()
    if (CMD_NAME IN_LIST SPECIAL_TARGETS)
        add_executable(${TARGET_NAME} ${CMD_SRC})
        target_link_libraries(${TARGET_NAME} LibCore)
        install(TARGETS ${TARGET_NAME} RUNTIME DESTINATION bin)
        install(CODE "file(RENAME ${CMAKE_INSTALL_PREFIX}/bin/${CMD_NAME}-bin ${CMAKE_INSTALL_PREFIX}/bin/${CMD_NAME})")
    else()
        add_executable(${CMD_NAME} ${CMD_SRC})
        set_target_properties(${CMD_NAME} PROPERTIES EXCLUDE_FROM_ALL TRUE)
        target_link_libraries(${CMD_NAME} LibCore)
        install(TARGETS ${CMD_NAME} RUNTIME DESTINATION bin OPTIONAL)
    endif()
endforeach()

target_link_libraries(aplay LibAudio)
target_link_libraries(asctl LibAudio)
target_link_libraries(bt LibSymbolication)
target_link_libraries(checksum LibCrypto)
target_link_libraries(chres LibGUI)
target_link_libraries(cksum LibCrypto)
target_link_libraries(config LibConfig)
target_link_libraries(copy LibGUI)
target_link_libraries(diff LibDiff)
target_link_libraries(disasm LibX86)
target_link_libraries(dmesg LibMain)
target_link_libraries(expr LibRegex)
target_link_libraries(fdtdump LibDeviceTree)
target_link_libraries(file LibGfx LibIPC LibCompress)
target_link_libraries(functrace LibDebug LibX86)
target_link_libraries(gml-format LibGUI)
target_link_libraries(grep LibRegex)
target_link_libraries(gunzip LibCompress)
target_link_libraries(gzip LibCompress)
target_link_libraries(id LibMain)
target_link_libraries(js LibJS LibLine LibMain)
target_link_libraries(keymap LibKeyboard LibMain)
target_link_libraries(lspci LibPCIDB)
target_link_libraries(lsusb LibUSBDB)
target_link_libraries(man LibMarkdown)
target_link_libraries(markdown-check LibMarkdown)
target_link_libraries(matroska LibVideo)
target_link_libraries(md LibMarkdown)
target_link_libraries(notify LibGUI)
target_link_libraries(nproc LibMain)
target_link_libraries(open LibDesktop)
target_link_libraries(pape LibGUI)
target_link_libraries(passwd LibCrypt)
target_link_libraries(paste LibGUI)
target_link_libraries(pgrep LibRegex)
target_link_libraries(pls LibCrypt)
target_link_libraries(pmap LibMain)
target_link_libraries(pro LibProtocol)
target_link_libraries(ps LibMain)
target_link_libraries(run-tests LibRegex)
target_link_libraries(shot LibGUI)
target_link_libraries(sql LibLine LibSQL LibIPC)
target_link_libraries(su LibCrypt)
target_link_libraries(tar LibArchive LibCompress)
target_link_libraries(telws LibProtocol LibLine)
target_link_libraries(test-crypto LibCrypto LibTLS LibLine)
target_link_libraries(test-fuzz LibCore LibGemini LibGfx LibHTTP LibIPC LibJS LibMarkdown LibShell)
target_link_libraries(test-imap LibIMAP)
target_link_libraries(test-pthread LibThreading)
target_link_libraries(truncate LibMain)
target_link_libraries(tt LibPthread)
target_link_libraries(unzip LibArchive LibCompress)
target_link_libraries(utmpupdate LibMain)
target_link_libraries(zip LibArchive LibCompress LibCrypto)
target_link_libraries(cpp-lexer LibCpp)
target_link_libraries(cpp-parser LibCpp LibGUI)
target_link_libraries(cpp-preprocessor LibCpp LibGUI)
target_link_libraries(w LibMain)
target_link_libraries(wasm LibWasm LibLine)
target_link_libraries(wsctl LibGUI)