1
-
2
1
macro (group_sources_in source_dir curdir)
3
2
file (GLOB children RELATIVE ${source_dir} /${curdir}
4
3
${source_dir} /${curdir} /*)
@@ -29,165 +28,8 @@ macro (exclude_if_included target_)
29
28
endif ()
30
29
endmacro ()
31
30
32
- function (print_ep_logs _target)
33
- ExternalProject_Get_Property (${_target} STAMP_DIR)
34
- add_custom_command (TARGET ${_target} POST_BUILD
35
- COMMENT "${_target} BUILD OUTPUT"
36
- COMMAND ${CMAKE_COMMAND}
37
- -DIN_FILE=${STAMP_DIR} /${_target} -build -out.log
38
- -P ${CMAKE_CURRENT_SOURCE_DIR} /Builds/CMake/echo_file.cmake
39
- COMMAND ${CMAKE_COMMAND}
40
- -DIN_FILE=${STAMP_DIR} /${_target} -build -err.log
41
- -P ${CMAKE_CURRENT_SOURCE_DIR} /Builds/CMake/echo_file.cmake)
42
- endfunction ()
43
-
44
- #[=========================================================[
45
- This is a function override for one function in the
46
- standard ExternalProject module. We want to change
47
- the generated build script slightly to include printing
48
- the build logs in the case of failure. Those modifications
49
- have been made here. This function override could break
50
- in the future if the ExternalProject module changes internal
51
- function names or changes the way it generates the build
52
- scripts.
53
- See:
54
- https://gitlab.kitware.com/cmake/cmake/blob/df1ddeec128d68cc636f2dde6c2acd87af5658b6/Modules/ExternalProject.cmake#L1855-1952
55
- #]=========================================================]
56
-
57
- function (_ep_write_log_script name step cmd_var)
58
- ExternalProject_Get_Property(${name} stamp_dir)
59
- set (command "${${cmd_var} }" )
60
-
61
- set (make "" )
62
- set (code_cygpath_make "" )
63
- if (command MATCHES "^\\ $\\ (MAKE\\ )" )
64
- # GNU make recognizes the string "$(MAKE)" as recursive make, so
65
- # ensure that it appears directly in the makefile.
66
- string (REGEX REPLACE "^\\ $\\ (MAKE\\ )" "\$ {make}" command "${command} " )
67
- set (make "-Dmake=$(MAKE)" )
68
-
69
- if (WIN32 AND NOT CYGWIN )
70
- set (code_cygpath_make "
71
- if(\$ {make} MATCHES \" ^/\" )
72
- execute_process(
73
- COMMAND cygpath -w \$ {make}
74
- OUTPUT_VARIABLE cygpath_make
75
- ERROR_VARIABLE cygpath_make
76
- RESULT_VARIABLE cygpath_error
77
- OUTPUT_STRIP_TRAILING_WHITESPACE
78
- )
79
- if(NOT cygpath_error)
80
- set(make \$ {cygpath_make})
81
- endif()
82
- endif()
83
- " )
84
- endif ()
85
- endif ()
86
-
87
- set (config "" )
88
- if ("${CMAKE_CFG_INTDIR} " MATCHES "^\\ $" )
89
- string (REPLACE "${CMAKE_CFG_INTDIR} " "\$ {config}" command "${command} " )
90
- set (config "-Dconfig=${CMAKE_CFG_INTDIR} " )
91
- endif ()
92
-
93
- # Wrap multiple 'COMMAND' lines up into a second-level wrapper
94
- # script so all output can be sent to one log file.
95
- if (command MATCHES "(^|;)COMMAND;" )
96
- set (code_execute_process "
97
- ${code_cygpath_make}
98
- execute_process(COMMAND \$ {command} RESULT_VARIABLE result)
99
- if(result)
100
- set(msg \" Command failed (\$ {result}):\\ n\" )
101
- foreach(arg IN LISTS command)
102
- set(msg \"\$ {msg} '\$ {arg}'\" )
103
- endforeach()
104
- message(FATAL_ERROR \"\$ {msg}\" )
105
- endif()
106
- " )
107
- set (code "" )
108
- set (cmd "" )
109
- set (sep "" )
110
- foreach (arg IN LISTS command )
111
- if ("x${arg} " STREQUAL "xCOMMAND" )
112
- if (NOT "x${cmd} " STREQUAL "x" )
113
- string (APPEND code "set(command \" ${cmd} \" )${code_execute_process} " )
114
- endif ()
115
- set (cmd "" )
116
- set (sep "" )
117
- else ()
118
- string (APPEND cmd "${sep}${arg} " )
119
- set (sep ";" )
120
- endif ()
121
- endforeach ()
122
- string (APPEND code "set(command \" ${cmd} \" )${code_execute_process} " )
123
- file (GENERATE OUTPUT "${stamp_dir} /${name} -${step} -$<CONFIG>-impl.cmake" CONTENT "${code} " )
124
- set (command ${CMAKE_COMMAND} "-Dmake=\$ {make}" "-Dconfig=\$ {config}" -P ${stamp_dir} /${name} -${step} -$<CONFIG>-impl.cmake)
125
- endif ()
126
-
127
- # Wrap the command in a script to log output to files.
128
- set (script ${stamp_dir} /${name} -${step} -$<CONFIG>.cmake)
129
- set (logbase ${stamp_dir} /${name} -${step} )
130
- set (code "
131
- ${code_cygpath_make}
132
- function (_echo_file _fil)
133
- file (READ \$ {_fil} _cont)
134
- execute_process (COMMAND \$ {CMAKE_COMMAND} -E echo \"\$ {_cont}\" )
135
- endfunction ()
136
- set(command \" ${command} \" )
137
- execute_process(
138
- COMMAND \$ {command}
139
- RESULT_VARIABLE result
140
- OUTPUT_FILE \" ${logbase} -out.log\"
141
- ERROR_FILE \" ${logbase} -err.log\"
142
- )
143
- if(result)
144
- set(msg \" Command failed: \$ {result}\\ n\" )
145
- foreach(arg IN LISTS command)
146
- set(msg \"\$ {msg} '\$ {arg}'\" )
147
- endforeach()
148
- execute_process (COMMAND \$ {CMAKE_COMMAND} -E echo \" Build output for ${logbase} : \" )
149
- _echo_file (\" ${logbase} -out.log\" )
150
- _echo_file (\" ${logbase} -err.log\" )
151
- set(msg \"\$ {msg}\\ nSee above\\ n\" )
152
- message(FATAL_ERROR \"\$ {msg}\" )
153
- else()
154
- set(msg \" ${name} ${step} command succeeded. See also ${logbase} -*.log\" )
155
- message(STATUS \"\$ {msg}\" )
156
- endif()
157
- " )
158
- file (GENERATE OUTPUT "${script} " CONTENT "${code} " )
159
- set (command ${CMAKE_COMMAND} ${make} ${config} -P ${script} )
160
- set (${cmd_var} "${command} " PARENT_SCOPE)
161
- endfunction ()
162
-
163
31
find_package (Git)
164
32
165
- # function that calls git log to get current hash
166
- function (git_hash hash_val)
167
- # note: optional second extra string argument not in signature
168
- if (NOT GIT_FOUND)
169
- return ()
170
- endif ()
171
- set (_hash "" )
172
- set (_format "%H" )
173
- if (ARGC GREATER_EQUAL 2)
174
- string (TOLOWER ${ARGV1} _short)
175
- if (_short STREQUAL "short" )
176
- set (_format "%h" )
177
- endif ()
178
- endif ()
179
- execute_process (COMMAND ${GIT_EXECUTABLE} "log" "--pretty=${_format} " "-n1"
180
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
181
- RESULT_VARIABLE _git_exit_code
182
- OUTPUT_VARIABLE _temp_hash
183
- OUTPUT_STRIP_TRAILING_WHITESPACE
184
- ERROR_QUIET)
185
- if (_git_exit_code EQUAL 0)
186
- set (_hash ${_temp_hash} )
187
- endif ()
188
- set (${hash_val} "${_hash} " PARENT_SCOPE)
189
- endfunction ()
190
-
191
33
function (git_branch branch_val)
192
34
if (NOT GIT_FOUND)
193
35
return ()
@@ -204,4 +46,3 @@ function (git_branch branch_val)
204
46
endif ()
205
47
set (${branch_val} "${_branch} " PARENT_SCOPE)
206
48
endfunction ()
207
-
0 commit comments