File: UtilsHelper.cmake

package info (click to toggle)
codelite 17.0.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 136,244 kB
  • sloc: cpp: 491,547; ansic: 280,393; php: 10,259; sh: 8,930; lisp: 7,664; vhdl: 6,518; python: 6,020; lex: 4,920; yacc: 3,123; perl: 2,385; javascript: 1,715; cs: 1,193; xml: 1,110; makefile: 804; cobol: 741; sql: 709; ruby: 620; f90: 566; ada: 534; asm: 464; fortran: 350; objc: 289; tcl: 258; java: 157; erlang: 61; pascal: 51; ml: 49; awk: 44; haskell: 36
file content (182 lines) | stat: -rw-r--r-- 5,654 bytes parent folder | download | duplicates (3)
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
cmake_minimum_required(VERSION 3.0)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")

include(OSXInstall)

#------------------------------------
# install script
#------------------------------------
macro(codelite_install_script _script_)
    set (EXE_PERM OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ)
    install(FILES ${_script_} DESTINATION ${CL_INSTALL_BIN} PERMISSIONS ${EXE_PERM})
endmacro()

#------------------------------------
# install an executable
#------------------------------------
macro(codelite_install_executable TARGET)
    if(APPLE)
        install(TARGETS ${TARGET} DESTINATION ${CMAKE_BINARY_DIR}/codelite.app/Contents/MacOS/)
        cl_install_name_tool_std(${CMAKE_BINARY_DIR}/codelite.app/Contents/MacOS/${TARGET})
    else()
        set(EXE_PERM
            OWNER_EXECUTE
            OWNER_WRITE
            OWNER_READ
            GROUP_EXECUTE
            GROUP_READ
            WORLD_EXECUTE
            WORLD_READ)

        install(
            TARGETS ${TARGET}
            DESTINATION ${CL_INSTALL_BIN}
            PERMISSIONS ${EXE_PERM})
    endif()
endmacro()

function(get_distro_name DISTRO_NAME)
    execute_process(COMMAND /bin/bash "-c" "cat /etc/os-release |grep ^ID=|cut -d = -f 2"
                    OUTPUT_VARIABLE _DISTRO_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
    execute_process(COMMAND /bin/bash "-c" "cat /etc/os-release |grep VERSION_ID=|cut -d = -f 2"
                    OUTPUT_VARIABLE _VERSION_ID OUTPUT_STRIP_TRAILING_WHITESPACE)

    # clean the output
    string (REPLACE "\"" "" _DISTRO_ID "${_DISTRO_ID}")
    string (REPLACE "\"" "" _VERSION_ID "${_VERSION_ID}")
    string (REPLACE "." "" _DISTRO_ID "${_DISTRO_ID}")
    string (REPLACE "." "" _VERSION_ID "${_VERSION_ID}")
    set(${DISTRO_NAME} "")
    string(FIND ${_DISTRO_ID} "fedora" POS)
    if (POS GREATER -1)
        set (${DISTRO_NAME} "fedora_${_VERSION_ID}" PARENT_SCOPE)
    endif()

    string(FIND ${_DISTRO_ID} "ubuntu" POS)
    if (POS GREATER -1)
        set (${DISTRO_NAME} "${_DISTRO_ID}_${_VERSION_ID}" PARENT_SCOPE)
    endif()

    string(FIND ${_DISTRO_ID} "debian" POS)
    if (POS GREATER -1)
        set (${DISTRO_NAME} "${_DISTRO_ID}_${_VERSION_ID}" PARENT_SCOPE)
    endif()
endfunction()

if(MINGW)
    macro(msys_install_clang64_tool tool_name install_dir)
        # locate the dependencies
        execute_process(COMMAND sh -c "ldd /clang64/bin/${tool_name} | grep clang64|cut -d'=' -f2|cut -d' ' -f2|xargs cygpath -w"
                        OUTPUT_VARIABLE TOOL_DEPS OUTPUT_STRIP_TRAILING_WHITESPACE)
        string(REPLACE "\n" ";" TOOL_DEPS ${TOOL_DEPS})
        list(APPEND TOOL_DEPS "${MSYS2_BASE}/clang64/bin/${tool_name}")
        foreach(TOOL ${TOOL_DEPS})
            string(REPLACE "\\" "/" TOOL "${TOOL}")
            install(FILES "${TOOL}" DESTINATION ${install_dir})
        endforeach()
    endmacro()
endif()

set(PCH_HEADERS_LIST
    <wx/wxprec.h>
    <wx/app.h>
    <wx/artprov.h>
    <wx/bitmap.h>
    <wx/button.h>
    <wx/checklst.h>
    <wx/choice.h>
    <wx/colour.h>
    <wx/dialog.h>
    <wx/ffile.h>
    <wx/filedlg.h>
    <wx/font.h>
    <wx/frame.h>
    <wx/gdicmn.h>
    <wx/icon.h>
    <wx/image.h>
    <wx/imaggif.h>
    <wx/imaglist.h>
    <wx/intl.h>
    <wx/log.h>
    <wx/menu.h>
    <wx/msgdlg.h>
    <wx/notebook.h>
    <wx/panel.h>
    <wx/scrolwin.h>
    <wx/settings.h>
    <wx/sizer.h>
    <wx/splitter.h>
    <wx/statbox.h>
    <wx/stattext.h>
    <wx/statusbr.h>
    <wx/string.h>
    <wx/textctrl.h>
    <wx/tooltip.h>
    <wx/treectrl.h>
    <wx/wupdlock.h>
    <wx/xrc/xmlres.h>
    <set>
    <unordered_set>
    <unordered_map>
    <vector>
    <list>
    <map>
    <memory>
    )
macro(codelite_add_exported_pch _TARGET_)
    target_precompile_headers(
        ${_TARGET_}
    PUBLIC
        ${PCH_HEADERS_LIST}
    )
endmacro()

macro(codelite_add_pch _TARGET_)
    target_precompile_headers(
        ${_TARGET_}
    PRIVATE
        ${PCH_HEADERS_LIST}
    )
endmacro()

#------------------------------------
# install a library (shared object, but not a plugin)
#------------------------------------
macro(codelite_install_library_target TARGET)
    if(APPLE)
        install(TARGETS ${TARGET} DESTINATION ${CMAKE_BINARY_DIR}/codelite.app/Contents/MacOS/)
        cl_install_name_tool_std("${CL_INSTALL_BIN}/lib${TARGET}.dylib")
    elseif(MINGW)
        # under windows (MinGW) we install libraries under the "bin" folder
        install(TARGETS ${TARGET} DESTINATION "${CL_INSTALL_BIN}")
    else()
        # Under linux, we install libraries in the plugins directory
        install(TARGETS ${TARGET} DESTINATION ${PLUGINS_DIR})
    endif()
endmacro()

# Determine if we are running on Windows using MSYS2 shell or using MinGW tools (but not using MSYS)
if (UNIX)
    execute_process(COMMAND /bin/sh "-c" "uname -s|grep MSYS|cut -d_ -f1"
                    OUTPUT_VARIABLE _OS_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
    string(FIND "${_OS_NAME}" "MSYS" POS)
    if (POS GREATER -1)
        set(MSYS_SHELL 1)
        set(MSW 1)
    endif()
elseif(WIN32)
    execute_process(COMMAND sh "-c" "uname -o|grep -E 'Msys|Cygwin'|cut -d_ -f1"
                    OUTPUT_VARIABLE _OS_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)

    if ("${_OS_NAME}" MATCHES "Msys|Cygwin")
        set(MSYS_SHELL 1)
        set(MSW 1)
    else()
        set(WIN_CMD_SHELL 1)
        set(MSW 1)
        execute_process(COMMAND sh "-c" "uname -s"
                        OUTPUT_VARIABLE _OS_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
        message(FATAL_ERROR "${_OS_NAME}")
    endif()
endif() # UNIX -> WIN32