diff --git a/CMakeLists.txt b/CMakeLists.txt index 06c77fd..e7c79eb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,123 +1,128 @@ cmake_minimum_required(VERSION 3.5) set(KF5_VERSION "5.61.0") # handled by release scripts project(KI18n VERSION ${KF5_VERSION}) +if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) + conan_basic_setup(TARGETS) +endif() + # ECM setup include(FeatureSummary) find_package(ECM 5.60.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://projects.kde.org/projects/kdesupport/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR} ${KI18n_SOURCE_DIR}/cmake ${KI18n_BINARY_DIR}/cmake) include(GenerateExportHeader) include(CMakePackageConfigHelpers) include(ECMSetupVersion) include(ECMGenerateHeaders) include(ECMAddQch) ecm_setup_version( PROJECT VARIABLE_PREFIX KI18N VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/ki18n_version.h" PACKAGE_VERSION_FILE "${CMAKE_BINARY_DIR}/cmake/KF5I18nConfigVersion.cmake" SOVERSION 5) # Dependencies set(REQUIRED_QT_VERSION 5.11.0) find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core) option(BUILD_WITH_QML "Build with support for scripted translations (recommended)" ON) if (BUILD_WITH_QML) find_package(Qt5Qml ${REQUIRED_QT_VERSION} CONFIG REQUIRED) endif() include(KDEInstallDirs) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) find_package(LibIntl) set_package_properties(LibIntl PROPERTIES TYPE REQUIRED URL "http://gnuwin32.sourceforge.net/packages/libintl.htm" PURPOSE "Needed for building KI18n unless glibc is the system libc implementation" ) # KF5I18nMacros.cmake only needs to know the python executable path. # Due to CMake caching the variables, and KF5I18nMacros being included by KF5I18nConfig, # we have to hardcode the PYTHON_EXECUTABLE path or anything depending on KF5I18n # would be unable to find another Python version. find_package(PythonInterp REQUIRED) configure_file(cmake/KF5I18nMacros.cmake.in ${KI18n_BINARY_DIR}/cmake/KF5I18nMacros.cmake @ONLY) # Needed to build the ki18n translations and run the autotests file(COPY ${KI18n_SOURCE_DIR}/cmake/build-pofiles.cmake DESTINATION ${KI18n_BINARY_DIR}/cmake) file(COPY ${KI18n_SOURCE_DIR}/cmake/build-tsfiles.cmake DESTINATION ${KI18n_BINARY_DIR}/cmake) file(COPY ${KI18n_SOURCE_DIR}/cmake/ts-pmap-compile.py DESTINATION ${KI18n_BINARY_DIR}/cmake) file(COPY ${KI18n_SOURCE_DIR}/cmake/kf5i18nuic.cmake DESTINATION ${KI18n_BINARY_DIR}/cmake) # Create dummy file to execute find_package(KF5I18n) within autotests/ki18n_install file(WRITE ${CMAKE_BINARY_DIR}/cmake/KF5I18nTargets.cmake "") include(${KI18n_BINARY_DIR}/cmake/KF5I18nMacros.cmake) remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) if(MSVC) remove_definitions(-DQT_STRICT_ITERATORS) endif() option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF) add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)") add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00) add_definitions(-DQT_NO_FOREACH) if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po") ki18n_install(po) endif() add_subdirectory(src) if (BUILD_TESTING) add_subdirectory(autotests) endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/src/config.h") # create a Config.cmake and a ConfigVersion.cmake file and install them set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5I18n") if (BUILD_QCH) ecm_install_qch_export( TARGETS KF5I18n_QCH FILE "${CMAKE_BINARY_DIR}/cmake/KF5I18nQchTargets.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel ) set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5I18nQchTargets.cmake\")") endif() configure_package_config_file("${CMAKE_CURRENT_LIST_DIR}/KF5I18nConfig.cmake.in" "${CMAKE_BINARY_DIR}/cmake/KF5I18nConfig.cmake" INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} PATH_VARS KF5_INCLUDE_INSTALL_DIR LIB_INSTALL_DIR CMAKE_INSTALL_PREFIX) install(FILES "${CMAKE_BINARY_DIR}/cmake/KF5I18nConfig.cmake" "${CMAKE_BINARY_DIR}/cmake/KF5I18nConfigVersion.cmake" DESTINATION "${CMAKECONFIG_INSTALL_DIR}" COMPONENT Devel) install(EXPORT KF5I18nTargets DESTINATION "${CMAKECONFIG_INSTALL_DIR}" FILE KF5I18nTargets.cmake NAMESPACE KF5::) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ki18n_version.h DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel) install( FILES ${KI18n_BINARY_DIR}/cmake/KF5I18nMacros.cmake cmake/kf5i18nuic.cmake cmake/build-pofiles.cmake cmake/build-tsfiles.cmake cmake/ts-pmap-compile.py DESTINATION ${CMAKECONFIG_INSTALL_DIR} COMPONENT Devel ) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 7f5d022..f257fc3 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,49 +1,48 @@ remove_definitions(-DQT_NO_CAST_FROM_ASCII) include(ECMAddTests) -find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Test Qml Concurrent) +find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core Test Concurrent) -ecm_add_test(ki18ndeclarativetest.cpp - TEST_NAME "ki18n-declarativetest" - LINK_LIBRARIES Qt5::Test Qt5::Qml KF5::I18n -) +if (BUILD_WITH_QML) + find_package(Qt5Qml ${REQUIRED_QT_VERSION} CONFIG REQUIRED) +endif() ecm_add_test(klocalizedstringtest.cpp TEST_NAME "ki18n-klocalizedstringtest" LINK_LIBRARIES Qt5::Test Qt5::Concurrent KF5::I18n ${LibIntl_LIBRARIES} ) # klocalizedstringtest needs the libintl include path target_include_directories(ki18n-klocalizedstringtest PRIVATE ${LibIntl_INCLUDE_DIRS}) if (TARGET ktranscript) ecm_add_test(ktranscripttest.cpp testhelpers.cpp TEST_NAME "ki18n-ktranscripttest" LINK_LIBRARIES Qt5::Test KF5::I18n ) # ktranscripttest needs the path to ktranscript in the build dir: it cannot rely # on the installed version since it must be able to run *before* the plugin is # installed. target_compile_definitions(ki18n-ktranscripttest PRIVATE "KTRANSCRIPT_PATH=\"$\"") # ktranscriptcleantest needs to directly compile ktranscript.cpp with an addition DEFINE ecm_add_test(ktranscriptcleantest.cpp ../src/ktranscript.cpp ../src/common_helpers.cpp TEST_NAME ki18n-ktranscriptcleantest LINK_LIBRARIES Qt5::Qml Qt5::Test Qt5::Concurrent KF5::I18n ) target_compile_definitions(ki18n-ktranscriptcleantest PRIVATE "KTRANSCRIPT_TESTBUILD") target_include_directories(ki18n-ktranscriptcleantest PRIVATE ..) endif() add_test(ki18n_install ${CMAKE_CTEST_COMMAND} --build-and-test "${CMAKE_CURRENT_SOURCE_DIR}/ki18n_install" "${CMAKE_CURRENT_BINARY_DIR}/ki18n_install" --build-generator ${CMAKE_GENERATOR} --build-makeprogram ${CMAKE_MAKE_PROGRAM} --build-target install --build-options "-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}" "-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_CURRENT_BINARY_DIR}/ki18n_install/destdir" "-DKF5I18n_DIR=${CMAKE_BINARY_DIR}/cmake" --test-command ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/ki18n_install/test.cmake") diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..09b54c3 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,39 @@ +from conans import ConanFile, CMake, tools + + +class Ki18nConan(ConanFile): + name = "ki18n" + version = "5.61.0" + license = "GPLv2" + url = "https://api.kde.org/frameworks/ki18n/html/index.html" + description = "KDE Gettext-based UI text internationalization" + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + options = {"with_qml": [True, False]} + default_options = { "with_qml" : False} + + requires = ( + "extra-cmake-modules/[>=5.60.0]@kde/testing", # CMakeLists.txt requires 5.49.0 + "qt/[>=5.11.0]@bincrafters/stable", + "gettext_installer/0.20.1@bincrafters/stable" + ) + + scm = { + "type": "git", + "url": "auto", + "revision": "auto" + } + + def configure(self): + if self.options.with_qml: + self.options["qt"].qtdeclarative = True + + def build(self): + cmake = CMake(self) + cmake.definitions["BUILD_WITH_QML"] = "ON" if self.options.with_qml else "OFF" + cmake.configure() + cmake.build() + cmake.install() + + def package_info(self): + self.cpp_info.resdirs = ["share"]