Skip to content

Conversation

@axic
Copy link
Contributor

@axic axic commented Apr 18, 2018

@axic axic requested a review from chfast April 18, 2018 20:18
@axic
Copy link
Contributor Author

axic commented Apr 18, 2018

@chfast I am not sure what I am doing, but this fixes it locally for me when I install jsoncpp-1.8.4 in the system with homebrew.

Without these changes, I get the same error as shown in https://github.com/ethereum/homebrew-ethereum/issues/164

target_link_libraries(devcore PRIVATE jsoncpp ${Boost_FILESYSTEM_LIBRARIES} ${Boost_REGEX_LIBRARIES} ${Boost_SYSTEM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(devcore PRIVATE ${JSONCPP_LIBRARY} ${Boost_FILESYSTEM_LIBRARIES} ${Boost_REGEX_LIBRARIES} ${Boost_SYSTEM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_include_directories(devcore PUBLIC "${CMAKE_SOURCE_DIR}")
target_include_directories(devcore PUBLIC "${JSONCPP_INCLUDE_DIR}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you try keeping this line only?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not how this works, but basically libdevcore/JSON.h and json/json.h are included in many different libraries (libevmasm, libsolidity, libsolc, test), so I'd think the include directory should be made valid for all of them, e.g. should be put into the main CMake file and not into libdevcore.

The same applies to jsoncpp library then.

How to accomplish this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add inlcude_directories(${JSONCPP_INCLUDE_DIR}) just after include(ProjectJsoncpp).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will that cover both the header and the lib?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Only iclude path.
You still have to use target_link_libraries(). But should be enough to specify that in devcore, because for static libs this dependency in transitive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cannot find a include(ProjectJsoncpp) line? There is only a include(jsoncpp) line in the main cmake file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I meant.


add_library(devcore ${sources} ${headers})
target_link_libraries(devcore PRIVATE jsoncpp ${Boost_FILESYSTEM_LIBRARIES} ${Boost_REGEX_LIBRARIES} ${Boost_SYSTEM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(devcore PRIVATE ${JSONCPP_LIBRARY} ${Boost_FILESYSTEM_LIBRARIES} ${Boost_REGEX_LIBRARIES} ${Boost_SYSTEM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chfast are you sure jsoncpp here will be correct and we don't need to use ${JSONCPP_LIBRARY} here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use a CMake target representing a library (defined in https://github.com/ethereum/solidity/blob/develop/cmake/jsoncpp.cmake#L47) than the path to the library directly (old school CMake).

The jsoncpp defines also include paths, however we have to workaround it with additional include_directories() because we want to make sure jsoncpp's include path is before /usr/include.

So in other words. both work but using jsoncpp is better style.

@axic
Copy link
Contributor Author

axic commented Apr 20, 2018

This works now locally (fixes the problem when jsoncpp is installed system wide by homebrew) and also fixes #3467.

@axic axic merged commit c8167a9 into develop Apr 20, 2018
@axic axic deleted the jsoncpp-cmake branch April 20, 2018 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants