Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Changes: CMake, double free, auto to unique_ptr (sed action) #2

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

ObiWahn
Copy link

@ObiWahn ObiWahn commented Jul 22, 2020

Hi,

I am helping a friend to evaluate a few graph libraries to find one that he can use with his students in the PACE challenge. Igraph(pp) is one of the top 3.

Here is a collection of first changes done to make igraphpp more useful for us. The PR is probably already bigger than it should be:(

Before you reject: The uinique_ptr in the generators is probably not what we want. I think I would go by-value, but shared pointer or whatever you prefer is fine for me. I have just used sed to get rid of the auto_ptr deprecation warning.


Here is some extra snippet that shows how the lib could be consumed when igraph is not installed in the system. The script will probably work on Linux and Mac only. I am not sure if it is of interest to you and should go in a file or wiki-page. We try to keep most dependencies as source to avoid students to use different versions.

## igraph - build
include(ExternalProject)
set(IGRAPH_PATH "${CMAKE_BINARY_DIR}/igraph_build-prefix/")
set(IGRAPH_SRC "${IGRAPH_PATH}/src/igraph_build")
set(IGRAPH_INSTALL_PATH "${CMAKE_BINARY_DIR}/igraph/install/")
set(IGRAPH_INCLUDES "${IGRAPH_INSTALL_PATH}/igraph/install/include")
ExternalProject_Add(igraph_build
    GIT_REPOSITORY https://github.com/igraph/igraph.git
    GIT_TAG 0.8.2
    GIT_PROGRESS TRUE
    CONFIGURE_COMMAND test -f ${IGRAPH_SRC}/configure || ${IGRAPH_SRC}/bootstrap.sh
    COMMAND test -f Makefile || ${IGRAPH_SRC}/configure --prefix=${IGRAPH_INSTALL_PATH}
    BUILD_COMMAND test -f ${IGRAPH_INCLUDES}/igraph/igraph.h || make
    INSTALL_COMMAND test -f ${IGRAPH_INCLUDES}/igraph/igraph.h || make install
)

## igraph - imported target
set(libname libigraph.so)
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
    set(libname libigraph.dylib)
endif()

add_library(igraph SHARED IMPORTED)
set_property(TARGET igraph PROPERTY IMPORTED_LOCATION ${IGRAPH_INSTALL_PATH}/lib/${libname})
#This directory must exist to pass it to `target_include_directories`
file(MAKE_DIRECTORY ${IGRAPH_INCLUDES})
target_include_directories(igraph INTERFACE ${IGRAPH_INCLUDES})

## igraphpp
include(FetchContent)
FetchContent_Declare(igraphpp_obiwahn
    GIT_REPOSITORY https://github.com/obiwahn/igraphpp.git
    GIT_TAG master
    GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(igraphpp_obiwahn)
add_dependencies(igraphpp igraph_build)

After that code a igraphpp target is available to be used with target_link_libraries. The sample works, but is probably not considered best style. Hardliners would certainly argue that the dependencies should be installed.

@ntamas
Copy link
Owner

ntamas commented Jul 22, 2020

Wow, thanks for the contribution! As you can see from the date of the last commit in this repo, I have abandoned igraphpp quite a while ago (I was not doing research any more at that time and I was focusing on other things). To be honest, I believed that igraphpp was not in a state that could have been useful to anyone, so I'm quite glad to hear that someone actually used it for something :)

I'll go through this PR during the next few days and give feedback. You might also be interested to know that igraph has recently received a grant from CZI to support further development, which means that we could continue working on igraphpp as well if there is real demand for it. I'd be grateful if you (or your friend) could head over to our discussion forum and tell us a bit more about how you are planning to use igraph, and whether there would be demand for a higher level C++ interface for igraph. Most of the people use igraph from R, Python or Mathematica, and I was assuming that people who are working on a lower level are quite okay with working igraph in C, but I may be wrong here.

@ntamas
Copy link
Owner

ntamas commented Jul 22, 2020

(One more thing: we have a branch in https://github.com/igraph/igraph where we are working on a CMake-based build system for igraph. Once that is done it would be much easier to add igraph as a subproject in igraphpp).

@ObiWahn
Copy link
Author

ObiWahn commented Jul 23, 2020

screenshot_2020-07-23_13:08:26

@ntamas what is wrong with the tag?

@ntamas
Copy link
Owner

ntamas commented Jul 23, 2020

I guess Discourse uses square brackets for special markup (e.g., boldface, italic, inline links) so you need to escape them somehow.

@ObiWahn
Copy link
Author

ObiWahn commented Jul 24, 2020

It worked when I used mathematica as tag instead of C 🤯 This could be edited later.

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.

3 participants