|
1 | | -PROCESS_SOURCES() |
| 1 | +# CMakeLists.txt for libyui-qt/src |
| 2 | + |
| 3 | +include( ../VERSION.cmake ) |
| 4 | +include( GNUInstallDirs ) # set CMAKE_INSTALL_INCLUDEDIR, ..._LIBDIR |
| 5 | + |
| 6 | +# Use the package PkgConfig to detect GTK+ headers/library files |
| 7 | +FIND_PACKAGE(PkgConfig REQUIRED) |
| 8 | + |
| 9 | +PKG_CHECK_MODULES(YUI REQUIRED libyui) |
| 10 | +pkg_get_variable(YUI_SO_VERSION libyui soversion) |
| 11 | +pkg_get_variable(YUI_SO_MAJOR libyui soversion_major) |
| 12 | +#pkg_get_variable(YUI_SO_MINOR libyui soversion_minor) |
| 13 | +#pkg_get_variable(YUI_SO_PATCH libyui soversion_patch) |
| 14 | + |
| 15 | +# Check if the libs we link against are available. |
| 16 | +# They are all part of package ncurses-devel. |
| 17 | + |
| 18 | +find_library( NCURSESW_LIB NAMES ncursesw REQUIRED ) |
| 19 | +find_library( TINFO_LIB NAMES tinfo REQUIRED ) |
| 20 | + |
| 21 | +set( NCURSES_LIBS ${NCURSESW_LIB} ${TINFO_LIB} ) |
| 22 | + |
| 23 | +message (STATUS "Using ${YUI_LIBRARY_DIRS}/libyui.so.${YUI_SO_VERSION}") |
| 24 | + |
| 25 | +##### This is needed to be set for the libyui core |
| 26 | +SET( SONAME_MAJOR ${YUI_SO_MAJOR} ) |
| 27 | +SET( SONAME ${YUI_SO_VERSION} ) |
| 28 | + |
| 29 | +PKG_CHECK_MODULES(YUIMGA REQUIRED libyui-mga) |
| 30 | +PKG_CHECK_MODULES(YUI_NCURSES REQUIRED libyui-ncurses) |
| 31 | + |
| 32 | +# |
| 33 | +# libyui plugin specific |
| 34 | +# |
| 35 | + |
| 36 | +set( TARGETLIB libyui-mga-ncurses ) |
| 37 | +set( TARGETLIB_BASE yui-mga-ncurses ) |
| 38 | + |
| 39 | +set( HEADERS_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/yui/mga/ncurses ) |
| 40 | +set( PLUGIN_DIR ${CMAKE_INSTALL_LIBDIR}/yui ) # /usr/lib64/yui |
| 41 | + |
| 42 | +# if DESTDIR is set, CMAKE_INSTALL_INCLUDEDIR already contains it |
| 43 | +# during "make install" (but not for other make targets!): |
| 44 | +# |
| 45 | +# sudo make install DESTDIR=/work/foo |
| 46 | +# or |
| 47 | +# DESTDIR=/work/foo sudo make install |
| 48 | +# |
| 49 | +# -> the include files are installed to /work/foo/usr/include/... |
| 50 | +# We need that for RPM builds to install everything to $RPM_BUILD_ROOT. |
| 51 | + |
| 52 | + |
| 53 | +set( SOURCES |
| 54 | + NCMenu.cc |
| 55 | + NCMGAPopupMenu.cc |
| 56 | + YNCWE.cc |
| 57 | + YMGA_NCCBTable.cc |
| 58 | + YMGANCMenuBar.cc |
| 59 | + YMGANCWidgetFactory.cc |
| 60 | + ) |
| 61 | + |
| 62 | + |
| 63 | +set( HEADERS |
| 64 | + NCMenu.h |
| 65 | + NCMGAPopupMenu.h |
| 66 | + YNCWE.h |
| 67 | + YMGA_NCCBTable.h |
| 68 | + YMGANCMenuBar.h |
| 69 | + YMGANCWidgetFactory.h |
| 70 | + ) |
| 71 | + |
| 72 | + |
| 73 | +# Add shared lib to be built |
| 74 | +add_library( ${TARGETLIB} SHARED |
| 75 | + ${SOURCES} |
| 76 | + ${HEADERS} |
| 77 | + ) |
| 78 | + |
| 79 | + |
| 80 | +# Include directories and compile options |
| 81 | +# |
| 82 | + |
| 83 | +# Setup CMake to use GTK+, tell the compiler where to look for headers |
| 84 | +# and to the linker where to look for libraries |
| 85 | +INCLUDE_DIRECTORIES(${YUI_NCURSES_INCLUDE_DIRS} ${YUI_INCLUDE_DIRS} ${YUIMGA_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}) |
| 86 | + |
| 87 | + |
| 88 | +# Make the version from ../../VERSION.cmake available as a #define |
| 89 | +target_compile_definitions( ${TARGETLIB} PUBLIC VERSION="${VERSION}" ) |
| 90 | + |
| 91 | + |
| 92 | +# |
| 93 | +# Linking |
| 94 | +# |
| 95 | + |
| 96 | +# https://cmake.org/cmake/help/latest/command/link_directories.html suggests to use target_link_libraries |
| 97 | +# and anyway LINK_DIRECTORIES command will apply only to targets created after it is called, so must be set |
| 98 | +# before add_library in the case. |
| 99 | +target_link_directories( ${TARGETLIB} |
| 100 | + PUBLIC ${YUI_LIBRARY_DIRS} |
| 101 | + PUBLIC ${YUIMGA_LIBRARY_DIRS} |
| 102 | + PUBLIC ${YUI_NCURSES_LIBRARY_DIRS} |
| 103 | +) |
| 104 | + |
| 105 | + |
| 106 | +# Libraries that are needed to build this shared lib |
| 107 | +# |
| 108 | +# If in doubt what is really needed, check with "ldd -u" which libs are unused. |
| 109 | +target_link_libraries( ${TARGETLIB} |
| 110 | + ${YUI_LIBRARIES} |
| 111 | + ${YUIMGA_LIBRARIES} |
| 112 | + ${YUI_NCURSES_LIBRARIES} |
| 113 | + ${NCURSES_LIBS} |
| 114 | + ) |
| 115 | + |
| 116 | + |
| 117 | +# https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#target-properties |
| 118 | +set_target_properties( ${TARGETLIB} PROPERTIES |
| 119 | + VERSION ${SONAME} # From ../../VERSION.cmake |
| 120 | + SOVERSION ${SONAME_MAJOR} # From ../../VERSION.cmake |
| 121 | + OUTPUT_NAME ${TARGETLIB_BASE} |
| 122 | + ) |
| 123 | + |
| 124 | + |
| 125 | +# |
| 126 | +# Install |
| 127 | +# |
| 128 | + |
| 129 | +# Install the headers first so the message about the lib does not scroll away |
| 130 | +install( FILES ${HEADERS} DESTINATION ${HEADERS_INSTALL_DIR} ) |
| 131 | +install( TARGETS ${TARGETLIB} LIBRARY DESTINATION ${PLUGIN_DIR} ) |
0 commit comments