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.20 FATAL_ERROR)
0008 
0009 project(kdiff3 VERSION 1.11.70)
0010 
0011 #Avaliable as QtVersionOption starting in ECM 5.82.
0012 option(BUILD_WITH_QT6 "Build against Qt 6" ON)
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.110.0")
0020 if (BUILD_WITH_QT6)
0021     set(QT_MAJOR_VERSION "6")
0022     set(QT_MIN_VERSION "6.6.0")
0023 else()
0024     set(QT_MAJOR_VERSION "5")
0025     set(QT_MIN_VERSION "5.15.8")
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 # Change this to 1.84 when its more widely available
0078 find_package(Boost 1.80 REQUIRED)
0079 #add_definitions()
0080 #needed on craft and possiablely other custom setups.
0081 include_directories(${Boost_INCLUDE_DIRS})
0082 
0083 find_package(
0084     Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION}
0085     CONFIG
0086     REQUIRED
0087     COMPONENTS
0088     Core
0089     Gui
0090     Widgets
0091     PrintSupport
0092 )
0093 
0094 if (QT_MAJOR_VERSION STREQUAL "6")
0095     find_package(Qt6Core5Compat)
0096     set(COMPATLIB Qt6::Core5Compat)
0097 endif()
0098 
0099 find_package(
0100     KF${KF_MAJOR_VERSION} ${KF_MIN_VERSION}
0101     REQUIRED
0102     COMPONENTS
0103     I18n
0104     CoreAddons
0105     XmlGui
0106     WidgetsAddons
0107     Config
0108     Crash
0109     KIO #Not fully ready for to build without KIO
0110     OPTIONAL_COMPONENTS
0111     DocTools
0112 )
0113 
0114 set_package_properties(KF${KF_MAJOR_VERSION}DocTools PROPERTIES PURPOSE "Allows generating and installing docs.")
0115 
0116 string(REPLACE "." ";" VERSION_LIST "${KF${KF_MAJOR_VERSION}_VERSION}")
0117 list(GET VERSION_LIST 0 KF_VERSION_MAJOR)
0118 list(GET VERSION_LIST 1 KF_VERSION_MINOR)
0119 list(GET VERSION_LIST 2 KF_VERSION_PATCH)
0120 
0121 option(ENABLE_AUTO "Enable kdiff3's '--auto' flag" ON)
0122 option(ENABLE_CLANG_TIDY "Run clang-tidy if available and cmake version >=3.6" OFF)
0123 option(ENABLE_GDBINDEX OFF)
0124 
0125 set(CMAKE_CXX_STANDARD 17)
0126 
0127 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
0128     if(ENABLE_CLAZY)
0129         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")
0130     endif()
0131     #Adjust clang specific  warnings
0132     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow -fexceptions")
0133     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")
0134     set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${CLANG_WARNING_FLAGS}")
0135 elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
0136     #Make MSVC obey standard C++ exception handling by destroying all objects going out of scope as a result of the exception.
0137     #This also separates a Microsoft specific exention SEH which catches non-c++ asynchronous exceptions.
0138     add_compile_options("/EHsc")
0139     #Suppress MSVCs min/max macros
0140     add_definitions(-DNOMINMAX)
0141     #Suppress Microsoft specfic C4996 "deprecatation" warnings. Not helpful for code intended to run on any other platform.
0142     add_definitions(-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS_GLOBALS)
0143     #force compliant use of __cplusplus
0144     add_compile_options("/Zc:__cplusplus")
0145 elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
0146     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-trigraphs -Wduplicated-cond -Wduplicated-branches -Wshadow -fexceptions")
0147 endif()
0148 
0149 #new in cmake 3.6+ integrate clang-tidy
0150 if(ENABLE_CLANG_TIDY)
0151     find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable")
0152     if(NOT CLANG_TIDY_EXE)
0153         message(STATUS "clang-tidy not found disabling integration.")
0154     else()
0155         message(STATUS "Found clang-tidy: ${CLANG_TIDY_EXE}")
0156         set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}" "-header-filter=.*")
0157     endif()
0158 endif()
0159 
0160 set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
0161 
0162 if(ENABLE_AUTO)
0163     add_definitions(
0164         -DENABLE_AUTO
0165     )
0166 endif()
0167 
0168 add_definitions(
0169     -DBOOST_NO_CXX98_FUNCTION_BASE #since we use the header only portion of boost we can hard code this until the upstream fix gets more widely distributed
0170     -DQT_DEPRECATED_WARNINGS #Get warnings from QT about deprecated functions.
0171     -DQT_NO_URL_CAST_FROM_STRING # casting from string to url does not always behave as you might think
0172     -DQT_RESTRICTED_CAST_FROM_ASCII #casting from char*/QByteArray to QString can produce unexpected results for non-latin characters.
0173     -DQT_NO_KEYWORDS
0174     -DQT_NO_CAST_TO_ASCII
0175     -DQT_NO_PROCESS_COMBINED_ARGUMENT_START
0176     -DQT_DEPRECATED_WARNINGS_SINCE=0x060100#warn if deprecated at 6.1 or before. Qt default setting is not useful for kdiff3.
0177     -DQT_DISABLE_DEPRECATED_BEFORE=0x050F00#disable deprecated api for Qt<5.15.
0178     #Boost 1.74 and possibly others trigger these warnings in boosts own internal headers making
0179     #the warning useless.
0180     -DBOOST_ALLOW_DEPRECATED_HEADERS
0181     #KF5 5.64+ flags
0182     #Don't warn for API depreciated after 5.110.0 (below as hex.hex.hex number)
0183     -DKF_DISABLE_DEPRECATED_BEFORE=0x056E00#disable deprecated api for KF 5.110.
0184     -DKF_DEPRECATED_WARNINGS_SINCE=0x056E00
0185     -DKIOCORE_DEPRECATED_WARNINGS_SINCE=0x056E00
0186     -DKXMLGUI_DEPRECATED_WARNINGS_SINCE=0x056E00
0187     -DKF_VERSION_MAJOR=${KF_VERSION_MAJOR}
0188     -DKF_VERSION_MINOR=${KF_VERSION_MINOR}
0189     -DKF_VERSION_PATCH=${KF_VERSION_PATCH}
0190 )
0191 
0192 #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.
0193 if(KF${KF_MAJOR_VERSION}KIO_FOUND)
0194     add_definitions(
0195         -DHAS_KFKIO=1
0196     )
0197 endif()
0198 
0199 add_subdirectory(src)
0200 if(KF${KF_MAJOR_VERSION}DocTools_FOUND)
0201     ecm_optional_add_subdirectory(doc)
0202     kdoctools_install(po)
0203 else()
0204     message(WARNING "DocTools not found. Docs will not be generated.")
0205 endif()
0206 
0207 ki18n_install(po)
0208 
0209 add_subdirectory(kdiff3fileitemactionplugin)
0210 
0211 if(WIN32)
0212 add_subdirectory(diff_ext_for_kdiff3)
0213 endif()
0214 
0215 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)