|  | 
| 87 | 87 | # | 
| 88 | 88 | #       ./build/randbytes 10 | 
| 89 | 89 | # | 
|  | 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. | 
| 90 | 94 | # | 
| 91 | 95 | # 32-bit builds | 
| 92 | 96 | # ============= | 
| @@ -268,74 +272,76 @@ set(run_terse "" "-t" | 
| 268 | 272 | set(run_threads 1 4 | 
| 269 | 273 |     CACHE STRING "List of thread counts") | 
| 270 | 274 | 
 | 
| 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() | 
| 277 | 300 | 
 | 
| 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}) | 
| 284 | 309 | 
 | 
| 285 |  | -        if(test IN_LIST test_name) | 
|  | 310 | +        # certdir | 
|  | 311 | +        if(test IN_LIST run_certdir_tests) | 
| 286 | 312 |             set(new_cmds) | 
| 287 | 313 |             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}") | 
| 291 | 315 |             endforeach() | 
| 292 | 316 |             set(cmds ${new_cmds}) | 
| 293 | 317 |         endif() | 
| 294 |  | -    endforeach() | 
| 295 | 318 | 
 | 
| 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 | 
| 307 | 320 |         set(new_cmds) | 
| 308 | 321 |         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() | 
| 310 | 325 |         endforeach() | 
| 311 | 326 |         set(cmds ${new_cmds}) | 
| 312 |  | -    endif() | 
| 313 | 327 | 
 | 
| 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}") | 
| 319 | 345 |         endforeach() | 
| 320 | 346 |     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