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.18 FATAL_ERROR)
0008 
0009 project(kdiff3 VERSION 1.10.0)
0010 
0011 #Avaliable as QtVersionOption starting in ECM 5.82.
0012 option(BUILD_WITH_QT6 "Build against Qt 6" OFF)
0013 
0014 option(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE ON)
0015 option(CMAKE_CXX_EXTENSIONS ON ) #disable trigraphs in clang/gcc -- officially removed in c++17
0016 option(CMAKE_EXPORT_COMPILE_COMMANDS ON)
0017 
0018 if (BUILD_WITH_QT6)
0019     set(QT_MAJOR_VERSION "6")
0020     set(ECM_MIN_VERSION "5.82.0")
0021     set(QT_MIN_VERSION "6.0.0")
0022     set(KF5_MIN_VERSION "5.82.0")
0023 else()
0024     set(QT_MAJOR_VERSION "5")
0025     set(ECM_MIN_VERSION "5.70.0")
0026     set(QT_MIN_VERSION "5.15.2")
0027     set(KF5_MIN_VERSION "5.70.0")
0028 endif()
0029 
0030 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.2)
0031     message(WARNING "gcc < 8.2 is not recomended support is best effort-only.")
0032 endif()
0033 
0034 find_package(ECM ${ECM_MIN_VERSION} CONFIG REQUIRED)
0035 set(
0036     CMAKE_MODULE_PATH
0037     ${CMAKE_MODULE_PATH}
0038     ${ECM_MODULE_PATH}
0039 )
0040 
0041 if(BUILD_WITH_QT6)
0042     include(QtVersionOption)
0043     include(KDEInstallDirs5)
0044 else()
0045     include(KDEInstallDirs)
0046 endif()
0047 include(KDECompilerSettings NO_POLICY_SCOPE)
0048 include(KDECMakeSettings NO_POLICY_SCOPE)
0049 include(FeatureSummary)
0050 
0051 include(ECMInstallIcons)
0052 include(ECMAddAppIcon)
0053 include(ECMSetupVersion)
0054 include(ECMAddTests)
0055 include(ECMOptionalAddSubdirectory)
0056 
0057 ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX KDIFF3 VERSION_HEADER ${CMAKE_BINARY_DIR}/src/version.h)
0058 
0059 # Some older versions on boost contain a bug that prevents compiling gcc offers a built-in workaround
0060 # but that isn't enough to ship as clang has no such workaround. 1.65 is known to be affected.
0061 #
0062 # 1.71 or later is required for safe_numerics to work on MSVC otherwise we get a link-time error.
0063 find_package(Boost 1.71 REQUIRED)
0064 
0065 #needed on craft and possiablely other custom setups.
0066 include_directories(${Boost_INCLUDE_DIRS})
0067 
0068 find_package(
0069     Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION}
0070     CONFIG
0071     REQUIRED
0072     COMPONENTS
0073     Core
0074     Gui
0075     Widgets
0076     PrintSupport
0077 )
0078 
0079 if (QT_MAJOR_VERSION STREQUAL "6")
0080     find_package(Qt6Core5Compat)
0081 endif()
0082 
0083 find_package(
0084     KF5 ${KF5_MIN_VERSION}
0085     REQUIRED
0086     COMPONENTS
0087     I18n
0088     CoreAddons
0089     Parts
0090     WidgetsAddons
0091     Config
0092     OPTIONAL_COMPONENTS
0093     Crash
0094     DocTools
0095 )
0096 
0097 set_package_properties(KF5DocTools PROPERTIES PURPOSE "Allows generating and installing docs.")
0098 
0099 string(REPLACE "." ";" VERSION_LIST "${KF5_VERSION}")
0100 list(GET VERSION_LIST 0 KF_VERSION_MAJOR)
0101 list(GET VERSION_LIST 1 KF_VERSION_MINOR)
0102 list(GET VERSION_LIST 2 KF_VERSION_PATCH)
0103 
0104 option(ENABLE_AUTO "Enable kdiff3's '--auto' flag" ON)
0105 option(ENABLE_CLANG_TIDY "Run clang-tidy if available and cmake version >=3.6" OFF)
0106 
0107 set(CMAKE_CXX_STANDARD 17)
0108 
0109 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
0110     if(ENABLE_CLAZY)
0111         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")
0112     endif()
0113     #Adjust clang specific  warnings
0114     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wshadow -fexceptions")
0115     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")
0116     set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${CLANG_WARNING_FLAGS}")
0117 elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
0118     #Make MSVC obey standard C++ exception handling by destroying all objects going out of scope as a result of the exception.
0119     #This also separates a Microsoft specific exention SEH which catches non-c++ asynchronous exceptions.
0120     add_compile_options("/EHsc")
0121     #Suppress MSVCs min/max macros
0122     add_definitions(-DNOMINMAX)
0123     #Suppress Microsoft specfic C4996 "deprecatation" warnings. Not helpful for code intended to run on any other platform.
0124     add_definitions(-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS_GLOBALS)
0125     #force compliant use of __cplusplus
0126     add_compile_options("/Zc:__cplusplus")
0127 elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
0128     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-trigraphs -Wduplicated-cond -Wduplicated-branches -Wshadow -fexceptions")
0129 endif()
0130 
0131 #new in cmake 3.6+ integrate clang-tidy
0132 if(ENABLE_CLANG_TIDY)
0133     find_program(CLANG_TIDY_EXE NAMES "clang-tidy" DOC "Path to clang-tidy executable")
0134     if(NOT CLANG_TIDY_EXE)
0135         message(STATUS "clang-tidy not found disabling integration.")
0136     else()
0137         message(STATUS "Found clang-tidy: ${CLANG_TIDY_EXE}")
0138         set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}" "-header-filter=.*")
0139     endif()
0140 endif()
0141 
0142 set(CMAKE_C_FLAGS  "${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS}")
0143 
0144 if(ENABLE_AUTO)
0145     add_definitions(
0146         -DENABLE_AUTO
0147     )
0148 endif()
0149 
0150 add_definitions(
0151     -DQT_DEPRECATED_WARNINGS #Get warnings from QT about deprecated functions.
0152     -DQT_NO_URL_CAST_FROM_STRING # casting from string to url does not always behave as you might think
0153     -DQT_RESTRICTED_CAST_FROM_ASCII #casting from char*/QByteArray to QString can produce unexpected results for non-latin characters.
0154     -DQT_NO_KEYWORDS
0155     -DQT_NO_CAST_TO_ASCII
0156     -DQT_NO_PROCESS_COMBINED_ARGUMENT_START
0157     -DQT_DEPRECATED_WARNINGS_SINCE=0x050F00#warn if deprecated at 5.15 or before. Qt default setting is not useful for kdiff3.
0158     -DQT_DISABLE_DEPRECATED_BEFORE=0x050F00#disable deprecated api for Qt<5.15.
0159     #Boost 1.74 and possibly others trigger these warnings in boosts own internal headers making
0160     #the warning useless.
0161     -DBOOST_ALLOW_DEPRECATED_HEADERS
0162     #KF5 5.64+ flags
0163     #Don't warn for API depreciated after 5.86.0 (below as hex.hex.hex number)
0164     -DKF_DEPRECATED_WARNINGS_SINCE=0x056200
0165     -DKIOCORE_DEPRECATED_WARNINGS_SINCE=0x056200
0166     -DKXMLGUI_DEPRECATED_WARNINGS_SINCE=0x056200
0167     -DKF_VERSION_MAJOR=${KF_VERSION_MAJOR}
0168     -DKF_VERSION_MINOR=${KF_VERSION_MINOR}
0169     -DKF_VERSION_PATCH=${KF_VERSION_PATCH}
0170 )
0171 #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.
0172 if(${KF5Crash_FOUND})
0173     add_definitions(
0174         -DHAS_KFCRASH=1
0175     )
0176 endif()
0177 
0178 add_subdirectory(src)
0179 if(KF5DocTools_FOUND)
0180     ecm_optional_add_subdirectory(doc)
0181     kdoctools_install(po)
0182 else()
0183     message(WARNING "DocTools not found. Docs will not be generated.")
0184 endif()
0185 
0186 ki18n_install(po)
0187 
0188 add_subdirectory(kdiff3fileitemactionplugin)
0189 
0190 if(WIN32)
0191 add_subdirectory(diff_ext_for_kdiff3)
0192 endif()
0193 
0194 feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)