-
-
Notifications
You must be signed in to change notification settings - Fork 881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improvements to CMakeLists #2313
Changes from all commits
10d926e
78080b1
2d73419
ab30d91
f2352f9
00be9ab
0f0a934
26a629b
fe7c3de
c706fc6
2af4ed5
5c4bf27
aea2749
54a0955
9a8534d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
cmake_minimum_required(VERSION 3.19) | ||
include(CheckIncludeFile) | ||
include(ExternalProject) | ||
|
||
# Get version | ||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/props.json PROPS) | ||
|
@@ -12,7 +13,7 @@ project(Hyprland | |
|
||
set(HYPRLAND_VERSION ${VER}) | ||
set(PREFIX ${CMAKE_INSTALL_PREFIX}) | ||
configure_file(hyprland.pc.in hyprland.pc @ONLY) | ||
configure_file(hyprland.pc.in hyprland.pc @ONLY) | ||
|
||
set(CMAKE_MESSAGE_LOG_LEVEL "STATUS") | ||
|
||
|
@@ -69,12 +70,32 @@ else() | |
message(STATUS "Configuring Hyprland in Release with CMake") | ||
endif() | ||
|
||
include_directories( | ||
. | ||
"subprojects/wlroots/include/" | ||
"subprojects/wlroots/build/include/" | ||
"subprojects/udis86/" | ||
"protocols/") | ||
set(WLROOTS_SOVERSION 12032) | ||
|
||
find_program(MESON_EXE NAMES meson) | ||
find_program(NINJA_EXE NAMES ninja) | ||
find_program(SED_EXE NAMES sed) | ||
ExternalProject_Add(wlroots_build | ||
PREFIX wlroots | ||
SOURCE_DIR ${CMAKE_SOURCE_DIR}/subprojects/wlroots | ||
PATCH_COMMAND ${SED_EXE} -E -i -e "s/(soversion = 12)([^032]|$$)/soversion = ${WLROOTS_SOVERSION}/g" ${CMAKE_SOURCE_DIR}/subprojects/wlroots/meson.build | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the Sed script could be simplified to:
|
||
CONFIGURE_COMMAND ${MESON_EXE} setup --prefix "/" . ${CMAKE_SOURCE_DIR}/subprojects/wlroots | ||
BUILD_COMMAND ${NINJA_EXE} -C . | ||
INSTALL_COMMAND ${MESON_EXE} install --destdir ${CMAKE_CURRENT_BINARY_DIR}/wlroots | ||
BUILD_BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/wlroots/lib/libwlroots.so.${WLROOTS_SOVERSION}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: wrong indention? |
||
|
||
set(wlroots_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/subprojects/wlroots/include/) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it should be something like: ExternalProject_Get_property(wlroots_build INSTALL_DIR)
set(wlroots_INCLUDE_DIR ${INSTALL_DIR}/include/) I think that is reason why the build currently fails. |
||
set(wlroots_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/wlroots/lib/libwlroots.so.${WLROOTS_SOVERSION}) | ||
|
||
add_library(wlroots SHARED IMPORTED) | ||
add_dependencies(wlroots wlroots_build) | ||
set_target_properties(wlroots PROPERTIES | ||
IMPORTED_LOCATION ${wlroots_LIBRARY} | ||
INTERFACE_INCLUDE_DIRECTORIES ${wlroots_INCLUDE_DIR}) | ||
|
||
add_subdirectory("subprojects/udis86" udis86) | ||
m00nwtchr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
include_directories(${CMAKE_SOURCE_DIR}/subprojects/udis86/ "protocols/") | ||
|
||
set(CMAKE_CXX_STANDARD 23) | ||
add_compile_definitions(WLR_USE_UNSTABLE) | ||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Wno-unused-value -Wno-missing-field-initializers -Wno-narrowing -Wno-pointer-arith) | ||
|
@@ -84,14 +105,13 @@ set(CMAKE_ENABLE_EXPORTS TRUE) | |
message(STATUS "Checking deps...") | ||
|
||
find_package(Threads REQUIRED) | ||
|
||
find_package(PkgConfig REQUIRED) | ||
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") | ||
|
||
add_executable(Hyprland ${SRCFILES}) | ||
add_executable(hyprctl hyprctl/main.cpp) | ||
|
||
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG) | ||
message(STATUS "Setting debug flags") | ||
|
@@ -144,7 +164,6 @@ target_compile_definitions(Hyprland | |
"GIT_DIRTY=\"${GIT_DIRTY}\"" | ||
"GIT_TAG=\"${GIT_TAG}\"") | ||
|
||
target_link_libraries(Hyprland rt) | ||
|
||
set(CPACK_PROJECT_NAME ${PROJECT_NAME}) | ||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION}) | ||
|
@@ -153,35 +172,53 @@ include(CPack) | |
message(STATUS "Setting link libraries") | ||
|
||
function(protocol protoPath protoName external) | ||
if (external) | ||
if(external) | ||
execute_process( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using |
||
COMMAND ${WaylandScanner} server-header ${protoPath} protocols/${protoName}-protocol.h | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
execute_process( | ||
COMMAND ${WaylandScanner} private-code ${protoPath} protocols/${protoName}-protocol.c | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
target_sources(Hyprland PRIVATE protocols/${protoName}-protocol.c) | ||
else() | ||
execute_process( | ||
COMMAND ${WaylandScanner} server-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.h | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
execute_process( | ||
COMMAND ${WaylandScanner} private-code ${WAYLAND_PROTOCOLS_DIR}/${protoPath} protocols/${protoName}-protocol.c | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) | ||
target_sources(Hyprland PRIVATE protocols/${protoName}-protocol.c) | ||
endif() | ||
endfunction() | ||
|
||
target_link_libraries(Hyprland PkgConfig::deps) | ||
|
||
target_link_libraries(Hyprland | ||
${CMAKE_SOURCE_DIR}/subprojects/wlroots/build/libwlroots.so.12032 # wlroots is provided by us | ||
OpenGL::EGL | ||
OpenGL::GL | ||
Threads::Threads | ||
${CMAKE_SOURCE_DIR}/subprojects/udis86/build/libudis86/liblibudis86.a | ||
rt | ||
PkgConfig::deps | ||
OpenGL::EGL | ||
OpenGL::GL | ||
Threads::Threads | ||
wlroots | ||
udis86 | ||
) | ||
|
||
install(TARGETS Hyprland hyprctl DESTINATION bin) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it would make sense to include install(TARGETS Hyprland hyprctl DESTINATION ${CMAKE_INSTALL_BINDIR}) instead? |
||
install(FILES ${wlroots_LIBRARY} DESTINATION lib) | ||
install(DIRECTORY assets/ DESTINATION share/hyprland PATTERN "meson.build" EXCLUDE) | ||
install(FILES example/hyprland.desktop DESTINATION share/wayland-sessions) | ||
install(FILES example/hyprland.conf DESTINATION share/hyprland) | ||
install(FILES docs/hyprctl.1 docs/Hyprland.1 DESTINATION share/man/man1) | ||
|
||
if(NO_DEV) | ||
message(STATUS "Development headers disabled") | ||
else() | ||
message(STATUS "Development headers enabled") | ||
install(DIRECTORY ${wlroots_INCLUDE_DIR}/ DESTINATION include/hyprland/wlroots) | ||
install(DIRECTORY protocols/ DESTINATION include/hyprland/protocols FILES_MATCHING PATTERN "*.h") | ||
install(DIRECTORY src/ DESTINATION include/hyprland/src FILES_MATCHING PATTERN "*.h*") | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hyprland.pc | ||
vaxerski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
DESTINATION share/pkgconfig) | ||
endif() | ||
|
||
protocol("protocols/ext-workspace-unstable-v1.xml" "ext-workspace-unstable-v1" true) | ||
protocol("protocols/idle.xml" "idle" true) | ||
protocol("protocols/pointer-constraints-unstable-v1.xml" "pointer-constraints-unstable-v1" true) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
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`nproc 2>/dev/null || getconf NPROCESSORS_CONF` | ||
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DLEGACY_RENDERER:BOOL=true -S . -B build -G Ninja | ||
cmake --build build --config Release -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`nproc 2>/dev/null || getconf NPROCESSORS_CONF` | ||
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -DLEGACY_RENDERER:BOOL=true -S . -B build -G Ninja | ||
cmake --build build --config Release -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`nproc 2>/dev/null || getconf NPROCESSORS_CONF` | ||
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -S . -B build -G Ninja | ||
cmake --build build --config Release -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`nproc 2>/dev/null || getconf NPROCESSORS_CONF` | ||
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug -S . -B build -G Ninja | ||
cmake --build build --config Debug -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF` | ||
|
||
clear: | ||
rm -rf build | ||
|
@@ -24,48 +24,12 @@ clear: | |
|
||
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/ && 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 -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 | ||
|
||
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*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland | ||
cd subprojects/wlroots/include && find . -name '*.h*' -print0 | cpio --quiet -0dump ${PREFIX}/include/hyprland/wlroots && cd ../../.. | ||
cd subprojects/wlroots/build/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 | ||
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 | ||
cmake --install build --prefix "/usr" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fun of you to disallow commits from me on my own project. Hyprland installs to /usr/local, .pc to /usr.
if anything. |
||
|
||
uninstall: | ||
rm -f ${PREFIX}/share/wayland-sessions/hyprland.desktop | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be checked if
find_program
actually finds something. Since CMake 3.18 you can say:https://cmake.org/cmake/help/latest/command/find_program.html