Warning, /graphics/glaxnimate/external/Qt-Color-Widgets/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 # SPDX-FileCopyrightText: 2013-2023 Mattia Basaglia <dev@dragon.best>
0002 # SPDX-License-Identifier: BSD-2-Clause
0003 
0004 cmake_minimum_required (VERSION 3.1...3.27 FATAL_ERROR)
0005 
0006 if ( ${CMAKE_VERSION} VERSION_GREATER "3.12.0")
0007     cmake_policy(SET CMP0077 NEW)
0008 endif()
0009 
0010 set(COLORWIDGET_PROJECT_NAME QtColorWidgets)
0011 project(${COLORWIDGET_PROJECT_NAME} CXX)
0012 
0013 
0014 set (CMAKE_MODULE_PATH
0015   ${CMAKE_MODULE_PATH}
0016   ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
0017   ${CMAKE_CURRENT_LIST_DIR})
0018 
0019 
0020 include (CheckCXXCompilerFlag)
0021 
0022 include (cmake/install.cmake)
0023 include (cmake/versioning.cmake)
0024 
0025 
0026 SET (${COLORWIDGET_PROJECT_NAME}_VERSION_MAJOR 2)
0027 SET (${COLORWIDGET_PROJECT_NAME}_VERSION_MINOR 2)
0028 SET (${COLORWIDGET_PROJECT_NAME}_VERSION_PATCH 0)
0029 SET (${COLORWIDGET_PROJECT_NAME}_VERSION "${${COLORWIDGET_PROJECT_NAME}_VERSION_MAJOR}.${${COLORWIDGET_PROJECT_NAME}_VERSION_MINOR}.${${COLORWIDGET_PROJECT_NAME}_VERSION_PATCH}")
0030 
0031 
0032 if(NOT QT_VERSION_MAJOR)
0033     set(QT_VERSION_MAJOR 5 CACHE STRING "Qt version to use (4, 5 or 6), defaults to 5")
0034 endif()
0035 find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Widgets REQUIRED)
0036 
0037 # These definitions do mostly match what with what KDE software uses
0038 # See https://api.kde.org/ecm/kde-module/KDECompilerSettings.html
0039 add_definitions(
0040     -DQT_NO_URL_CAST_FROM_STRING
0041     -DQT_NO_CAST_TO_ASCII
0042     -DQT_NO_CAST_FROM_ASCII
0043     -DQT_NO_FOREACH
0044     -DQT_NO_KEYWORDS
0045     -DQT_USE_QSTRINGBUILDER
0046     -DQT_NO_CAST_FROM_BYTEARRAY
0047     -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT
0048 )
0049 if (NOT WIN32)
0050     add_definitions(-DQT_STRICT_ITERATORS)
0051 endif()
0052 
0053 # Auto generate moc files
0054 set(CMAKE_AUTOMOC ON)
0055 # Auto generate moc files
0056 set(CMAKE_AUTOUIC ON)
0057 # Auto generate moc files
0058 set(CMAKE_AUTORCC ON)
0059 
0060 
0061 if ( BUILD_SHARED_LIBS )
0062     option(BUILD_STATIC_LIBS "Build the static library" OFF)
0063 else()
0064     option(BUILD_STATIC_LIBS "Build the static library" ON)
0065 endif()
0066 
0067 set (TARGET_NAME ${COLORWIDGET_PROJECT_NAME})
0068 option(COLOR_WIDGETS_QT_SUFFIX "Append qt version to the target output files" OFF)
0069 if ( COLOR_WIDGETS_QT_SUFFIX )
0070     set (TARGET_OUTPUT_SUFFIX "-Qt${QT_VERSION}${${COLORWIDGET_PROJECT_NAME}_VERSION_MAJOR}")
0071 else()
0072     set (TARGET_OUTPUT_SUFFIX "")
0073 endif()
0074 
0075 set (INCLUDE_PREFIX "QtColorWidgets")
0076 set (COLOR_WIDGETS_LIBRARY "${TARGET_NAME}")
0077 
0078 if ( ${BUILD_STATIC_LIBS} )
0079     add_definitions(-DQTCOLORWIDGETS_STATICALLY_LINKED)
0080     add_library (${TARGET_NAME} STATIC "")
0081 else()
0082     add_library (${TARGET_NAME} "")
0083 endif()
0084 
0085 
0086 set_target_properties(${TARGET_NAME}
0087   PROPERTIES
0088   EXPORT_NAME "${TARGET_NAME}${TARGET_OUTPUT_SUFFIX}")
0089 
0090 
0091 set_target_properties (${TARGET_NAME}
0092     PROPERTIES
0093     CXX_STANDARD 11
0094     CXX_STANDARD_REQUIRED ON
0095     VERSION ${${COLORWIDGET_PROJECT_NAME}_VERSION}
0096     SOVERSION ${${COLORWIDGET_PROJECT_NAME}_VERSION_MAJOR}
0097     "INTERFACE_${COLORWIDGET_PROJECT_NAME}_MAJOR_VERSION" ${${COLORWIDGET_PROJECT_NAME}_VERSION_MAJOR}
0098     COMPATIBLE_INTERFACE_STRING "${COLORWIDGET_PROJECT_NAME}_MAJOR_VERSION"
0099     COMPILE_DEFINITIONS QTCOLORWIDGETS_LIBRARY
0100     OUTPUT_NAME "${TARGET_NAME}${TARGET_OUTPUT_SUFFIX}")
0101 
0102 check_cxx_compiler_flag ("-Wall" Wall_FLAG_SUPPORTED)
0103 
0104 if (Wall_FLAG_SUPPORTED)
0105   set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
0106 endif (Wall_FLAG_SUPPORTED)
0107 
0108 check_cxx_compiler_flag ("-pedantic" pedantic_FLAG_SUPPORTED)
0109 
0110 if (pedantic_FLAG_SUPPORTED)
0111     set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pedantic")
0112 endif (pedantic_FLAG_SUPPORTED)
0113 
0114 check_cxx_compiler_flag ("-Wextra" Wextra_FLAG_SUPPORTED)
0115 
0116 if (Wextra_FLAG_SUPPORTED)
0117   set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wextra")
0118 endif (Wextra_FLAG_SUPPORTED)
0119 
0120 
0121 set (EXPORT_HEADER "${INCLUDE_PREFIX}/colorwidgets_global.hpp")
0122 
0123 
0124 generate_versioning_information (
0125     TARGET_NAME ${TARGET_NAME}
0126     EXPORT_HEADER ${EXPORT_HEADER}
0127     EXPORT_MACRO QCP_EXPORT
0128     VERSIONED_ENTITY ${COLORWIDGET_PROJECT_NAME}
0129     INCLUDE_PREFIX ${INCLUDE_PREFIX}
0130     COMPANY_NAME "Mattia Basaglia"
0131     COMPANY_COPYRIGHT "Mattia Basaglia Copyright (C) 2013-2020"
0132     FILE_DESCRIPTION "Color wheel widget and dialog for Qt${QT_VERSION}"
0133 )
0134 
0135 
0136 target_include_directories(${TARGET_NAME}
0137     PUBLIC
0138     $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
0139     $<INSTALL_INTERFACE:include>
0140     PUBLIC
0141     $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
0142     $<INSTALL_INTERFACE:include>
0143 )
0144 
0145 
0146 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/include/${INCLUDE_PREFIX})
0147 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/resources/${INCLUDE_PREFIX})
0148 add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/src/${INCLUDE_PREFIX})
0149 
0150 
0151 target_link_libraries (${TARGET_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
0152 
0153 
0154 install_project (
0155     PROJECT_NAME ${COLORWIDGET_PROJECT_NAME}
0156     TARGET_NAME ${TARGET_NAME}
0157     TARGET_OUTPUT_SUFFIX "${TARGET_OUTPUT_SUFFIX}"
0158     EXPORT_HEADER ${EXPORT_HEADER}
0159     INCLUDE_PREFIX ${INCLUDE_PREFIX}
0160     HEADER_MATCHING_REGEX "^.*\.h$|^.*\.hpp$|^.*$"
0161     VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${COLORWIDGET_PROJECT_NAME}_version.h
0162     NAMESPACE ""
0163 )
0164 
0165 
0166 add_subdirectory (gallery)
0167 
0168 option(QTCOLORWIDGETS_DESIGNER_PLUGIN "Build QtDesigner plugin" ON)
0169 if (${QTCOLORWIDGETS_DESIGNER_PLUGIN})
0170     find_package (Qt${QT_VERSION_MAJOR}Designer QUIET)
0171     if (Qt${QT_VERSION_MAJOR}Designer_FOUND)
0172         add_subdirectory (color_widgets_designer_plugin)
0173     endif(Qt${QT_VERSION_MAJOR}Designer_FOUND)
0174 endif()
0175 
0176 configure_file(Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
0177 add_custom_target(
0178     ${COLORWIDGET_PROJECT_NAME}_docs
0179     COMMAND doxygen Doxyfile
0180     COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/gallery/*.png ${CMAKE_CURRENT_BINARY_DIR}/doxygen/html
0181     WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
0182 )
0183