Skip to content

Commit c51e909

Browse files
committed
- adding a note on run target. I also think the run target should be generated when build is prepared with OPENSSL_ROOT_DIR option (use library built in openssl sources)
1 parent 1fc3f67 commit c51e909

File tree

1 file changed

+62
-56
lines changed

1 file changed

+62
-56
lines changed

source/CMakeLists.txt

Lines changed: 62 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@
8787
#
8888
# ./build/randbytes 10
8989
#
90+
# If build is prepared with OPENSSL_ROOT_DIR, using -DOPENSSL_ROOT_DIR=...
91+
# argument, then cmake generates a run target. The run target serves as a
92+
# unit test which runs all commands. Use 'cmake --build build -t run' command
93+
# to run it.
9094
#
9195
# 32-bit builds
9296
# =============
@@ -268,74 +272,76 @@ set(run_terse "" "-t"
268272
set(run_threads 1 4
269273
CACHE STRING "List of thread counts")
270274

271-
add_custom_target(run
272-
COMMENT "Run perf tests"
273-
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
274-
275-
foreach(test IN LISTS run_tests)
276-
set(cmds "${test}")
275+
if(OPENSSL_ROOT_DIR)
276+
add_custom_target(run
277+
COMMENT "Run perf tests"
278+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
279+
280+
foreach(test IN LISTS run_tests)
281+
set(cmds "${test}")
282+
283+
# test-specific options
284+
foreach(opt_name IN LISTS run_opts)
285+
set(opt "${${opt_name}}")
286+
list(GET opt 0 test_name)
287+
list(GET opt 1 test_opt)
288+
list(REMOVE_AT opt 0 1)
289+
290+
if(test IN_LIST test_name)
291+
set(new_cmds)
292+
foreach(cmd IN LISTS cmds)
293+
foreach(val IN LISTS opt)
294+
list(APPEND new_cmds "${cmd} ${test_opt} ${val}")
295+
endforeach()
296+
endforeach()
297+
set(cmds ${new_cmds})
298+
endif()
299+
endforeach()
277300

278-
# test-specific options
279-
foreach(opt_name IN LISTS run_opts)
280-
set(opt "${${opt_name}}")
281-
list(GET opt 0 test_name)
282-
list(GET opt 1 test_opt)
283-
list(REMOVE_AT opt 0 1)
301+
# terse
302+
set(new_cmds)
303+
foreach(cmd IN LISTS cmds)
304+
foreach(val IN LISTS run_terse)
305+
list(APPEND new_cmds "${cmd} ${val}")
306+
endforeach()
307+
endforeach()
308+
set(cmds ${new_cmds})
284309

285-
if(test IN_LIST test_name)
310+
# certdir
311+
if(test IN_LIST run_certdir_tests)
286312
set(new_cmds)
287313
foreach(cmd IN LISTS cmds)
288-
foreach(val IN LISTS opt)
289-
list(APPEND new_cmds "${cmd} ${test_opt} ${val}")
290-
endforeach()
314+
list(APPEND new_cmds "${cmd} ${run_certdir}")
291315
endforeach()
292316
set(cmds ${new_cmds})
293317
endif()
294-
endforeach()
295318

296-
# terse
297-
set(new_cmds)
298-
foreach(cmd IN LISTS cmds)
299-
foreach(val IN LISTS run_terse)
300-
list(APPEND new_cmds "${cmd} ${val}")
301-
endforeach()
302-
endforeach()
303-
set(cmds ${new_cmds})
304-
305-
# certdir
306-
if(test IN_LIST run_certdir_tests)
319+
# threads
307320
set(new_cmds)
308321
foreach(cmd IN LISTS cmds)
309-
list(APPEND new_cmds "${cmd} ${run_certdir}")
322+
foreach(val IN LISTS run_threads)
323+
list(APPEND new_cmds "${cmd} ${val}")
324+
endforeach()
310325
endforeach()
311326
set(cmds ${new_cmds})
312-
endif()
313327

314-
# threads
315-
set(new_cmds)
316-
foreach(cmd IN LISTS cmds)
317-
foreach(val IN LISTS run_threads)
318-
list(APPEND new_cmds "${cmd} ${val}")
328+
foreach(cmd IN LISTS cmds)
329+
string(REGEX REPLACE " *" ";" cmd "${cmd}")
330+
string(REGEX REPLACE "[^0-9A-Za-z]" "-" cmd_target_name "${cmd}")
331+
# A hack for lesser OSes that cannot normally distinguish lower-
332+
# and uppercase letters.
333+
if (WIN32 OR APPLE)
334+
string(REGEX REPLACE "[A-Z]" "\\0_" cmd_target_name
335+
"${cmd_target_name}")
336+
endif()
337+
string(REPLACE ";" " " cmd_desc "${cmd}")
338+
add_custom_target("run-${cmd_target_name}"
339+
COMMAND ${cmd}
340+
DEPENDS "${test}"
341+
COMMENT "Run ${cmd_desc}"
342+
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
343+
USES_TERMINAL)
344+
add_dependencies(run "run-${cmd_target_name}")
319345
endforeach()
320346
endforeach()
321-
set(cmds ${new_cmds})
322-
323-
foreach(cmd IN LISTS cmds)
324-
string(REGEX REPLACE " *" ";" cmd "${cmd}")
325-
string(REGEX REPLACE "[^0-9A-Za-z]" "-" cmd_target_name "${cmd}")
326-
# A hack for lesser OSes that cannot normally distinguish lower-
327-
# and uppercase letters.
328-
if (WIN32 OR APPLE)
329-
string(REGEX REPLACE "[A-Z]" "\\0_" cmd_target_name
330-
"${cmd_target_name}")
331-
endif()
332-
string(REPLACE ";" " " cmd_desc "${cmd}")
333-
add_custom_target("run-${cmd_target_name}"
334-
COMMAND ${cmd}
335-
DEPENDS "${test}"
336-
COMMENT "Run ${cmd_desc}"
337-
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
338-
USES_TERMINAL)
339-
add_dependencies(run "run-${cmd_target_name}")
340-
endforeach()
341-
endforeach()
347+
endif()

0 commit comments

Comments
 (0)