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

0001 
0002 cmake_minimum_required(VERSION 3.5)
0003 
0004 if (POLICY CMP0071)
0005   cmake_policy(SET CMP0071 NEW)
0006 endif()
0007 
0008 project(Grantlee5 VERSION 5.2.0)
0009 
0010 # Workaround for http://public.kitware.com/Bug/view.php?id=12301
0011 if (MINGW)
0012   if(NOT CMAKE_BUILD_TYPE)
0013     set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build,
0014   options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release
0015   RelWithDebInfo MinSizeRel Coverage." FORCE)
0016   endif()
0017 endif()
0018 
0019 option( BUILD_TEMPLATES "Build the Grantlee template library" TRUE )
0020 option( BUILD_TEXTDOCUMENT "Build the Grantlee textdocument library" TRUE )
0021 option( BUILD_MAIN_PLUGINS "Build the Grantlee Templates plugins" TRUE )
0022 option( BUILD_I18N_PLUGIN "Build the Grantlee Templates i18n plugin" TRUE )
0023 option( BUILD_TESTS "Build the Grantlee tests" TRUE )
0024 
0025 if (BUILD_TESTS)
0026   enable_testing()
0027 endif()
0028 
0029 set(Grantlee_MODULE_DIR ${CMAKE_SOURCE_DIR}/cmake/modules)
0030 list(APPEND CMAKE_MODULE_PATH ${Grantlee_MODULE_DIR})
0031 
0032 include(GenerateExportHeader)
0033 set(CMAKE_CXX_VISIBILITY_PRESET hidden)
0034 set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
0035 
0036 if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
0037   # create coverage build type
0038   set(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} Coverage )
0039   set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
0040                 "Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Coverage")
0041 endif()
0042 
0043 if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
0044   set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
0045   set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
0046   set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
0047 endif()
0048 
0049 if (CMAKE_COMPILER_IS_GNUCXX)
0050   set (CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
0051   set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-check-new -fno-common -pedantic-errors")
0052 
0053   if (NOT APPLE)
0054     set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
0055     set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}")
0056   endif ()
0057 endif()
0058 
0059 add_definitions(
0060   -DQT_NO_CAST_TO_ASCII
0061   -DQT_NO_CAST_FROM_ASCII
0062   -DQT_STRICT_ITERATORS
0063   -DQT_NO_URL_CAST_FROM_STRING
0064   -DQT_NO_CAST_FROM_BYTEARRAY
0065   -DQT_NO_KEYWORDS
0066   -DQT_USE_QSTRINGBUILDER
0067 )
0068 
0069 # Always include the source and build directories in the include path
0070 # to save doing so manually in every subdirectory.
0071 set(CMAKE_INCLUDE_CURRENT_DIR ON)
0072 set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
0073 set(CMAKE_AUTOMOC ON)
0074 
0075 set(Grantlee5_MIN_PLUGIN_VERSION 0)
0076 
0077 set(Grantlee5_MAJOR_MINOR_VERSION_STRING "${Grantlee5_VERSION_MAJOR}.${Grantlee5_VERSION_MINOR}" )
0078 
0079 set (LIB_SUFFIX "" CACHE STRING "Define suffix of library directory name (eg. '64')")
0080 
0081 set( LIB_INSTALL_DIR lib${LIB_SUFFIX} )
0082 set( PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR}/grantlee/${Grantlee5_MAJOR_MINOR_VERSION_STRING} )
0083 
0084 # set up RPATH/install_name_dir
0085 set( CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR})
0086 set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
0087 
0088 include("${Grantlee_MODULE_DIR}/GrantleeMacros.cmake")
0089 
0090 if (BUILD_TEMPLATES)
0091   add_subdirectory(templates)
0092 endif()
0093 
0094 if (BUILD_TEXTDOCUMENT)
0095   add_subdirectory(textdocument)
0096 endif()
0097 
0098 set(CMAKECONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/Grantlee${Grantlee5_VERSION_MAJOR}" )
0099 
0100 configure_file(
0101   "${Grantlee_MODULE_DIR}/Grantlee${Grantlee5_VERSION_MAJOR}Config.cmake.in"
0102   "${CMAKE_BINARY_DIR}/Grantlee${Grantlee5_VERSION_MAJOR}Config.cmake"
0103   @ONLY
0104 )
0105 
0106 include(CMakePackageConfigHelpers)
0107 write_basic_package_version_file("${CMAKE_BINARY_DIR}/Grantlee${Grantlee5_VERSION_MAJOR}ConfigVersion.cmake"
0108   VERSION ${Grantlee5_VERSION}
0109   COMPATIBILITY AnyNewerVersion
0110 )
0111 
0112 install(FILES
0113   "${CMAKE_BINARY_DIR}/Grantlee${Grantlee5_VERSION_MAJOR}Config.cmake"
0114   "${CMAKE_BINARY_DIR}/Grantlee${Grantlee5_VERSION_MAJOR}ConfigVersion.cmake"
0115   DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
0116   COMPONENT Common
0117 )
0118 
0119 install(FILES
0120   "${Grantlee_MODULE_DIR}/GrantleeMacros.cmake"
0121   DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
0122   COMPONENT Common
0123 )
0124 
0125 install(EXPORT grantlee_targets
0126   DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
0127   NAMESPACE Grantlee${Grantlee5_VERSION_MAJOR}::
0128   FILE GrantleeTargets.cmake
0129   COMPONENT Common
0130 )
0131 
0132 # Add support for an uninstall target
0133 configure_file(
0134   "${Grantlee_MODULE_DIR}/cmake_uninstall.cmake.in"
0135   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
0136   @ONLY)
0137 
0138 add_custom_target(uninstall
0139   "${CMAKE_COMMAND}" -P
0140   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
0141 
0142 find_package(Doxygen)
0143 if (DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
0144   message (STATUS "Doxygen and dot found. make docs target is available")
0145   # Add support for a docs target
0146 
0147   # Available from http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/libstdc++.tag
0148   set(STLTAGFILE "${CMAKE_SOURCE_DIR}/scripts/libstdc++.tag=http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen")
0149   find_file(qtcore_tag_file
0150     qtcore.tags
0151     HINTS
0152       "/usr/share/qt5/doc/qtcore"
0153     )
0154   set(QTTAGFILE "${qtcore_tag_file}=https://doc.qt.io/qt-5/")
0155 
0156   set(TAGFILES "${QTTAGFILE} ${STLTAGFILE}")
0157   set(DOCS_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
0158   configure_file(
0159     "${Grantlee_MODULE_DIR}/Doxyfile.in"
0160     "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile"
0161     @ONLY)
0162 
0163   # Add support for a Qt assistant docs target
0164   # qttags.tag is too big to distribute with Grantlee. Get it
0165   # from http://api.kde.org/kdereview-api/kdereview.tar.gz for example.
0166   if(EXISTS ${qtcore_tag_file})
0167     set(DOCS_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/qtdocs")
0168 
0169     # Available from http://steveire.com/libstdc++-longnames.tag
0170     # Also recommended: http://www.steveire.com/libstdc++-v3.qch
0171     set(STLTAGFILE "${CMAKE_SOURCE_DIR}/scripts/libstdc++-longnames.tag=qthelp://org.gnu.libstdcxx/libstdc++-v3/")
0172     set(QTTAGFILE "${qtcore_tag_file}=qthelp://org.qt-project.qtcore/qtcore/")
0173 
0174     set(TAGFILES "${QTTAGFILE} ${STLTAGFILE}")
0175     set(GENERATE_QHP "yes")
0176 
0177     configure_file(
0178       "${Grantlee_MODULE_DIR}/Doxyfile.in"
0179       "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.qt"
0180       @ONLY)
0181   endif()
0182 
0183   set( DOCS_ARGS ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" )
0184   if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.qt")
0185     set(DOCS_ARGS ${DOCS_ARGS} COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.qt" )
0186   endif()
0187 
0188   add_custom_target(docs
0189     ${DOCS_ARGS}
0190   )
0191 endif()
0192 
0193 find_package(LCov)
0194 
0195 if(LCOV_FOUND)
0196   get_property(UNITTESTS GLOBAL PROPERTY TEST_COVERAGE)
0197 
0198   set(coverageDir ${CMAKE_BINARY_DIR})
0199   set(coverage_ARGS)
0200 
0201   foreach(_testpath ${UNITTESTS})
0202     list(APPEND coverage_ARGS COMMAND ${LCOV_EXECUTABLE} -z -d ${coverageDir})
0203 
0204     get_filename_component(_test ${_testpath} NAME)
0205 
0206     list(APPEND coverage_ARGS COMMAND ${_testpath})
0207     list(APPEND coverage_ARGS COMMAND ${LCOV_EXECUTABLE} -c -t ${_test} -d ${coverageDir} -o ${CMAKE_BINARY_DIR}/test_${_test}.info)
0208     set(infoFiles ${infoFiles} -a ${CMAKE_BINARY_DIR}/test_${_test}.info)
0209   endforeach()
0210 
0211   list(APPEND coverage_ARGS COMMAND ${LCOV_EXECUTABLE} ${infoFiles} -o test_all.info)
0212 
0213   # For an unknown reason lcov does not work with absolute paths such as ${CMAKE_BINARY_DIR}
0214   file(RELATIVE_PATH relBinaryDir / ${CMAKE_BINARY_DIR})
0215 
0216   find_package(Qt5Core REQUIRED)
0217   get_property(qmake_loc TARGET Qt5::qmake PROPERTY LOCATION)
0218   execute_process(COMMAND "${qmake_loc}" -query QT_INSTALL_HEADERS
0219     RESULT_VARIABLE return_code
0220     OUTPUT_VARIABLE output
0221     OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)
0222   if(return_code)
0223     message(FATAL_ERROR "Problem")
0224   endif()
0225   file(TO_CMAKE_PATH "${output}" output)
0226   file(RELATIVE_PATH relQtDir / ${output})
0227   set(Qt4_exclude -r test_all.info *${relQtDir}*)
0228 
0229   list(APPEND coverage_ARGS COMMAND ${LCOV_EXECUTABLE} -r test_all.info *${relBinaryDir}*
0230                                                                 -r test_all.info *pluginpointer*
0231                                                                 -r test_all.info *usr/include*
0232                                                                 ${Qt4_exclude}
0233                                                                 -o test_all.info
0234   )
0235 
0236   list(APPEND coverage_ARGS COMMAND ${CMAKE_COMMAND} -E remove_directory coverage)
0237   list(APPEND coverage_ARGS COMMAND ${GENHTML_EXECUTABLE} -o coverage/ -s --demangle-cpp -f test_all.info --prefix ${CMAKE_SOURCE_DIR})
0238 
0239   add_custom_target(coverage
0240     ${coverage_ARGS}
0241   )
0242 endif()
0243 
0244 find_package(Cccc)
0245 if (CCCC_FOUND)
0246   macro(append_target_sources target)
0247     if (TARGET ${target})
0248       get_target_property(_tar_files ${target} SOURCES)
0249       foreach(f ${_tar_files})
0250         if(IS_ABSOLUTE f)
0251           list(APPEND target_files ${f})
0252         else()
0253           list(APPEND target_files ${${target}_SOURCE_DIR}/${f})
0254         endif()
0255       endforeach()
0256     endif()
0257   endmacro()
0258 
0259 
0260   append_target_sources(Grantlee_Templates)
0261   append_target_sources(Grantlee_TextDocument)
0262   append_target_sources(grantlee_defaultfilters)
0263   append_target_sources(grantlee_defaulttags)
0264   append_target_sources(grantlee_loadertags)
0265   append_target_sources(grantlee_i18ntags)
0266 
0267   set(cccc_ARGS ${CCCC_EXECUTABLE} ${target_files} --outdir=${CMAKE_BINARY_DIR}/cccc --html_outfile=${CMAKE_BINARY_DIR}/cccc/index.html)
0268 
0269   add_custom_target(cccc
0270     ${cccc_ARGS}
0271   )
0272 endif()
0273 
0274 # http://www.vtk.org/Wiki/CMake:Component_Install_With_CPack
0275 set(CPACK_PACKAGE_NAME "grantlee")
0276 set(CPACK_PACKAGE_VERSION_MAJOR ${Grantlee5_VERSION_MAJOR})
0277 set(CPACK_PACKAGE_VERSION_MINOR ${Grantlee5_VERSION_MINOR})
0278 set(CPACK_PACKAGE_VERSION_PATCH ${Grantlee5_VERSION_PATCH})
0279 set(CPACK_PACKAGE_CONTACT "Stephen Kelly <steveire@gmail.com>")
0280 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A set of frameworks for use with Qt")
0281 set(CPACK_GENERATOR "TGZ" )
0282 set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
0283 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.LIB")
0284 
0285 set(CPACK_COMPONENT_COMMON_DISPLAY_NAME "Grantlee Common files")
0286 set(CPACK_COMPONENT_TEMPLATES_DISPLAY_NAME "Grantlee String Templates")
0287 set(CPACK_COMPONENT_TEXTDOCUMENT_DISPLAY_NAME "Grantlee TextDocument framework")
0288 
0289 set(CPACK_COMPONENT_COMMON_DESCRIPTION
0290   "Files needed by all Grantlee frameworks")
0291 set(CPACK_COMPONENT_TEMPLATES_DESCRIPTION
0292   "A string template system for Qt based on Django syntax")
0293 set(CPACK_COMPONENT_TEXTDOCUMENT_DESCRIPTION
0294   "A framework for QTextDocument related tasks")
0295 
0296 set(CPACK_COMPONENT_TEMPLATES_DEPENDS Common)
0297 set(CPACK_COMPONENT_TEXTDOCUMENT_DEPENDS Common)
0298 set(CPACK_COMPONENT_COMMON_REQUIRED ON)
0299 
0300 set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
0301 
0302 if (WIN32)
0303   set(CPACK_NSIS_MODIFY_PATH ON)
0304   set(CPACK_GENERATOR ${CPACK_GENERATOR} "NSIS" )
0305 endif()
0306 
0307 include(CPack)