3

When attempting to compile a new contract, I am getting this error. I'm using eosio version 2.1 for this.

CMake Error at /home/michael/eosio.cdt/build/lib/cmake/eosio.cdt/EosioCDTMacros.cmake:18 (set_source_files_properties):
  set_source_files_properties called with incorrect number of arguments.
Call Stack (most recent call first):
  CMakeLists.txt:12 (target_ricardian_directory)

Has anyone seen this before?

Here is the content for the CMakeLists.txt file:

project(equity)
  
set(EOSIO_WASM_OLD_BEHAVIOR "Off")
find_package(eosio.cdt)

add_contract( equity equity equity.cpp )
target_include_directories( equity PUBLIC ${CMAKE_SOURCE_DIR}/../include )
target_ricardian_directory( equity ${CMAKE_SOURCE_DIR}/../ricardian )

add_contract( equity equity_local equity.cpp )
target_include_directories( equity_local PUBLIC ${CMAKE_SOURCE_DIR}/../include )
target_ricardian_directory( equity_local ${CMAKE_SOURCE_DIR}/../ricardian )
target_compile_definitions( equity_local PUBLIC LOCAL )
2
  • 3
    Elaborate your issue further. Contract compilation has nothing to do with eosio. It is affected by eosio.cdt. As error message says, you need to check whether you use CDT macros correctly. How do you add target? Did you call like add_contract(CONTRACT_NAME TARGET SOURCES)? Usually it has a similar form to add_contract(eosio.token eosio.token eosio.token.cpp).
    – conr2d
    Commented Jan 4, 2021 at 14:52
  • @conr2d I'm using the standard CMakelists that you get when you use eosio-init Commented Jan 4, 2021 at 15:37

3 Answers 3

3

It seems you use eosio.cdt v1.8.0-rc1.

macro (target_ricardian_directory TARGET DIR)
  target_compile_options( ${TARGET} PUBLIC -R${DIR} )
  file(GLOB contracts ${DIR}/*.contracts.md ${DIR}/*.clauses.md)
  get_target_property(contract_sources ${TARGET} SOURCES)
  if(contracts)
    set_source_files_properties(${contract_sources} PROPERTIES OBJECT_DEPENDS ${contracts})
  endif()
endmacro()

set_source_files_properties will be called arguments with ${contract_sources} and ${contracts}. We can know that ${contracts} is not empty, because your error message says set_source_files_properties is called.

I suspect the case of empty ${contract_sources}. ${contract_sources} is set by get_target_property(contract_sources ${TARGET} SOURCES), so you can check your add_contract() macro first. (contract target is usually set by add_contract macro) The name of contract should be repeated two times and have following source files like add_contract(hello hello hello.cpp).

2
  • I've added the src/CMakelists.txt file to the question. I believe the add_contract() macro is correct. Commented Jan 5, 2021 at 13:45
  • The problem is caused by the target_ricardian_directory line - commenting out these lines caused the problem to go away. I'm not sure why this is the case though, but my code now compiles so I can deal with this problem later. Commented Jan 5, 2021 at 14:13
2

When both xx.contracts.md and xx.clauses.md are present, ${contracts} is a ;-list, which must be quoted. This edited macro defn works for me without complaint in v1.8.1 (using CMake 3.10.2 on Ubuntu 18.04)

   macro (target_ricardian_directory TARGET DIR)
      target_compile_options( ${TARGET} PUBLIC -R${DIR} )
      file(GLOB contracts ${DIR}/*.contracts.md ${DIR}/*.clauses.md)
      get_target_property(contract_sources ${TARGET} SOURCES)
      if(contracts)
         set_source_files_properties(${contract_sources} PROPERTIES OBJECT_DEPENDS "${contracts}")
      endif()
   endmacro()
1
  • This worked for me, thanks!
    – James Mart
    Commented Oct 4, 2021 at 20:13
0

The solution above was adopted at https://github.com/EOSIO/eosio.cdt/pull/1220

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.