-
-
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 6 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,31 @@ 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_CURRENT_BINARY_DIR}/wlroots . ${CMAKE_SOURCE_DIR}/subprojects/wlroots | ||
BUILD_COMMAND ${NINJA_EXE} -C . | ||
INSTALL_COMMAND ${NINJA_EXE} -C . install) | ||
vaxerski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 +104,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 +163,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 +171,48 @@ 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) | ||
|
||
install(DIRECTORY ${wlroots_INCLUDE_DIR}/ DESTINATION include/hyprland/wlroots) | ||
install(DIRECTORY protocols/ DESTINATION include/hyprland/protocols PATTERN "meson.build" EXCLUDE) | ||
m00nwtchr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hyprland.pc | ||
vaxerski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
DESTINATION share/pkgconfig) | ||
|
||
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) | ||
|
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