141 lines
10 KiB
CMake
141 lines
10 KiB
CMake
cmake_minimum_required(VERSION 3.31)
|
|
|
|
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "0e5b6991-d74f-4b3d-a41c-cf096e0b2508")
|
|
|
|
project(LunarWM LANGUAGES C CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_MODULE_STD 1)
|
|
|
|
add_compile_options(
|
|
-fstack-protector-strong
|
|
-fwrapv
|
|
)
|
|
add_compile_definitions(
|
|
WLR_USE_UNSTABLE
|
|
XR_USE_PLATFORM_EGL
|
|
XR_USE_GRAPHICS_API_OPENGL_ES
|
|
)
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
find_package(Boost REQUIRED)
|
|
|
|
pkg_check_modules(WAYLAND REQUIRED IMPORTED_TARGET GLOBAL wayland-server)
|
|
pkg_check_modules(EGL REQUIRED IMPORTED_TARGET egl)
|
|
pkg_check_modules(GLES2 REQUIRED IMPORTED_TARGET glesv2)
|
|
pkg_check_modules(WLROOTS REQUIRED IMPORTED_TARGET wlroots-0.20)
|
|
pkg_check_modules(XKBCOMMON REQUIRED IMPORTED_TARGET xkbcommon)
|
|
pkg_check_modules(OPENXR REQUIRED IMPORTED_TARGET openxr)
|
|
|
|
find_program(WAYLAND_SCANNER_EXECUTABLE wayland-scanner REQUIRED)
|
|
message(STATUS "Found wayland-scanner at ${WAYLAND_SCANNER_EXECUTABLE}")
|
|
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
|
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
|
pkg_get_variable(WAYLAND_SCANNER_PKGDATA_DIR wayland-scanner pkgdatadir)
|
|
message(
|
|
STATUS "Found wayland-scanner pkgdatadir at ${WAYLAND_SCANNER_PKGDATA_DIR}")
|
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
raylib
|
|
GIT_REPOSITORY https://github.com/slendidev/raylib.git
|
|
GIT_TAG "lunar"
|
|
GIT_SHALLOW 1
|
|
)
|
|
set(OPENGL_VERSION "ES 3.0")
|
|
set(PLATFORM DRM)
|
|
set(BUILD_EXAMPLES OFF)
|
|
FetchContent_MakeAvailable(raylib)
|
|
|
|
FetchContent_Declare(
|
|
cpptrace
|
|
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
|
|
GIT_TAG v1.0.1
|
|
)
|
|
FetchContent_MakeAvailable(cpptrace)
|
|
|
|
add_executable(${PROJECT_NAME})
|
|
target_sources(${PROJECT_NAME} PUBLIC
|
|
src/dhos_config.cpp
|
|
src/main.cpp
|
|
)
|
|
target_sources(${PROJECT_NAME} PUBLIC FILE_SET CXX_MODULES FILES
|
|
src/Util.cppm
|
|
src/Math.cppm
|
|
src/Config.cppm
|
|
src/LunarWM.cppm
|
|
)
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC
|
|
PkgConfig::XKBCOMMON
|
|
PkgConfig::WAYLAND
|
|
PkgConfig::EGL
|
|
PkgConfig::GLES2
|
|
PkgConfig::WLROOTS
|
|
PkgConfig::OPENXR
|
|
|
|
Boost::boost
|
|
raylib
|
|
cpptrace::cpptrace
|
|
)
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
CXX_CLANG_TIDY "clang-tidy;-header-filter=^${CMAKE_SOURCE_DIR}/src/.*;-checks=*,-some-disabled-checks,misc-const-correctness,modernize-use-nullptr,bugprone-branch-clone,bugprone-use-after-move,performance-unnecessary-value-param,hicpp-no-malloc,cppcoreguidelines-pro-type-const-cast,clang-analyzer-core.NullDereference,-fuchsia-overloaded-operator,-readability-identifier-length,-bugprone-easily-swappable-parameters,-fuchsia-trailing-return,-misc-non-private-member-variables-in-classes,-readability-math-missing-parentheses,-llvmlibc-implementation-in-namespace,-misc-include-cleaner,-modernize-use-std-print,-llvmlibc-restrict-system-libc-headers,-fuchsia-statically-constructed-objects,-cppcoreguidelines-avoid-non-const-global-variables,-llvmlibc-callee-namespace,-misc-use-anonymous-namespace,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-hicpp-uppercase-literal-suffix,-readability-uppercase-literal-suffix,-fuchsia-default-arguments-calls,-altera-unroll-loops,-fuchsia-default-arguments-declarations,-readability-function-cognitive-complexity,-altera-struct-pack-align,-altera-id-dependent-backward-branch,-cppcoreguidelines-pro-type-reinterpret-cast,-boost-use-ranges,-cppcoreguidelines-owning-memory,-readability-redundant-declaration,-bugprone-unchecked-optional-access,-readability-const-return-type,-llvm-namespace-comment,-google-readability-namespace-comments,-cert-arr39-c,-cert-con36-c,-cert-con54-cpp,-cert-ctr56-cpp,-cert-dcl03-c,-cert-dcl16-c,-cert-dcl37-c,-cert-dcl51-cpp,-cert-dcl54-cpp,-cert-dcl59-cpp,-cert-err09-cpp,-cert-err61-cpp,-cert-exp42-c,-cert-fio38-c,-cert-flp37-c,-cert-int09-c,-cert-msc24-c,-cert-msc30-c,-cert-msc32-c,-cert-msc33-c,-cert-msc54-cpp,-cert-oop11-cpp,-cert-oop54-cpp,-cert-pos44-c,-cert-pos47-c,-cert-sig30-c,-cert-str34-c,-clang-analyzer-core.BitwiseShift,-clang-analyzer-core.CallAndMessage,-clang-analyzer-core.DivideZero,-clang-analyzer-core.NonNullParamChecker,-clang-analyzer-core.NullDereference,-clang-analyzer-core.StackAddressEscape,-clang-analyzer-core.UndefinedBinaryOperatorResult,-clang-analyzer-core.VLASize,-clang-analyzer-core.uninitialized.ArraySubscript,-clang-analyzer-core.uninitialized.Assign,-clang-analyzer-core.uninitialized.Branch,-clang-analyzer-core.uninitialized.CapturedBlockVariable,-clang-analyzer-core.uninitialized.NewArraySize,-clang-analyzer-core.uninitialized.UndefReturn,-clang-analyzer-cplusplus.ArrayDelete,-clang-analyzer-cplusplus.InnerPointer,-clang-analyzer-cplusplus.Move,-clang-analyzer-cplusplus.NewDelete,-clang-analyzer-cplusplus.NewDeleteLeaks,-clang-analyzer-cplusplus.PlacementNew,-clang-analyzer-cplusplus.SelfAssignment,-clang-analyzer-cplusplus.StringChecker,-clang-analyzer-deadcode.DeadStores,-clang-analyzer-fuchsia.HandleChecker,-clang-analyzer-nullability.NullPassedToNonnull,-clang-analyzer-nullability.NullReturnedFromNonnull,-clang-analyzer-nullability.NullableDereferenced,-clang-analyzer-nullability.NullablePassedToNonnull,-clang-analyzer-nullability.NullableReturnedFromNonnull,-clang-analyzer-optin.core.EnumCastOutOfRange,-clang-analyzer-optin.cplusplus.UninitializedObject,-clang-analyzer-optin.cplusplus.VirtualCall,-clang-analyzer-optin.mpi.MPI-Checker,-clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,-clang-analyzer-optin.osx.cocoa.localizability.NonLocalizedStringChecker,-clang-analyzer-optin.performance.GCDAntipattern,-clang-analyzer-optin.performance.Padding,-clang-analyzer-optin.portability.UnixAPI,-clang-analyzer-optin.taint.TaintedAlloc,-clang-analyzer-osx.API,-clang-analyzer-osx.NumberObjectConversion,-clang-analyzer-osx.ObjCProperty,-clang-analyzer-osx.SecKeychainAPI,-clang-analyzer-osx.cocoa.AtSync,-clang-analyzer-osx.cocoa.AutoreleaseWrite,-clang-analyzer-osx.cocoa.ClassRelease,-clang-analyzer-osx.cocoa.Dealloc,-clang-analyzer-osx.cocoa.IncompatibleMethodTypes,-clang-analyzer-osx.cocoa.Loops,-clang-analyzer-osx.cocoa.MissingSuperCall,-clang-analyzer-osx.cocoa.NSAutoreleasePool,-clang-analyzer-osx.cocoa.NSError,-clang-analyzer-osx.cocoa.NilArg,-clang-analyzer-osx.cocoa.NonNilReturnValue,-clang-analyzer-osx.cocoa.ObjCGenerics,-clang-analyzer-osx.cocoa.RetainCount,-clang-analyzer-osx.cocoa.RunLoopAutoreleaseLeak,-clang-analyzer-osx.cocoa.SelfInit,-clang-analyzer-osx.cocoa.SuperDealloc,-clang-analyzer-osx.cocoa.UnusedIvars,-clang-analyzer-osx.cocoa.VariadicMethodTypes,-clang-analyzer-osx.coreFoundation.CFError,-clang-analyzer-osx.coreFoundation.CFNumber,-clang-analyzer-osx.coreFoundation.CFRetainRelease,-clang-analyzer-osx.coreFoundation.containers.OutOfBounds,-clang-analyzer-osx.coreFoundation.containers.PointerSizedValues,-clang-analyzer-security.FloatLoopCounter,-clang-analyzer-security.PutenvStackArray,-clang-analyzer-security.SetgidSetuidOrder,-clang-analyzer-security.cert.env.InvalidPtr,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,-clang-analyzer-security.insecureAPI.UncheckedReturn,-clang-analyzer-security.insecureAPI.bcmp,-clang-analyzer-security.insecureAPI.bcopy,-clang-analyzer-security.insecureAPI.bzero,-clang-analyzer-security.insecureAPI.decodeValueOfObjCType,-clang-analyzer-security.insecureAPI.getpw,-clang-analyzer-security.insecureAPI.gets,-clang-analyzer-security.insecureAPI.mkstemp,-clang-analyzer-security.insecureAPI.mktemp,-clang-analyzer-security.insecureAPI.rand,-clang-analyzer-security.insecureAPI.strcpy,-clang-analyzer-security.insecureAPI.vfork,-clang-analyzer-unix.API,-clang-analyzer-unix.BlockInCriticalSection,-clang-analyzer-unix.Errno,-clang-analyzer-unix.Malloc,-clang-analyzer-unix.MallocSizeof,-clang-analyzer-unix.MismatchedDeallocator,-clang-analyzer-unix.StdCLibraryFunctions,-clang-analyzer-unix.Stream,-clang-analyzer-unix.Vfork,-clang-analyzer-unix.cstring.BadSizeArg,-clang-analyzer-unix.cstring.NullArg,-clang-analyzer-webkit.NoUncountedMemberChecker,-clang-analyzer-webkit.RefCntblBaseVirtualDtor,-clang-analyzer-webkit.UncountedLambdaCapturesChecker,-cppcoreguidelines-avoid-c-arrays,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-c-copy-assignment-signature,-cppcoreguidelines-explicit-virtual-functions,-cppcoreguidelines-macro-to-enum,-cppcoreguidelines-narrowing-conversions,-cppcoreguidelines-noexcept-destructor,-cppcoreguidelines-noexcept-move-operations,-cppcoreguidelines-noexcept-swap,-cppcoreguidelines-non-private-member-variables-in-classes,-cppcoreguidelines-use-default-member-init,-fuchsia-header-anon-namespaces,-google-readability-braces-around-statements,-google-readability-function-size,-google-readability-namespace-comments,-hicpp-avoid-c-arrays,-hicpp-avoid-goto,-hicpp-braces-around-statements,-hicpp-deprecated-headers,-hicpp-explicit-conversions,-hicpp-function-size,-hicpp-invalid-access-moved,-hicpp-member-init,-hicpp-move-const-arg,-hicpp-named-parameter,-hicpp-new-delete-operators,-hicpp-no-array-decay,-hicpp-no-malloc,-hicpp-noexcept-move,-hicpp-special-member-functions,-hicpp-static-assert,-hicpp-undelegated-constructor,-hicpp-uppercase-literal-suffix,-hicpp-use-auto,-hicpp-use-emplace,-hicpp-use-equals-default,-hicpp-use-equals-delete,-hicpp-use-noexcept,-hicpp-use-nullptr,-hicpp-use-override,-hicpp-vararg,-llvm-else-after-return,-llvm-qualified-auto,-llvm-header-guard"
|
|
)
|
|
|
|
# Wayland protocol codegen
|
|
set(XDG_SHELL_XML
|
|
${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml
|
|
)
|
|
|
|
set(XDG_SHELL_HEADER
|
|
${CMAKE_BINARY_DIR}/xdg-shell-protocol.h
|
|
)
|
|
|
|
set(XDG_SHELL_C
|
|
${CMAKE_BINARY_DIR}/xdg-shell-protocol.c
|
|
)
|
|
|
|
add_custom_command(
|
|
OUTPUT ${XDG_SHELL_HEADER}
|
|
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} server-header
|
|
${XDG_SHELL_XML} ${XDG_SHELL_HEADER}
|
|
DEPENDS ${XDG_SHELL_XML}
|
|
COMMENT "Generating xdg-shell-protocol.h (server header)"
|
|
VERBATIM
|
|
)
|
|
|
|
add_custom_command(
|
|
OUTPUT ${XDG_SHELL_C}
|
|
COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code
|
|
${XDG_SHELL_XML} ${XDG_SHELL_C}
|
|
DEPENDS ${XDG_SHELL_XML}
|
|
COMMENT "Generating xdg-shell-protocol.c"
|
|
VERBATIM
|
|
)
|
|
|
|
add_custom_target(xdg_shell_protocol
|
|
DEPENDS ${XDG_SHELL_HEADER} ${XDG_SHELL_C}
|
|
)
|
|
|
|
add_library(xdg_shell STATIC
|
|
${XDG_SHELL_C}
|
|
)
|
|
|
|
add_dependencies(xdg_shell xdg_shell_protocol)
|
|
|
|
target_include_directories(xdg_shell PUBLIC
|
|
${CMAKE_BINARY_DIR}
|
|
)
|
|
|
|
add_dependencies(${PROJECT_NAME} xdg_shell_protocol)
|
|
|
|
target_link_libraries(${PROJECT_NAME} PRIVATE xdg_shell)
|
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
|
${CMAKE_BINARY_DIR}
|
|
)
|
|
|