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:


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 )
  • 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 Jan 4 at 14:52
  • @conr2d I'm using the standard CMakelists that you get when you use eosio-init – Michael Nash Jan 4 at 15:37

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)
    set_source_files_properties(${contract_sources} PROPERTIES OBJECT_DEPENDS ${contracts})

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).

  • I've added the src/CMakelists.txt file to the question. I believe the add_contract() macro is correct. – Michael Nash Jan 5 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. – Michael Nash Jan 5 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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