if (NOT EOSIO_WASM_OLD_BEHAVIOR STREQUAL "On")
   macro(add_contract CONTRACT_NAME TARGET)
      add_executable( ${TARGET} ${ARGN} )
      target_compile_options( ${TARGET} PUBLIC -abigen )
      get_target_property(BINOUTPUT ${TARGET} BINARY_DIR)
      target_compile_options( ${TARGET} PUBLIC -abigen_output=${BINOUTPUT}/${TARGET}.abi )
      target_compile_options( ${TARGET} PUBLIC -contract ${CONTRACT_NAME} )
   endmacro()
   macro (target_ricardian_directory TARGET DIR)
      target_compile_options( ${TARGET} PUBLIC -R${DIR} )
      file(GLOB contracts ${DIR}/*.contracts.md ${DIR}/*.clauses.md)
      add_dependencies( ${TARGET} ${contracts} )
   endmacro()

else()
   macro(add_contract CONTRACT_NAME TARGET)
      add_executable( ${TARGET}.wasm ${ARGN} )
      target_compile_options( ${TARGET}.wasm PUBLIC -abigen )
      get_target_property(BINOUTPUT ${TARGET}.wasm BINARY_DIR)
      target_compile_options( ${TARGET}.wasm PUBLIC -abigen_output=${BINOUTPUT}/${TARGET}.abi )
      target_compile_options( ${TARGET}.wasm PUBLIC -contract ${CONTRACT_NAME} )
   endmacro()
   macro (target_ricardian_directory TARGET DIR)
      target_compile_options( ${TARGET}.wasm PUBLIC -R${DIR} )
      file(GLOB contracts ${DIR}/*.contracts.md ${DIR}/*.clauses.md)
      add_dependencies( ${TARGET}.wasm ${contracts} )
   endmacro()
endif()

macro (add_native_library TARGET)
   add_library( ${TARGET} ${ARGN} )
   target_compile_options( ${TARGET} PUBLIC -fnative )
endmacro()

macro (add_native_executable TARGET)
   cmake_policy(SET CMP0002 OLD)
   add_executable( ${TARGET} ${ARGN} )
   target_compile_options( ${TARGET} PUBLIC -fnative )
   set_target_properties( ${TARGET} PROPERTIES LINK_FLAGS "-fnative" SUFFIX "" )
   get_target_property(BINOUTPUT ${TARGET} BINARY_DIR)
   if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" AND APPLE)
      target_compile_options( ${TARGET} PUBLIC -g )
      find_program ( name NAMES "dsymutil" )
      if ( name )
         add_custom_command( TARGET ${TARGET} POST_BUILD COMMAND dsymutil ${BINOUTPUT}/${TARGET} )
      endif()
   endif()
endmacro()

