Skip to content

Commit

Permalink
Support building the (not very useful) examples
Browse files Browse the repository at this point in the history
  • Loading branch information
shundhammer committed Jan 14, 2021
1 parent 1ac18a3 commit 6ca724a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ project( libyui-qt-graph )
#
# cmake -DBUILD_DOC=on -DBUILD_EXAMPLES=off ..

option( BUILD_SRC "Build in src/ subdirectory" on )
option( BUILD_SRC "Build in src/ subdirectory" on )
option( BUILD_EXAMPLES "Build C++ -based libyui examples" off )
option( BUILD_DOC "Build class documentation" off )
option( WERROR "Treat all compiler warnings as errors" on )
Expand Down
51 changes: 50 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
PROCESS_EXAMPLES()
# CMakeLists.txt for libyui-qt-graph/examples

include( ../VERSION.cmake )
include( FindPkgConfig ) # pkg_check_modules()

set( PKG_NAME libyui-qt-graph${SONAME_MAJOR} )
set( EXAMPLES_INSTALL_DIR ${DESTDIR}/usr/share/doc/packages/${PKG_NAME}/examples )

set( USE_FRESHLY_BUILT_LIBYUI off )

if ( USE_FRESHLY_BUILT_LIBYUI )
# Use the freshly built libyui from ../build/src, not the system libyui from
# /usr/lib64; also set rpath.
#
# FIXME: This will still load the UI plug-ins from the system, not the
# freshly built ones.
set( LIBYUI ${CMAKE_BINARY_DIR}/src/libyui.so )
else()
# Link against the system libyui in /usr/lib64. No rpath.
set( LIBYUI yui )
endif()

# Check for the libgvc (from the libgraphviz package) via pkg-config;
# this sets LIBGVC_LIBRARIES (and more).
pkg_check_modules( LIBGVC REQUIRED libgvc )


# Build a simple example named EXAMPLE from one source file EXAMPLE.cc
# and install the source to the package's doc directory
#
function( add_example EXAMPLE )
add_executable( ${EXAMPLE} ${EXAMPLE}.cc )
target_link_libraries( ${EXAMPLE} ${LIBYUI} ${LIBGVC_LIBRARIES} )

# Add a dependency to the libyui-qt-graph CMake target so ../src/ is built first
add_dependencies( ${EXAMPLE} libyui-qt-graph )

if ( USE_FRESHLY_BUILT_LIBYUI )
# Enable including headers like <yui/YFoo.h> from ../../libyui/include
# which has a symlink yui -> ../src
target_include_directories( ${EXAMPLE} BEFORE PUBLIC ../../libyui/include )
endif()

install( FILES ${EXAMPLE}.cc DESTINATION ${EXAMPLES_INSTALL_DIR} )
endfunction()

#----------------------------------------------------------------------

add_example( SimpleCreate )
add_example( SimpleLoad )
3 changes: 2 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ include( FindPkgConfig ) # pkg_check_modules()
find_package( Qt5 COMPONENTS Widgets Svg X11Extras REQUIRED )
set( CMAKE_AUTOMOC on ) # Automatically handle "moc" preprocessor (Q_OBJECTs)

# Check for the libgvc (from the libgraphviz package) via pkg-config
# Check for the libgvc (from the libgraphviz package) via pkg-config;
# this sets LIBGVC_LIBRARIES (and more).
pkg_check_modules( LIBGVC REQUIRED libgvc )
message( "-- Graphviz libs: ${LIBGVC_LIBRARIES}" )

Expand Down

0 comments on commit 6ca724a

Please sign in to comment.