mirror of
https://github.com/QRouland/UTPass.git
synced 2024-09-08 00:35:22 +00:00
95 lines
2.9 KiB
CMake
95 lines
2.9 KiB
CMake
project(UTPass C CXX)
|
|
cmake_minimum_required(VERSION 3.5.1)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
|
|
|
option(TEST_RUNNER "Run Test" OFF)
|
|
if(${TEST_RUNNER})
|
|
add_definitions(-DTEST_RUNNER)
|
|
endif()
|
|
|
|
execute_process(
|
|
COMMAND dpkg-architecture -qDEB_HOST_ARCH
|
|
OUTPUT_VARIABLE CLICK_ARCH
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
execute_process(
|
|
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
|
|
OUTPUT_VARIABLE ARCH_TRIPLET
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
|
|
|
|
find_package(Qt5Core)
|
|
find_package(Qt5Qml)
|
|
find_package(Qt5Quick)
|
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
# Automatically create moc files
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(QT_IMPORTS_DIR "lib/${ARCH_TRIPLET}")
|
|
|
|
set(PROJECT_NAME "UTPass")
|
|
set(FULL_PROJECT_NAME "utpass.qrouland")
|
|
set(CMAKE_INSTALL_PREFIX /)
|
|
set(DATA_DIR /)
|
|
set(BIN_DIR ${DATA_DIR}lib/${ARCH_TRIPLET}/bin)
|
|
set(DESKTOP_FILE_NAME ${PROJECT_NAME}.desktop)
|
|
|
|
add_executable(${PROJECT_NAME} main.cpp)
|
|
|
|
if(${TEST_RUNNER})
|
|
find_package(Qt5QuickTest)
|
|
qt5_use_modules(${PROJECT_NAME} Gui Qml Quick QuickTest)
|
|
else()
|
|
qt5_use_modules(${PROJECT_NAME} Gui Qml Quick)
|
|
endif()
|
|
|
|
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
|
|
|
configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION ${CMAKE_INSTALL_PREFIX})
|
|
install(FILES ${PROJECT_NAME}.apparmor DESTINATION ${DATA_DIR})
|
|
install(DIRECTORY qml DESTINATION ${DATA_DIR})
|
|
install(DIRECTORY assets DESTINATION ${DATA_DIR})
|
|
file(GLOB_RECURSE BIN_FILES
|
|
"third/local/${ARCH_TRIPLET}/bin/*")
|
|
install(
|
|
FILES ${BIN_FILES}
|
|
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
|
DESTINATION ${BIN_DIR}
|
|
)
|
|
if(${TEST_RUNNER})
|
|
install(DIRECTORY tests DESTINATION ${DATA_DIR})
|
|
endif()
|
|
|
|
# Translations
|
|
file(GLOB_RECURSE I18N_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po qml/*.qml qml/*.js)
|
|
list(APPEND I18N_SRC_FILES ${DESKTOP_FILE_NAME}.in.h)
|
|
|
|
find_program(INTLTOOL_MERGE intltool-merge)
|
|
if (NOT INTLTOOL_MERGE)
|
|
message(FATAL_ERROR "Could not find intltool-merge, please install the intltool package")
|
|
endif ()
|
|
find_program(INTLTOOL_EXTRACT intltool-extract)
|
|
if (NOT INTLTOOL_EXTRACT)
|
|
message(FATAL_ERROR "Could not find intltool-extract, please install the intltool package")
|
|
endif ()
|
|
|
|
add_custom_target(${DESKTOP_FILE_NAME} ALL
|
|
COMMENT "Merging translations into ${DESKTOP_FILE_NAME}..."
|
|
COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${CMAKE_SOURCE_DIR}/${DESKTOP_FILE_NAME}.in ${DESKTOP_FILE_NAME}
|
|
COMMAND sed -i 's/${PROJECT_NAME}-//g' ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME}
|
|
)
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME} DESTINATION ${DATA_DIR})
|
|
|
|
add_subdirectory(po)
|
|
add_subdirectory(plugins)
|
|
|
|
add_custom_target(${PROJECT_NAME}_FILES ALL SOURCES ${PROJECT_SRC_FILES})
|
|
|