diff --git a/.gitignore b/.gitignore index 3bcdda1..10e6bdc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,10 @@ moc_* qrc_* imagewriter .tmp/ + +# build directory +build/ + # Compiled Object files *.slo *.lo diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..091c970 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,68 @@ +cmake_minimum_required(VERSION 3.19) +project(Imagewriter VERSION 1.10 LANGUAGES CXX) + +# try to find Qt6 +find_package(Qt6 6.2 + COMPONENTS DBus Gui Widgets) +if (Qt6_FOUND) + message(STATUS "Using Qt6") + qt_standard_project_setup() +else() + # try to fall back to Qt5 + find_package(Qt5 5.15 + COMPONENTS DBus Gui Widgets) + if (Qt5_FOUND) + message(STATUS "Using Qt5") + set(CMAKE_AUTOMOC ON) + set(CMAKE_AUTORCC ON) + set(CMAKE_AUTOUIC ON) + else() + message(FATAL_ERROR "Qt6 and Qt5 not found") + endif() +endif() + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden -fvisibility-inlines-hidden") + +add_executable(imagewriter + main.cpp + MainWindow.cpp + PlatformHal.cpp + PlatformUdisks.cpp + Platform.cpp + PlatformUdisks2.cpp + udisks2_interface.cpp + udisks2_mountpoints_interface.cpp + imagewriter.qrc +) + +include(FindPackageHandleStandardArgs) +if(USEHAL) + # try to find HAL + find_path(HAL_INCLUDE_DIR NAMES hal/libhal.h) + find_library(HAL_LIBRARY NAMES hal) + find_package_handle_standard_args(HAL REQUIRED_VARS HAL_INCLUDE_DIR HAL_LIBRARY) + target_compile_definitions(imagewriter PUBLIC USEHAL) +elseif(USEUDISKS) + target_compile_definitions(imagewriter PUBLIC USEUDISKS) +else() # default to USEUDISKS2 + target_compile_definitions(imagewriter PUBLIC USEUDISKS2) +endif() + +target_compile_definitions(imagewriter PUBLIC "APP_VERSION=\"${CMAKE_PROJECT_VERSION}\"") + +target_link_libraries(imagewriter + PRIVATE Qt::DBus Qt::Gui Qt::Widgets ${HAL_LIBRARY}) + +target_include_directories(imagewriter + PRIVATE HAL_INCLUDE_DIR UDISKS_INCLUDE_DIR UDISKS2_INCLUDE_DIR) + +# install +include(GNUInstallDirs) +install(TARGETS imagewriter + RUNTIME + RESOURCE imagewriter.qrc) +install(DIRECTORY icons DESTINATION "${DATAROOTDIR}/icons/hicolor/") +install(FILES imagewriter.1 DESTINATION ${mandir}) diff --git a/README.md b/README.md index 33ef4c2..b598068 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,26 @@ In order to compile, run % qmake DEFINES=USEHAL imagewriter.pro +or + + % cmake -DUSEHAL=ON .. + ** udisks1 ** % qmake DEFINES=USEUDISKS imagewriter.pro +or + + % cmake -DUSEUDISKS=ON .. + ** udisks2 ** % qmake DEFINES=USEUDISKS2 imagewriter.pro +or + + % cmake -DUSEUDISKS2=ON .. + Failing to specify the define will likely not work out. Then run diff --git a/imagewriter.pro b/imagewriter.pro index c3b98cc..fa57e94 100644 --- a/imagewriter.pro +++ b/imagewriter.pro @@ -1,6 +1,6 @@ -# ##################################################################### -# Automatically generated by qmake (2.01a) Thu Oct 23 14:13:58 2008 -# ##################################################################### +# print deprecation warning +message("qmake support is deprecated and will be removed in future release. Use CMake instead.") + unix:isEmpty(PREFIX):PREFIX = /usr/local TEMPLATE = app TARGET = imagewriter