Run the compiler a second time without -H in case of errors

This commit is contained in:
Laurent Rineau 2018-05-23 14:50:15 +02:00
parent 11d310bba0
commit 4ba33e17d3
2 changed files with 21 additions and 6 deletions

View File

@ -1278,6 +1278,15 @@ LEDA_FOUND is false.")
UNIX_COMMAND UNIX_COMMAND
"${CMAKE_CXX_COMPILER} ${compile_options_str} "${CMAKE_CXX_COMPILER} ${compile_options_str}
${include_options_str} -x c++ ${flag} -H \ ${include_options_str} -x c++ ${flag} -H \
${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header}"
# The header Algebraic_kernel_rs_gmpz_d_1.h is skipped on purpose: it
# depends on RS.
)
# CMD2 is CMD without the -H option
separate_arguments(CMD2
UNIX_COMMAND
"${CMAKE_CXX_COMPILER} ${compile_options_str}
${include_options_str} -x c++ ${flag} \
${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header}" ${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header}"
# The header Algebraic_kernel_rs_gmpz_d_1.h is skipped on purpose: it # The header Algebraic_kernel_rs_gmpz_d_1.h is skipped on purpose: it
# depends on RS. # depends on RS.
@ -1288,6 +1297,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header}"
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
-DCERR:STRING=${chk_header_name} -DCERR:STRING=${chk_header_name}
"-DCMD:STRING=${CMD}" "-DCMD:STRING=${CMD}"
"-DCMD2:STRING=${CMD2}"
-P "${CGAL_MODULES_DIR}/run_cmd_redirection_cerr.cmake" -P "${CGAL_MODULES_DIR}/run_cmd_redirection_cerr.cmake"
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../${package}/include/${header}
DEPENDS ${CGAL_MODULES_DIR}/run_cmd_redirection_cerr.cmake DEPENDS ${CGAL_MODULES_DIR}/run_cmd_redirection_cerr.cmake

View File

@ -17,15 +17,19 @@ endif()
execute_process( execute_process(
COMMAND ${CMD} COMMAND ${CMD}
ERROR_VARIABLE err ERROR_FILE "${CERR}"
OUTPUT_VARIABLE output OUTPUT_VARIABLE output
RESULT_VARIABLE error_result) RESULT_VARIABLE error_result)
file(WRITE ${CERR} "${err}")
if(error_result) if(error_result)
string(REPLACE ";" " " CMD_STR "${CMD}") if(CMD2)
message(SEND_ERROR file(REMOVE ${CERR})
execute_process(COMMAND ${CMD2})
message(SEND_ERROR)
else()
file(READ ${CERR} err)
file(REMOVE ${CERR})
string(REPLACE ";" " " CMD_STR "${CMD}")
message(SEND_ERROR
"The command "The command
${CMD_STR} > ${CERR} ${CMD_STR} > ${CERR}
ended with the error code ${error_result}, ended with the error code ${error_result},
@ -34,4 +38,5 @@ ${output}
and the following error output: and the following error output:
${err}" ${err}"
) )
endif()
endif() endif()