Commit d6fb6c39 authored by Robert Kimball's avatar Robert Kimball

add cmake finder for graphviz dot program and then conditionally compile…

add cmake finder for graphviz dot program and then conditionally compile visualization based on finding
parent 8fd94713
find_program(GRAPHVIZ_EXECUTABLE dot)
# Handle REQUIRED and QUIET arguments
# this will also set GRAPHVIZ_FOUND to true if GRAPHVIZ_EXECUTABLE exists
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Graphviz
"Failed to locate graphviz executable"
GRAPHVIZ_EXECUTABLE)
......@@ -36,15 +36,22 @@ set(NGRAPH_INCLUDE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/ngraph
)
# find_program (GRAPHVIZ dot)
# message (STATUS "graphviz '${GRAPHVIZ}'")
find_package(Graphviz)
if (GRAPHVIZ_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGRAPHVIZ_FOUND")
endif()
include_directories("${NGRAPH_INCLUDE_PATH}")
add_library(ngraph SHARED ${SRC})
target_include_directories(ngraph PUBLIC "${NGRAPH_INCLUDE_PATH}")
if ( APPLE )
set_property( TARGET ngraph PROPERTY PREFIX "lib" )
set_property( TARGET ngraph PROPERTY OUTPUT_NAME "ngraph.so" )
set_property( TARGET ngraph PROPERTY SUFFIX "" )
if (APPLE)
set_property(TARGET ngraph PROPERTY PREFIX "lib")
set_property(TARGET ngraph PROPERTY OUTPUT_NAME "ngraph.so")
set_property(TARGET ngraph PROPERTY SUFFIX "")
endif()
#-----------------------------------------------------------------------------------------------
......@@ -63,7 +70,7 @@ set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/ngraph_dist" CACHE PATH "Install directory"
message (STATUS "Installation directory: ${CMAKE_INSTALL_PREFIX}")
message (STATUS "To Override use: cmake -DCMAKE_INSTALL_PREFIX=/foo -P cmake_install.cmake")
install(TARGETS ngraph DESTINATION ${CMAKE_INSTALL_PREFIX} )
install(TARGETS ngraph DESTINATION ${CMAKE_INSTALL_PREFIX})
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/ngraph
DESTINATION ${CMAKE_INSTALL_PREFIX}
......
......@@ -41,6 +41,7 @@ void Visualize::add(node_ptr p)
void Visualize::save_dot(const string& path) const
{
#if GRAPHVIZ_FOUND
auto tmp_file = path + ".tmp";
ofstream out(tmp_file);
if (out)
......@@ -56,6 +57,8 @@ void Visualize::save_dot(const string& path) const
auto stream = popen(cmd.c_str(), "r");
pclose(stream);
// remove(tmp_file.c_str());
remove(tmp_file.c_str());
}
#else
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment