Skip to content

Commit 3944236

Browse files
committedApr 9, 2021
first attempt to remove legacy buildtools dependency and use
GNUInstallDirs macros
1 parent 7773803 commit 3944236

File tree

6 files changed

+304
-53
lines changed

6 files changed

+304
-53
lines changed
 

‎.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Makefile.in
3939
# CMake
4040
CMakeCache.txt
4141
CMakeFiles
42-
CMakeLists.txt
4342
Makefile
4443
cmake_install.cmake
4544
install_manifest.txt

‎CMakeLists.txt

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# CMakeLists.txt for libyui-qt
2+
#
3+
# Usage:
4+
#
5+
# mkdir build
6+
# cd build
7+
# cmake ..
8+
#
9+
# make
10+
# sudo make install
11+
#
12+
# Restart with a clean build environment:
13+
# rm -rf build
14+
#
15+
# Show the complete compiler commands with all arguments:
16+
# make VERBOSE=1
17+
18+
cmake_minimum_required( VERSION 3.10 )
19+
project( libyui-qt )
20+
21+
# Options usage:
22+
#
23+
# cmake -DBUILD_DOC=on -DBUILD_EXAMPLES=off ..
24+
25+
option( BUILD_SRC "Build in src/ subdirectory" on )
26+
option( BUILD_DOC "Build class documentation" off )
27+
option( WERROR "Treat all compiler warnings as errors" off )
28+
29+
# Non-boolean options
30+
set( DOC_DESTDIR "" CACHE STRING "Destination directory prefix for installing docs" )
31+
32+
#----------------------------------------------------------------------
33+
34+
35+
set( CMAKE_INSTALL_MESSAGE LAZY ) # Suppress "up-to-date" messages during "make install"
36+
37+
add_compile_options( "-Wall" )
38+
IF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
39+
# Initialize compiler flags for all targets in all subdirectories
40+
add_compile_options( "-Os" ) # Optimize for size (overrides CMake's -O3 in RELEASE builds)
41+
endif()
42+
43+
if ( WERROR )
44+
add_compile_options( "-Werror" )
45+
endif()
46+
47+
48+
#
49+
# Descend into subdirectories
50+
#
51+
52+
if ( BUILD_SRC )
53+
add_subdirectory( src )
54+
endif()
55+
56+
if ( BUILD_DOC )
57+
add_subdirectory( doc )
58+
endif()

‎Makefile.cvs

-25
This file was deleted.

‎Makefile.repo

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#
2+
# Makefile.repo for libyui-gtk
3+
#
4+
5+
# Local Variables:
6+
# mode: Makefile
7+
# End:
8+
9+
10+
all: clean configure build-hint
11+
12+
build-hint:
13+
@echo ""
14+
@echo "To build:"
15+
@echo ""
16+
@echo " cd build"
17+
@echo " make"
18+
@echo ""
19+
20+
configure:
21+
mkdir build; \
22+
cd build; \
23+
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
24+
25+
build: clean configure
26+
cd build; \
27+
make -j $$(nproc)
28+
29+
# This needs root privileges, of course
30+
install: configure
31+
cd build; \
32+
make -j $$(nproc) && make install
33+
34+
clean:
35+
rm -rf build
36+
37+
package:
38+
rake package
39+
40+
doc:
41+
test -d build || mkdir build
42+
cd build; \
43+
cmake -DBUILD_DOC=on .. ; \
44+
make doc
45+
46+
install-doc: doc
47+
cd build; \
48+
make install-doc
49+
50+
version-bump:
51+
rake version:bump
52+
53+
# Just an alias
54+
bump-version: version-bump
55+
56+
57+
# Enforce rebuilding some targets unconditionally, even if a file or directory
58+
# with that name exists; otherwise the timestamp of that file or directory
59+
# would be checked.
60+
#
61+
# We need this because we have a subdirectory doc/, a subdirectory package/
62+
# and possibly a subdirectory build/ here.
63+
.PHONY: doc package build

‎bootstrap.sh

-26
This file was deleted.

‎src/CMakeLists.txt

+183-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,183 @@
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+
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
9+
10+
PKG_CHECK_MODULES(YUI REQUIRED libyui)
11+
12+
message(" " ${YUI_INCLUDE_DIRS} ${YUI_LIBRARY_DIRS})
13+
14+
find_library(YUYU libyui)
15+
16+
17+
#
18+
# libyui plugin specific
19+
#
20+
21+
set( TARGETLIB libyui-gtk )
22+
set( TARGETLIB_BASE yui-gtk )
23+
24+
set( HEADERS_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/yui/gtk )
25+
set( PLUGIN_DIR ${CMAKE_INSTALL_LIBDIR}/yui ) # /usr/lib64/yui
26+
27+
# if DESTDIR is set, CMAKE_INSTALL_INCLUDEDIR already contains it
28+
# during "make install" (but not for other make targets!):
29+
#
30+
# sudo make install DESTDIR=/work/foo
31+
# or
32+
# DESTDIR=/work/foo sudo make install
33+
#
34+
# -> the include files are installed to /work/foo/usr/include/...
35+
# We need that for RPM builds to install everything to $RPM_BUILD_ROOT.
36+
37+
38+
set( SOURCES
39+
YGBarGraph.cc
40+
YGComboBox.cc
41+
YGDialog.cc
42+
ygdkmngloader.c
43+
YGDumbTab.cc
44+
YGFrame.cc
45+
YGImage.cc
46+
YGInputField.cc
47+
YGIntField.cc
48+
YGLabel.cc
49+
YGLayout.cc
50+
YGMenuBar.cc
51+
YGMenuButton.cc
52+
YGPackageSelectorPluginStub.cc
53+
YGProgressBar.cc
54+
YGPushButton.cc
55+
YGRadioButton.cc
56+
YGSelectionStore.cc
57+
YGText.cc
58+
ygtkbargraph.c
59+
ygtkfieldentry.c
60+
ygtkfixed.c
61+
ygtkhtmlwrap.c
62+
ygtkimage.c
63+
ygtklinklabel.c
64+
ygtkmenubutton.c
65+
ygtkratiobox.c
66+
ygtkrichtext.c
67+
ygtksteps.c
68+
ygtktextview.c
69+
ygtktimezonepicker.c
70+
ygtktreeview.c
71+
ygtkwindow.c
72+
ygtkwizard.c
73+
YGTreeView.cc
74+
YGUI.cc
75+
YGUtils.cc
76+
YGWidget.cc
77+
YGWizard.cc
78+
)
79+
80+
81+
set( HEADERS
82+
YGDialog.h
83+
YGMenuBar.h
84+
ygdkmngloader.h
85+
YGi18n.h
86+
YGPackageSelectorPluginIf.h
87+
YGSelectionStore.h
88+
ygtkbargraph.h
89+
ygtkfieldentry.h
90+
ygtkfixed.h
91+
ygtkhtmlwrap.h
92+
ygtkimage.h
93+
ygtklinklabel.h
94+
ygtkmenubutton.h
95+
ygtkratiobox.h
96+
ygtkrichtext.h
97+
ygtksteps.h
98+
ygtktextview.h
99+
ygtktimezonepicker.h
100+
ygtktreeview.h
101+
ygtkwindow.h
102+
ygtkwizard.h
103+
YGUI.h
104+
YGUtils.h
105+
YGWidget.h
106+
)
107+
108+
109+
# Add shared lib to be built
110+
add_library( ${TARGETLIB} SHARED
111+
${SOURCES}
112+
${HEADERS}
113+
)
114+
115+
116+
# Include directories and compile options
117+
#
118+
119+
set( LOCAL_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include )
120+
121+
# Symlink ${YUI_INCLUDE_DIRS}
122+
# so the headers there can be included as <yui/YFoo.h>
123+
add_custom_target( local-include-dir
124+
# check if the symlink already exists
125+
COMMAND if [ ! -L "${LOCAL_INCLUDE_DIR}/yui" ]\; then
126+
rm -rf ${LOCAL_INCLUDE_DIR}\;
127+
mkdir ${LOCAL_INCLUDE_DIR}\;
128+
ln -s ${YUI_INCLUDE_DIRS} ${LOCAL_INCLUDE_DIR}/yui\;
129+
fi
130+
)
131+
132+
add_dependencies( ${TARGETLIB} local-include-dir )
133+
target_include_directories( ${TARGETLIB} BEFORE PUBLIC ${LOCAL_INCLUDE_DIR} )
134+
135+
# Setup CMake to use GTK+, tell the compiler where to look for headers
136+
# and to the linker where to look for libraries
137+
INCLUDE_DIRECTORIES(${GTK3_INCLUDE_DIRS} ${YUI_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
138+
LINK_DIRECTORIES(${GTK3_LIBRARY_DIRS} ${YUI_LIBRARY_DIRS})
139+
140+
141+
# Make the version from ../../VERSION.cmake available as a #define
142+
target_compile_definitions( ${TARGETLIB} PUBLIC VERSION="${VERSION}" )
143+
144+
145+
#
146+
# Linking
147+
#
148+
149+
# Find yui during a combined build
150+
target_link_directories( ${TARGETLIB} BEFORE PUBLIC ../../libyui/build/src )
151+
152+
153+
# Libraries that are needed to build this shared lib
154+
#
155+
# If in doubt what is really needed, check with "ldd -u" which libs are unused.
156+
target_link_libraries( ${TARGETLIB}
157+
# yui
158+
${YUI_LIBRARIES}
159+
${GTK3_LIBRARIES}
160+
)
161+
162+
# Notice that we don't link against Qt5::Svg, but we need it at runtime:
163+
#
164+
# It's a plugin for Qt and will be used to load SVGs (like our icons) if
165+
# libQt5Svg is available. But we don't use it directly here, only via Qt
166+
# classes like QPixmap and QIcon. Qt loads the SVG plugin as needed.
167+
168+
169+
# https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#target-properties
170+
set_target_properties( ${TARGETLIB} PROPERTIES
171+
VERSION ${SONAME} # From ../../VERSION.cmake
172+
SOVERSION ${SONAME_MAJOR} # From ../../VERSION.cmake
173+
OUTPUT_NAME ${TARGETLIB_BASE}
174+
)
175+
176+
177+
#
178+
# Install
179+
#
180+
181+
# Install the headers first so the message about the lib does not scroll away
182+
install( FILES ${HEADERS} DESTINATION ${HEADERS_INSTALL_DIR} )
183+
install( TARGETS ${TARGETLIB} LIBRARY DESTINATION ${PLUGIN_DIR} )

0 commit comments

Comments
 (0)
Please sign in to comment.