From 609c7ab6b5af90de947b55999d6a8bee7d048382 Mon Sep 17 00:00:00 2001 From: Jan Beich Date: Tue, 2 May 2023 13:38:36 +0000 Subject: [PATCH] Unbreak CMake build on FreeBSD (#2209) * cmake: unbreak on non-GNU after 474ada9267cc CMake Error at CMakeLists.txt:121 (target_link_libraries): The keyword signature for target_link_libraries has already been used with the target "Hyprland". All uses of target_link_libraries with a target must be either all-keyword or all-plain. The uses of the keyword signature are here: * CMakeLists.txt:107 (target_link_libraries) Fixes https://github.com/hyprwm/Hyprland/issues/1780 * cmake: always link with dependencies via imported targets On BSD systems base compiler by default only looks for headers and libraries from base system. For dependencies from packages extra flags are necessary. ld: error: unable to find library -lxcb ld: error: unable to find library -lpixman-1 ld: error: unable to find library -lOpenGL ld: error: unable to find library -lGLESv2 * make: use same make in recursive calls On BSDs `make` is BSD make while `gmake` is GNU make * make: work around GNU vs. BSD sed -i incompatibility https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254091 * make: replace GNU make extension with POSIX sh `$(shell ...)` in GNU make is similar to `${:!..!}` in BSD make * make: fall back when nproc isn't available Only FreeBSD added nproc for compatibility with Linux. * make: unbreak hyprctl on Clang-based systems /bin/sh: g++: not found error: invalid value 'c++23' in '-std=c++23' * make: create lib/ before copying libwlroots.so there $ make install PREFIX=/tmp/test [...] cp: directory /tmp/test/lib does not exist * make: pass cp(1) flags before arguments cp: -f is not a directory * make: replace install -Dt with mkdir install: illegal option -- t * make: replace cp --parents with cpio -dump cp: illegal option -- - * make: limit pkg-config workaround to Linux when run as root /usr/share/pkgconfig doesn't exist on BSDs or may not be writable. --- CMakeLists.txt | 17 ++++++------ Makefile | 67 ++++++++++++++++++++++++------------------------ hyprctl/Makefile | 2 +- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac07d6d1..cafdd94f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,7 +86,8 @@ message(STATUS "Checking deps...") find_package(Threads REQUIRED) find_package(PkgConfig REQUIRED) -pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-server wayland-client wayland-cursor wayland-protocols cairo libdrm egl xkbcommon libinput pango pangocairo) # we do not check for wlroots, as we provide it ourselves +find_package(OpenGL REQUIRED) +pkg_check_modules(deps REQUIRED IMPORTED_TARGET wayland-server wayland-client wayland-cursor wayland-protocols cairo libdrm xkbcommon libinput pango pangocairo pixman-1) # we do not check for wlroots, as we provide it ourselves file(GLOB_RECURSE SRCFILES CONFIGURE_DEPENDS "src/*.cpp") @@ -104,7 +105,7 @@ endif() include(CheckLibraryExists) check_library_exists(execinfo backtrace "" HAVE_LIBEXECINFO) if(HAVE_LIBEXECINFO) - target_link_libraries(Hyprland PRIVATE execinfo) + target_link_libraries(Hyprland execinfo) endif() if(LEGACY_RENDERER) @@ -117,8 +118,8 @@ if(NO_XWAYLAND) add_compile_definitions(NO_XWAYLAND) else() message(STATUS "XWAYLAND Enabled (NO_XWAYLAND not defined) checking deps...") - pkg_check_modules(xcbdep REQUIRED xcb) - target_link_libraries(Hyprland xcb) + pkg_check_modules(xcbdep REQUIRED IMPORTED_TARGET xcb) + target_link_libraries(Hyprland PkgConfig::xcbdep) endif() if(NO_SYSTEMD) @@ -175,11 +176,9 @@ target_link_libraries(Hyprland PkgConfig::deps) target_link_libraries(Hyprland ${CMAKE_SOURCE_DIR}/subprojects/wlroots/build/libwlroots.so.12032 # wlroots is provided by us - pixman-1 - OpenGL - GLESv2 - pthread - ${CMAKE_THREAD_LIBS_INIT} + OpenGL::EGL + OpenGL::GL + Threads::Threads ${CMAKE_SOURCE_DIR}/subprojects/udis86/build/libudis86/liblibudis86.a ) diff --git a/Makefile b/Makefile index 1af92f92..25538384 100644 --- a/Makefile +++ b/Makefile @@ -2,19 +2,19 @@ PREFIX = /usr/local legacyrenderer: cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DLEGACY_RENDERER:BOOL=true -S . -B ./build -G Ninja - cmake --build ./build --config Release --target all -j$(shell nproc) + cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` legacyrendererdebug: cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DLEGACY_RENDERER:BOOL=true -S . -B ./build -G Ninja - cmake --build ./build --config Release --target all -j$(shell nproc) + cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` release: cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build -G Ninja - cmake --build ./build --config Release --target all -j$(shell nproc) + cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` debug: cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -S . -B ./build -G Ninja - cmake --build ./build --config Debug --target all -j$(shell nproc) + cmake --build ./build --config Debug --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` clear: rm -rf build @@ -23,47 +23,48 @@ clear: rm -rf ./subprojects/wlroots/build all: - make clear - make fixwlr - cd ./subprojects/wlroots && meson setup build/ --buildtype=release && ninja -C build/ && cp ./build/libwlroots.so.12032 ${PREFIX}/lib/ || echo "Could not install libwlroots to ${PREFIX}/lib/libwlroots.so.12032" - cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B./build -G Ninja && cmake --build ./build --config Release --target all -j$(shell nproc) - make release - make -C hyprctl all + $(MAKE) clear + $(MAKE) fixwlr + cd ./subprojects/wlroots && meson setup build/ --buildtype=release && ninja -C build/ && mkdir -p ${PREFIX}/lib/ && cp ./build/libwlroots.so.12032 ${PREFIX}/lib/ || echo "Could not install libwlroots to ${PREFIX}/lib/libwlroots.so.12032" + cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B./build -G Ninja && cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` + $(MAKE) release + $(MAKE) -C hyprctl all install: - make clear - make fixwlr - cd ./subprojects/wlroots && meson setup build/ --buildtype=release && ninja -C build/ && cp ./build/libwlroots.so.12032 ${PREFIX}/lib/ || echo "Could not install libwlroots to ${PREFIX}/lib/libwlroots.so.12032" - cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B./build -G Ninja && cmake --build ./build --config Release --target all -j$(shell nproc) && cd ../.. - make release - make -C hyprctl all + $(MAKE) clear + $(MAKE) fixwlr + cd ./subprojects/wlroots && meson setup build/ --buildtype=release && ninja -C build/ && mkdir -p ${PREFIX}/lib/ && cp ./build/libwlroots.so.12032 ${PREFIX}/lib/ || echo "Could not install libwlroots to ${PREFIX}/lib/libwlroots.so.12032" + cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B./build -G Ninja && cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` && cd ../.. + $(MAKE) release + $(MAKE) -C hyprctl all mkdir -p ${PREFIX}/share/wayland-sessions mkdir -p ${PREFIX}/bin - cp ./build/Hyprland ${PREFIX}/bin -f - cp ./hyprctl/hyprctl ${PREFIX}/bin -f + cp -f ./build/Hyprland ${PREFIX}/bin + cp -f ./hyprctl/hyprctl ${PREFIX}/bin if [ ! -f ${PREFIX}/share/wayland-sessions/hyprland.desktop ]; then cp ./example/hyprland.desktop ${PREFIX}/share/wayland-sessions; fi mkdir -p ${PREFIX}/share/hyprland cp ./assets/wall_2K.png ${PREFIX}/share/hyprland cp ./assets/wall_4K.png ${PREFIX}/share/hyprland cp ./assets/wall_8K.png ${PREFIX}/share/hyprland - install -Dm644 -t ${PREFIX}/share/man/man1 ./docs/*.1 + mkdir -p ${PREFIX}/share/man/man1 + install -m644 ./docs/*.1 ${PREFIX}/share/man/man1 mkdir -p ${PREFIX}/include/hyprland mkdir -p ${PREFIX}/include/hyprland/protocols mkdir -p ${PREFIX}/include/hyprland/wlroots mkdir -p ${PREFIX}/share/pkgconfig - find src -name '*.h*' -exec cp --parents '{}' ${PREFIX}/include/hyprland ';' - cd subprojects/wlroots/include && find . -name '*.h*' -exec cp --parents '{}' ${PREFIX}/include/hyprland/wlroots ';' && cd ../../.. + find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland + cd subprojects/wlroots/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots && cd ../../.. cp ./protocols/*-protocol.h ${PREFIX}/include/hyprland/protocols cp ./build/hyprland.pc ${PREFIX}/share/pkgconfig - cp ./build/hyprland.pc /usr/share/pkgconfig + if [ -d /usr/share/pkgconfig ]; then cp ./build/hyprland.pc /usr/share/pkgconfig 2>/dev/null || true; fi cleaninstall: - echo -en "make cleaninstall has been DEPRECATED, you should avoid using it in the future.\nRunning make install instead...\n" - make install + echo -en "$(MAKE) cleaninstall has been DEPRECATED, you should avoid using it in the future.\nRunning $(MAKE) install instead...\n" + $(MAKE) install uninstall: rm -f ${PREFIX}/share/wayland-sessions/hyprland.desktop @@ -75,24 +76,24 @@ uninstall: rm -f ${PREFIX}/share/man/man1/hyprctl.1 fixwlr: - sed -i -E 's/(soversion = 12)([^032]|$$)/soversion = 12032/g' subprojects/wlroots/meson.build + sed -E -i -e 's/(soversion = 12)([^032]|$$)/soversion = 12032/g' subprojects/wlroots/meson.build rm -rf ./subprojects/wlroots/build config: - make fixwlr + $(MAKE) fixwlr meson setup subprojects/wlroots/build subprojects/wlroots --prefix=${PREFIX} --buildtype=release -Dwerror=false -Dexamples=false ninja -C subprojects/wlroots/build/ ninja -C subprojects/wlroots/build/ install - cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build -G Ninja && cmake --build ./build --config Release --target all -j$(shell nproc) + cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build -G Ninja && cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` pluginenv: - cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build -G Ninja && cmake --build ./build --config Release --target all -j$(shell nproc) + cd subprojects/udis86 && cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B ./build -G Ninja && cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` - make fixwlr + $(MAKE) fixwlr meson setup subprojects/wlroots/build subprojects/wlroots --prefix=${PREFIX} --buildtype=release -Dwerror=false -Dexamples=false ninja -C subprojects/wlroots/build/ @@ -104,14 +105,14 @@ pluginenv: mkdir -p ${PREFIX}/include/hyprland/wlroots mkdir -p ${PREFIX}/share/pkgconfig - find src -name '*.h*' -exec cp --parents '{}' ${PREFIX}/include/hyprland ';' - cd subprojects/wlroots/include && find . -name '*.h*' -exec cp --parents '{}' ${PREFIX}/include/hyprland/wlroots ';' && cd ../../.. + find src -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland + cd subprojects/wlroots/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots && cd ../../.. cp ./protocols/*-protocol.h ${PREFIX}/include/hyprland/protocols cp ./build/hyprland.pc ${PREFIX}/share/pkgconfig - cp ./build/hyprland.pc /usr/share/pkgconfig + if [ -d /usr/share/pkgconfig ]; then cp ./build/hyprland.pc /usr/share/pkgconfig 2>/dev/null || true; fi configdebug: - make fixwlr + $(MAKE) fixwlr meson setup subprojects/wlroots/build subprojects/wlroots --prefix=${PREFIX} --buildtype=debug -Dwerror=false -Dexamples=false -Db_sanitize=address ninja -C subprojects/wlroots/build/ diff --git a/hyprctl/Makefile b/hyprctl/Makefile index cd1df201..ec819918 100644 --- a/hyprctl/Makefile +++ b/hyprctl/Makefile @@ -1,4 +1,4 @@ all: - g++ -std=c++23 ./main.cpp -o ./hyprctl + $(CXX) -std=c++2b ./main.cpp -o ./hyprctl clean: rm ./hyprctl