CMakeLists.txt 3.15 KB
Newer Older
1
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
2 3
project(kcm-fcitx)

Weng Xuetian's avatar
Weng Xuetian committed
4 5 6 7 8 9 10
set(QT_MIN_VERSION "5.3.0")
find_package(ECM 1.0.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings)
include(FeatureSummary)
11 12
option(ENABLE_TEST "Enable test" Off)

13
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets X11Extras)
Weng Xuetian's avatar
Weng Xuetian committed
14 15 16 17

find_package(KF5 REQUIRED COMPONENTS
    CoreAddons
    WidgetsAddons
18
    ConfigWidgets
Weng Xuetian's avatar
Weng Xuetian committed
19 20 21 22 23 24
    ItemViews
    I18n
    KIO
    NewStuff
)

25 26
find_package(FcitxQt5DBusAddons 1.1.0 REQUIRED)
find_package(FcitxQt5WidgetsAddons 1.1.0 REQUIRED)
Weng Xuetian's avatar
Weng Xuetian committed
27

Weng Xuetian's avatar
Weng Xuetian committed
28
set(MAJOR_VERSION "0")
29
set(MINOR_VERSION "5")
30
set(PATCH_VERSION "4")
Weng Xuetian's avatar
Weng Xuetian committed
31 32
set(SUFFIX_VERSION "")

33 34
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})

Weng Xuetian's avatar
Weng Xuetian committed
35 36 37 38 39 40 41
set(VERSION_STRING "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
if(NOT SUFFIX_VERSION)
    set(VERSION_STRING_FULL "${VERSION_STRING}")
else(NOT SUFFIX_VERSION)
    set(VERSION_STRING_FULL "${VERSION_STRING}-${SUFFIX_VERSION}")
endif(NOT SUFFIX_VERSION)

Weng Xuetian's avatar
Weng Xuetian committed
42
find_package(PkgConfig REQUIRED)
Weng Xuetian's avatar
Weng Xuetian committed
43
find_package(Gettext REQUIRED)
44
find_package(Fcitx 4.2.8 REQUIRED)
45
find_package(XkbFile REQUIRED)
46
find_package(X11 REQUIRED)
47

Weng Xuetian's avatar
Weng Xuetian committed
48 49 50 51
set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -fvisibility=hidden ${CMAKE_C_FLAGS}")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-sign-compare -Wno-unused-parameter -fvisibility=hidden ${CMAKE_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined,--as-needed ${CMAKE_SHARED_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "-Wl,--no-undefined,--as-needed ${CMAKE_MODULE_LINKER_FLAGS}")
Weng Xuetian's avatar
Weng Xuetian committed
52

53 54 55 56
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" FCITX4_MAJOR_VERSION "${FCITX4_VERSION}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" FCITX4_MINOR_VERSION "${FCITX4_VERSION}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" FCITX4_PATCH_VERSION "${FCITX4_VERSION}")

57 58
EXECUTE_PROCESS(COMMAND "${FCITX4_FCITXCONFIG_EXECUTABLE}" --exec-prefix OUTPUT_VARIABLE FCITX4_EXEC_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)

Weng Xuetian's avatar
Weng Xuetian committed
59
set(package ${FCITX4_PACKAGE_NAME})
Weng Xuetian's avatar
Weng Xuetian committed
60 61 62 63
set(datadir ${CMAKE_INSTALL_PREFIX}/share)
set(localedir ${CMAKE_INSTALL_PREFIX}/share/locale)
set(exec_prefix "${CMAKE_INSTALL_PREFIX}/bin")

64 65 66 67 68 69 70 71 72 73
find_program(some_x_program NAMES iceauth xrdb xterm)
if (NOT some_x_program)
    set(some_x_program /usr/bin/xrdb)
    message("Warning: Could not determine X binary directory. Assuming /usr/bin.")
endif (NOT some_x_program)
get_filename_component(proto_xbindir "${some_x_program}" PATH)
get_filename_component(XBINDIR "${proto_xbindir}" ABSOLUTE)
get_filename_component(xrootdir "${XBINDIR}" PATH)
set(XLIBDIR "${xrootdir}/lib/X11")

Weng Xuetian's avatar
Weng Xuetian committed
74 75
configure_file(config.h.in config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
76 77 78 79 80 81 82 83 84 85 86
include_directories(
    ${FCITX4_FCITX_INCLUDE_DIRS}
    ${FCITX4_FCITX_UTILS_INCLUDE_DIRS}
    ${FCITX4_FCITX_CONFIG_INCLUDE_DIRS}
    )

link_directories(
    ${FCITX4_FCITX_LIBRARY_DIRS}
    ${FCITX4_FCITX_UTILS_LIBRARY_DIRS}
    ${FCITX4_FCITX_CONFIG_LIBRARY_DIRS}
    )
Weng Xuetian's avatar
Weng Xuetian committed
87

88
add_subdirectory(po)
Weng Xuetian's avatar
Weng Xuetian committed
89
add_subdirectory(src)
90
add_subdirectory(layout)