# =========== libcopp/src - fcontext : ${LIBCOPP_FCONTEXT_OS_PLATFORM} - sysv - ${LIBCOPP_FCONTEXT_BIN_FORMAT} - ${LIBCOPP_FCONTEXT_AS_T
file(MAKE_DIRECTORY "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}")

if(MSVC)
  list(APPEND COPP_SRC_LIST "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_MAKE}.asm"
       "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_JUMP}.asm"
       "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_ONTOP}.asm")
  set(MASMFound FALSE)
  enable_language(ASM_MASM)
  if(CMAKE_ASM_MASM_COMPILER_WORKS)
    set(MASMFound TRUE)
  else()
    echowithcolor(COLOR RED "-- enable masm failed")
    message(FATAL_ERROR "enable ASM_MASM failed")
  endif(CMAKE_ASM_MASM_COMPILER_WORKS)
else()
  list(APPEND COPP_SRC_LIST "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_MAKE}.asm"
       "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_JUMP}.asm"
       "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_ONTOP}.asm")
  # set (LIBCOPP_FCONTEXT_AS_TOOL_OPTION "/c" "/Fo") if("${LIBCOPP_FCONTEXT_AS_TOOL}" STREQUAL "64") set (LIBCOPP_FCONTEXT_AS_BIN "ml64")
  # else() set (LIBCOPP_FCONTEXT_AS_BIN "ml") endif()
  #
  # if (LIBCOPP_FCONTEXT_USE_TSX) list (APPEND LIBCOPP_FCONTEXT_AS_TOOL_OPTION "/DLIBCOPP_FCONTEXT_AS_TOOL_OPTION=1") endif()
  #
  # if (CMAKE_ASM_MASM_COMPILER) set(LIBCOPP_FCONTEXT_AS_TOOL_BIN ${CMAKE_ASM_MASM_COMPILER}) else ()
  # find_program(LIBCOPP_FCONTEXT_AS_TOOL_BIN ${LIBCOPP_FCONTEXT_AS_BIN}) if(NOT LIBCOPP_FCONTEXT_AS_TOOL_BIN) EchoWithColor(COLOR RED "--
  # ${LIBCOPP_FCONTEXT_AS_BIN} not found in path, please add as's directory into path") message(FATAL_ERROR "${LIBCOPP_FCONTEXT_AS_BIN} not
  # found") endif() endif ()
  #
  # add_custom_command( OUTPUT "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_JUMP}"
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_MAKE}"
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_ONTOP}" COMMAND ${LIBCOPP_FCONTEXT_AS_TOOL_BIN}
  # ${LIBCOPP_FCONTEXT_AS_TOOL_OPTION} "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_JUMP}"
  # "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_JUMP}.asm" COMMAND ${LIBCOPP_FCONTEXT_AS_TOOL_BIN}
  # ${LIBCOPP_FCONTEXT_AS_TOOL_OPTION} "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_MAKE}"
  # "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_MAKE}.asm" COMMAND ${LIBCOPP_FCONTEXT_AS_TOOL_BIN}
  # ${LIBCOPP_FCONTEXT_AS_TOOL_OPTION} "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_ONTOP}"
  # "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_ONTOP}.asm" DEPENDS
  # "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_JUMP}.asm"
  # "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_MAKE}.asm"
  # "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_ONTOP}.asm" WORKING_DIRECTORY
  # ${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR} COMMENT "Genarate
  # ${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_JUMP},${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_MAKE},${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_ONTOP}" )
  #
  # # execute_process ( #     COMMAND ${LIBCOPP_FCONTEXT_AS_TOOL_BIN} ${LIBCOPP_FCONTEXT_AS_TOOL_OPTION}
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_MAKE}" #
  # "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_MAKE}.asm" #     WORKING_DIRECTORY
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}" # )
  #
  # # execute_process ( #     COMMAND ${LIBCOPP_FCONTEXT_AS_TOOL_BIN} ${LIBCOPP_FCONTEXT_AS_TOOL_OPTION}
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_JUMP}" #
  # "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_JUMP}.asm" #     WORKING_DIRECTORY
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}" # )
  #
  # # execute_process ( #     COMMAND ${LIBCOPP_FCONTEXT_AS_TOOL_BIN} ${LIBCOPP_FCONTEXT_AS_TOOL_OPTION}
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_ONTOP}" #
  # "${PROJECT_LIBCOPP_FCONTEXT_ASM_DIR}/${PROJECT_LIBCOPP_FCONTEXT_SRC_NAME_ONTOP}.asm" #     WORKING_DIRECTORY
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}" # )
  #
  # list(APPEND COPP_OBJ_LIST "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_JUMP}"
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_MAKE}"
  # "${PROJECT_LIBCOPP_FCONTEXT_BIN_DIR}/${PROJECT_LIBCOPP_FCONTEXT_BIN_NAME_ONTOP}" )
endif()
