Warning, /sdk/kdiff3/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: 2002-2011 Joachim Eibl, joachim.eibl at gmx.de
0002 # SPDX-FileCopyrightText: 2018-2020 Michael Reeves reeves.87@gmail.com
0003 # SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #cmake < 3.1 has no sane way of checking C++11 features and needed flags
0006 #CMP0077 is defined in 3.13 or later
0007 cmake_minimum_required(VERSION 3.19 FATAL_ERROR)
0008 
0009 project(kdiff3 VERSION 1.11.0)
0010 
0011 #Avaliable as QtVersionOption starting in ECM 5.82.
0012 option(BUILD_WITH_QT6 "Build against Qt 6" OFF)
0013 
0014 set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE ON)
0015 set(CMAKE_CXX_EXTENSIONS ON ) #disable trigraphs in clang/gcc -- officially removed in c++17
0016 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
0017 set(CXX_STANDARD_REQUIRED ON)#Force early fail if we cann't get c++17.
0018 
0019 set(KF_MIN_VERSION "5.95.0")
0020 if (BUILD_WITH_QT6)
0021     set(QT_MAJOR_VERSION "6")
0022     set(QT_MIN_VERSION "6.5.0")
0023 else()
0024     set(QT_MAJOR_VERSION "5")
0025     set(QT_MIN_VERSION "5.15.5")
0026 endif()
0027 
0028 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.2)
0029     message(WARNING "gcc < 9.2 is not recomended support is best effort-only.")
0030 endif()
0031 
0032 find_package(ECM ${KF_MIN_VERSION} CONFIG REQUIRED)
0033 set(
0034     CMAKE_MODULE_PATH
0035     ${CMAKE_MODULE_PATH}
0036     ${ECM_MODULE_PATH}
0037 )
0038 
0039 if(BUILD_WITH_QT6)
0040     include(QtVersionOption)
0041     set(KF_MAJOR_VERSION "6")
0042 else()
0043     set(KF_MAJOR_VERSION "5")
0044 endif()
0045 
0046 # project uses settings default as of KDECompilerSettings in ECM 5.85.0
0047 set(KDE_QT_MODERNCODE_DEFINITIONS_LEVEL 5.85.0)
0048 set(KDE_COMPILERSETTINGS_LEVEL 5.85.0)
0049 # pedantic compilers are not supported at this time.
0050 set(KDE_SKIP_PEDANTIC_WARNINGS_SETTINGS TRUE)
0051 
0052 include(KDEInstallDirs)
0053 include(KDECompilerSettings NO_POLICY_SCOPE)
0054 include(KDECMakeSettings NO_POLICY_SCOPE)
0055 include(FeatureSummary)
0056 
0057 #Full QT_NO_CAST_FROM_ASCII is not compatiable with kdiff3 code and not worth inforcing
0058 #we use the slightly less strict QT_RESTRICTED_CAST_FROM_ASCII
0059 #Disallowing implict cast from QByteArray doesn't make sense for this project
0060 remove_definitions(-DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY)
0061 #Causes multiple build errors related to the use QLatin1String
0062 remove_definitions(-DQT_USE_QSTRINGBUILDER)
0063 
0064 include(ECMInstallIcons)
0065 include(ECMAddAppIcon)
0066 include(ECMSetupVersion)
0067 include(ECMAddTests)
0068 include(ECMOptionalAddSubdirectory)
0069 include(ECMSetupQtPluginMacroNames)
0070 
0071 ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX KDIFF3 VERSION_HEADER ${CMAKE_BINARY_DIR}/src/version.h)
0072 
0073 # Some older versions on boost contain a bug that prevents compiling gcc offers a built-in workaround
0074 # but that isn't enough to ship as clang has no such workaround. 1.65 is known to be affected.
0075 #
0076 # 1.71 or later is required for safe_numerics to work on MSVC otherwise we get a link-time error.
0077 find_package(Boost 1.71 REQUIRED)
0078 
0079 #needed on craft and possiablely other custom setups.
0080 include_directories(${Boost_INCLUDE_DIRS})
0081 
0082 find_package(
0083     Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION}
0084     CONFIG
0085     REQUIRED
0086     COMPONENTS
0087     Core
0088     Gui
0089     Widgets
0090     PrintSupport
0091 )
0092 
0093 if (QT_MAJOR_VERSION STREQUAL "6")
0094     find_package(Qt6Core5Compat)
0095     set(COMPATLIB Qt6::Core5Compat)
0096 endif()
0097 
0098 find_package(
0099     KF${KF_MAJOR_VERSION} ${KF_MIN_VERSION}
0100     REQUIRED
0101     COMPONENTS
0102     I18n
0103     CoreAddons
0104     XmlGui
0105     WidgetsAddons
0106     Config
0107     Crash
0108     KIO #Not fully ready for to build without KIO
0109     OPTIONAL_COMPONENTS
0110     DocTools
0111 )
0112 
0113 set_package_properties(KF${KF_MAJOR_VERSION}DocTools PROPERTIES PURPOSE "Allows generating and installing docs.")
0114 
0115 string(REPLACE "." ";" VERSION_LIST "${KF${KF_MAJOR_VERSION}_VERSION}")
0116 list(GET VERSION_LIST 0 KF_VERSION_MAJOR)
0117 list(GET VERSION_LIST 1 KF_VERSION_MINOR)
0118 list(GET VERSION_LIST 2 KF_VERSION_PATCH)
0119 
0120 option(ENABLE_AUTO "Enable kdiff3's '--auto' flag" ON)
0121 option(ENABLE_CLANG_TIDY "Run clang-tidy if available and cmake version >=3.6" OFF)
0122 option(ENABLE_GDBINDEX OFF)
0123 
0124 set(CMAKE_CXX_STANDARD 17)
0125 
0126 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
0127     if(ENABLE_CLAZY)
0128         set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -plugin-arg-clazy -Xclang level0,level1,no-overloaded-signal,auto-unexpected-qstringbuilder,unused-non-trivial-variable,returning-void-expression,isempty-vs-count,container-inside-loop,assert-with-side-effects")
0129     endif()
0130     #Adjust clang specific  warnings
0131     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow -fexceptions")
0132     set(CLANG_WARNING_FLAGS "-Wno-undef -Wno-trigraphs -Wno-invalid-pp-token -Wno-comment -Wshorten-64-to-32 -Wstring-conversion -Wc++11-narrowing -fstack-protector-all")
0133     set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${CLANG_WARNING_FLAGS}")
0134 elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
0135     #Make MSVC obey standard C++ exception handling by destroying all objects going out of scope as a result of the exception.
0136     #This also separates a Microsoft specific exention SEH which catches non-c++ asynchronous exceptions.
0137     add_compile_options("/EHsc")
0138     #Suppress MSVCs min/max macros
0139     add_definitions(-DNOMINMAX)
0140     #Suppress Microsoft specfic C4996 "deprecatation" warnings. Not helpful for code intended to run on any other platform.
0141     add_definitions(-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS_GLOBALS)
0142     #force compliant use of __cplusplus
0143     add_compile_options("/Zc:__cplusplus")
0144 elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
0145     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-trigraphs -Wduplicated-cond -Wduplicated-branches -Wshadow -fexceptions")
0146 endif()
0147 
0148 #new in cmake 3.6+ integrate clang-tidy
0149 if(ENABLE_CLANG_TIDY)
0150     find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable")
0151     if(NOT CLANG_TIDY_EXE)
0152         message(STATUS "clang-tidy not found disabling integration.")
0153     else()
0154         message(STATUS "Found clang-tidy: ${CLANG_TIDY_EXE}")
0155         set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}" "-header-filter=.*")
0156     endif()
0157 endif()
0158 
0159 set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
0160 
0161 if(ENABLE_AUTO)
0162     add_definitions(
0163         -DENABLE_AUTO
0164     )
0165 endif()
0166 
0167 add_definitions(
0168     -DBOOST_NO_CXX98_FUNCTION_BASE #Work around for Boost config bug fixed in 1.84
0169     -DQT_DEPRECATED_WARNINGS #Get warnings from QT about deprecated functions.
0170     -DQT_NO_URL_CAST_FROM_STRING # casting from string to url does not always behave as you might think
0171     -DQT_RESTRICTED_CAST_FROM_ASCII #casting from char*/QByteArray to QString can produce unexpected results for non-latin characters.
0172     -DQT_NO_KEYWORDS
0173     -DQT_NO_CAST_TO_ASCII
0174     -DQT_NO_PROCESS_COMBINED_ARGUMENT_START
0175     -DQT_DEPRECATED_WARNINGS_SINCE=0x050F00#warn if deprecated at 5.15 or before. Qt default setting is not useful for kdiff3.
0176     -DQT_DISABLE_DEPRECATED_BEFORE=0x050F00#disable deprecated api for Qt<5.15.
0177     #Boost 1.74 and possibly others trigger these warnings in boosts own internal headers making
0178     #the warning useless.
0179     -DBOOST_ALLOW_DEPRECATED_HEADERS
0180     #KF5 5.64+ flags
0181     #Don't warn for API depreciated after 5.104.0 (below as hex.hex.hex number)
0182     -DKF_DEPRECATED_WARNINGS_SINCE=0x056800
0183     -DKIOCORE_DEPRECATED_WARNINGS_SINCE=0x056800
0184     -DKXMLGUI_DEPRECATED_WARNINGS_SINCE=0x056800
0185     -DKF_VERSION_MAJOR=${KF_VERSION_MAJOR}
0186     -DKF_VERSION_MINOR=${KF_VERSION_MINOR}
0187     -DKF_VERSION_PATCH=${KF_VERSION_PATCH}
0188 )
0189 
0190 #The CMake boolean value is not properly translated if we assign the variable directly to a C/C++ define. clangd will catch this in sytax hightlighting other language servers may not.
0191 if(KF${KF_MAJOR_VERSION}KIO_FOUND)
0192     add_definitions(
0193         -DHAS_KFKIO=1
0194     )
0195 endif()
0196 
0197 add_subdirectory(src)
0198 if(KF${KF_MAJOR_VERSION}DocTools_FOUND)
0199     ecm_optional_add_subdirectory(doc)
0200     kdoctools_install(po)
0201 else()
0202     message(WARNING "DocTools not found. Docs will not be generated.")
0203 endif()
0204 
0205 ki18n_install(po)
0206 
0207 add_subdirectory(kdiff3fileitemactionplugin)
0208 
0209 if(WIN32)
0210 add_subdirectory(diff_ext_for_kdiff3)
0211 endif()
0212 
0213 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)