Files
ThreadX4TGFS/port/threadx_smp/cmake/BuildAsmOffsets.cmake

42 lines
1.2 KiB
CMake

if(NOT DEFINED COMPILER)
message(FATAL_ERROR "COMPILER is required")
endif()
if(NOT DEFINED SOURCE)
message(FATAL_ERROR "SOURCE is required")
endif()
if(NOT DEFINED ASM_OUTPUT)
message(FATAL_ERROR "ASM_OUTPUT is required")
endif()
if(NOT DEFINED HEADER_OUTPUT)
message(FATAL_ERROR "HEADER_OUTPUT is required")
endif()
if(NOT DEFINED GENERATE_SCRIPT)
message(FATAL_ERROR "GENERATE_SCRIPT is required")
endif()
execute_process(
COMMAND "${COMPILER}" ${COMPILER_ARG1} ${CFLAG_ARGS} ${INCLUDE_ARGS} ${DEFINE_ARGS} -S -o "${ASM_OUTPUT}" "${SOURCE}"
RESULT_VARIABLE compile_result
OUTPUT_VARIABLE compile_stdout
ERROR_VARIABLE compile_stderr
)
if(NOT compile_result EQUAL 0)
message(FATAL_ERROR "failed to compile asm offsets source\n${compile_stdout}${compile_stderr}")
endif()
execute_process(
COMMAND "${CMAKE_COMMAND}" -DINPUT="${ASM_OUTPUT}" -DOUTPUT="${HEADER_OUTPUT}" -P "${GENERATE_SCRIPT}"
RESULT_VARIABLE generate_result
OUTPUT_VARIABLE generate_stdout
ERROR_VARIABLE generate_stderr
)
if(NOT generate_result EQUAL 0)
message(FATAL_ERROR "failed to generate asm offsets header\n${generate_stdout}${generate_stderr}")
endif()