refactor: move cmake infra to separate files
This commit is contained in:
parent
acbc891fc0
commit
a714917300
5 changed files with 75 additions and 68 deletions
|
|
@ -1 +1,18 @@
|
||||||
|
find_package(Qt6 REQUIRED COMPONENTS ShaderTools Core Qml Gui Quick QuickControls2 Concurrent Sql Network DBus)
|
||||||
|
find_package(PkgConfig REQUIRED)
|
||||||
|
pkg_check_modules(Qalculate IMPORTED_TARGET libqalculate REQUIRED)
|
||||||
|
pkg_check_modules(Pipewire IMPORTED_TARGET libpipewire-0.3 REQUIRED)
|
||||||
|
pkg_check_modules(Aubio IMPORTED_TARGET aubio REQUIRED)
|
||||||
|
pkg_check_modules(Cava IMPORTED_TARGET libcava QUIET)
|
||||||
|
if(NOT Cava_FOUND)
|
||||||
|
pkg_check_modules(Cava IMPORTED_TARGET cava REQUIRED)
|
||||||
|
endif()
|
||||||
|
include(cmake/sensorslib.cmake)
|
||||||
|
|
||||||
|
set(QT_QML_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/qml")
|
||||||
|
qt_standard_project_setup(REQUIRES 6.9)
|
||||||
|
|
||||||
|
include(cmake/pch.cmake)
|
||||||
|
include(cmake/qml-module.cmake)
|
||||||
|
|
||||||
add_subdirectory(src/Caelestia)
|
add_subdirectory(src/Caelestia)
|
||||||
|
|
|
||||||
14
plugin/cmake/pch.cmake
Normal file
14
plugin/cmake/pch.cmake
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
add_library(caelestia-pch INTERFACE)
|
||||||
|
target_precompile_headers(caelestia-pch INTERFACE
|
||||||
|
<qobject.h>
|
||||||
|
<qqmlintegration.h>
|
||||||
|
<qstring.h>
|
||||||
|
<qqmlengine.h>
|
||||||
|
<qloggingcategory.h>
|
||||||
|
<qvariant.h>
|
||||||
|
<qtimer.h>
|
||||||
|
<qdir.h>
|
||||||
|
<qlist.h>
|
||||||
|
<qstringlist.h>
|
||||||
|
<qpointer.h>
|
||||||
|
)
|
||||||
35
plugin/cmake/qml-module.cmake
Normal file
35
plugin/cmake/qml-module.cmake
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
message(STATUS "QML install dir: ${CMAKE_INSTALL_PREFIX}/${INSTALL_QMLDIR}")
|
||||||
|
|
||||||
|
function(qml_module arg_TARGET)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 1 arg "" "URI" "SOURCES;QML_FILES;QML_SINGLETONS;DEPENDENCIES;IMPORTS;OPTIONAL_IMPORTS;DEFAULT_IMPORTS;LIBRARIES")
|
||||||
|
|
||||||
|
set_source_files_properties(${arg_QML_SINGLETONS} PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
|
||||||
|
|
||||||
|
qt_add_qml_module(${arg_TARGET}
|
||||||
|
URI ${arg_URI}
|
||||||
|
SOURCES ${arg_SOURCES}
|
||||||
|
QML_FILES ${arg_QML_FILES} ${arg_QML_SINGLETONS}
|
||||||
|
DEPENDENCIES ${arg_DEPENDENCIES}
|
||||||
|
IMPORTS ${arg_IMPORTS}
|
||||||
|
OPTIONAL_IMPORTS ${arg_OPTIONAL_IMPORTS}
|
||||||
|
DEFAULT_IMPORTS ${arg_DEFAULT_IMPORTS}
|
||||||
|
)
|
||||||
|
|
||||||
|
qt_query_qml_module(${arg_TARGET}
|
||||||
|
URI module_uri
|
||||||
|
PLUGIN_TARGET module_plugin_target
|
||||||
|
TARGET_PATH module_target_path
|
||||||
|
QMLDIR module_qmldir
|
||||||
|
TYPEINFO module_typeinfo
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS "Created QML module: ${module_uri}")
|
||||||
|
|
||||||
|
set(module_dir "${INSTALL_QMLDIR}/${module_target_path}")
|
||||||
|
install(TARGETS ${arg_TARGET} LIBRARY DESTINATION "${module_dir}" RUNTIME DESTINATION "${module_dir}")
|
||||||
|
install(TARGETS "${module_plugin_target}" LIBRARY DESTINATION "${module_dir}" RUNTIME DESTINATION "${module_dir}")
|
||||||
|
install(FILES "${module_qmldir}" DESTINATION "${module_dir}")
|
||||||
|
install(FILES "${module_typeinfo}" DESTINATION "${module_dir}")
|
||||||
|
|
||||||
|
target_link_libraries(${arg_TARGET} PRIVATE caelestia-pch Qt::Core Qt::Qml ${arg_LIBRARIES})
|
||||||
|
endfunction()
|
||||||
9
plugin/cmake/sensorslib.cmake
Normal file
9
plugin/cmake/sensorslib.cmake
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
find_library(SENSORS_LIBRARY NAMES sensors REQUIRED)
|
||||||
|
find_path(SENSORS_INCLUDE_DIR NAMES sensors/sensors.h REQUIRED)
|
||||||
|
if(NOT TARGET Sensors::Sensors)
|
||||||
|
add_library(Sensors::Sensors UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(Sensors::Sensors PROPERTIES
|
||||||
|
IMPORTED_LOCATION "${SENSORS_LIBRARY}"
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${SENSORS_INCLUDE_DIR}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
@ -1,71 +1,3 @@
|
||||||
find_package(Qt6 REQUIRED COMPONENTS ShaderTools Core Qml Gui Quick QuickControls2 Concurrent Sql Network DBus)
|
|
||||||
find_package(PkgConfig REQUIRED)
|
|
||||||
pkg_check_modules(Qalculate IMPORTED_TARGET libqalculate REQUIRED)
|
|
||||||
pkg_check_modules(Pipewire IMPORTED_TARGET libpipewire-0.3 REQUIRED)
|
|
||||||
pkg_check_modules(Aubio IMPORTED_TARGET aubio REQUIRED)
|
|
||||||
pkg_check_modules(Cava IMPORTED_TARGET libcava QUIET)
|
|
||||||
if(NOT Cava_FOUND)
|
|
||||||
pkg_check_modules(Cava IMPORTED_TARGET cava REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_library(SENSORS_LIBRARY NAMES sensors REQUIRED)
|
|
||||||
find_path(SENSORS_INCLUDE_DIR NAMES sensors/sensors.h REQUIRED)
|
|
||||||
if(NOT TARGET Sensors::Sensors)
|
|
||||||
add_library(Sensors::Sensors UNKNOWN IMPORTED)
|
|
||||||
set_target_properties(Sensors::Sensors PROPERTIES
|
|
||||||
IMPORTED_LOCATION "${SENSORS_LIBRARY}"
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${SENSORS_INCLUDE_DIR}"
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(QT_QML_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/qml")
|
|
||||||
qt_standard_project_setup(REQUIRES 6.9)
|
|
||||||
|
|
||||||
function(qml_module arg_TARGET)
|
|
||||||
cmake_parse_arguments(PARSE_ARGV 1 arg "" "URI" "SOURCES;QML_FILES;LIBRARIES")
|
|
||||||
|
|
||||||
qt_add_qml_module(${arg_TARGET}
|
|
||||||
URI ${arg_URI}
|
|
||||||
VERSION ${VERSION}
|
|
||||||
SOURCES ${arg_SOURCES}
|
|
||||||
QML_FILES ${arg_QML_FILES}
|
|
||||||
)
|
|
||||||
|
|
||||||
qt_query_qml_module(${arg_TARGET}
|
|
||||||
URI module_uri
|
|
||||||
VERSION module_version
|
|
||||||
PLUGIN_TARGET module_plugin_target
|
|
||||||
TARGET_PATH module_target_path
|
|
||||||
QMLDIR module_qmldir
|
|
||||||
TYPEINFO module_typeinfo
|
|
||||||
)
|
|
||||||
|
|
||||||
message(STATUS "Created QML module ${module_uri}, version ${module_version}")
|
|
||||||
|
|
||||||
set(module_dir "${INSTALL_QMLDIR}/${module_target_path}")
|
|
||||||
install(TARGETS ${arg_TARGET} LIBRARY DESTINATION "${module_dir}" RUNTIME DESTINATION "${module_dir}")
|
|
||||||
install(TARGETS "${module_plugin_target}" LIBRARY DESTINATION "${module_dir}" RUNTIME DESTINATION "${module_dir}")
|
|
||||||
install(FILES "${module_qmldir}" DESTINATION "${module_dir}")
|
|
||||||
install(FILES "${module_typeinfo}" DESTINATION "${module_dir}")
|
|
||||||
|
|
||||||
target_link_libraries(${arg_TARGET} PRIVATE caelestia-pch Qt::Core Qt::Qml ${arg_LIBRARIES})
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
add_library(caelestia-pch INTERFACE)
|
|
||||||
target_precompile_headers(caelestia-pch INTERFACE
|
|
||||||
<qobject.h>
|
|
||||||
<qqmlintegration.h>
|
|
||||||
<qstring.h>
|
|
||||||
<qqmlengine.h>
|
|
||||||
<qloggingcategory.h>
|
|
||||||
<qvariant.h>
|
|
||||||
<qtimer.h>
|
|
||||||
<qdir.h>
|
|
||||||
<qlist.h>
|
|
||||||
<qstringlist.h>
|
|
||||||
<qpointer.h>
|
|
||||||
)
|
|
||||||
|
|
||||||
qml_module(caelestia
|
qml_module(caelestia
|
||||||
URI Caelestia
|
URI Caelestia
|
||||||
SOURCES
|
SOURCES
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue