From 6b4a0df6fa52012c3a3d29d223441c31fc6c7761 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 12 Jul 2022 14:54:22 +0200 Subject: [PATCH] Fix CMakeLists for when makecontext is not compilable. Patch from @adegomme. --- CMakeLists.txt | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d39d92ad58..6a4c36da08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -454,27 +454,27 @@ else() OUTPUT_VARIABLE compile_makecontext_output) #If can have both context - if(compile_makecontext) - set(HAVE_UCONTEXT_CONTEXTS 1) - message(STATUS "Support for ucontext factory ok.") - else() + if(NOT compile_makecontext) message(STATUS "Error: exists, but makecontext is not compilable. Compilation output:\n ${compile_makecontext_output}") message(STATUS "No ucontext factory: makecontext() is not compilable.") - endif() - - # Stack setup (size and address) - try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR - ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_stacksetup.c - RUN_OUTPUT_VARIABLE stack_setup) - - LIST(LENGTH stack_setup stack_setup_len) - if("${stack_setup_len}" STREQUAL "2") - LIST(GET stack_setup 0 makecontext_addr) - LIST(GET stack_setup 1 makecontext_size) - set(sg_makecontext_stack_addr "#define sg_makecontext_stack_addr(skaddr) (${makecontext_addr})") - set(sg_makecontext_stack_size "#define sg_makecontext_stack_size(sksize) (${makecontext_size})") else() - message(FATAL_ERROR "Could not figure out the stack setup. Compil: ${RUN_makecontext_VAR}. Exec: ${COMPILE_makecontext_VAR}. Output: ${stack_setup}") + message(STATUS "Support for ucontext factory ok.") + set(HAVE_UCONTEXT_CONTEXTS 1) + + # Stack setup (size and address) + try_run(RUN_makecontext_VAR COMPILE_makecontext_VAR + ${CMAKE_BINARY_DIR} ${CMAKE_HOME_DIRECTORY}/tools/cmake/test_prog/prog_stacksetup.c + RUN_OUTPUT_VARIABLE stack_setup) + + LIST(LENGTH stack_setup stack_setup_len) + if("${stack_setup_len}" STREQUAL "2") + LIST(GET stack_setup 0 makecontext_addr) + LIST(GET stack_setup 1 makecontext_size) + set(sg_makecontext_stack_addr "#define sg_makecontext_stack_addr(skaddr) (${makecontext_addr})") + set(sg_makecontext_stack_size "#define sg_makecontext_stack_size(sksize) (${makecontext_size})") + else() + message(FATAL_ERROR "Could not figure out the stack setup. Compil: ${RUN_makecontext_VAR}. Exec: ${COMPILE_makecontext_VAR}. Output: ${stack_setup}") + endif() endif() endif() -- 2.20.1