1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
#
# Copyright (C) 2013-2020 Mattia Basaglia
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
cmake_minimum_required (VERSION 3.1 FATAL_ERROR)
set(COLORWIDGET_PROJECT_NAME QtColorWidgets)
project(${COLORWIDGET_PROJECT_NAME} CXX)
set (CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules
${CMAKE_CURRENT_LIST_DIR})
include (CheckCXXCompilerFlag)
include (cmake/install.cmake)
include (cmake/qt-configuration.cmake)
include (cmake/versioning.cmake)
SET (${COLORWIDGET_PROJECT_NAME}_VERSION_MAJOR 2)
SET (${COLORWIDGET_PROJECT_NAME}_VERSION_MINOR 2)
SET (${COLORWIDGET_PROJECT_NAME}_VERSION_PATCH 0)
SET (${COLORWIDGET_PROJECT_NAME}_VERSION "${${COLORWIDGET_PROJECT_NAME}_VERSION_MAJOR}.${${COLORWIDGET_PROJECT_NAME}_VERSION_MINOR}.${${COLORWIDGET_PROJECT_NAME}_VERSION_PATCH}")
set (QT_SUPPORTED_VERSIONS 5)
select_qt (
QT_SUPPORTED_VERSIONS "${QT_SUPPORTED_VERSIONS}"
QT_DEFAULT_VERSION 5)
set (REQUIRED_QT_COMPONENTS
Widgets
)
find_qt (
QT_SUPPORTED_VERSIONS "${QT_SUPPORTED_VERSIONS}"
REQUIRED_COMPONENTS "${REQUIRED_QT_COMPONENTS}"
OPTIONAL_COMPONENTS "")
# Auto generate moc files
set(CMAKE_AUTOMOC ON)
# Auto generate moc files
set(CMAKE_AUTOUIC ON)
# Auto generate moc files
set(CMAKE_AUTORCC ON)
option(BUILD_SHARED_LIBS "Build the shared library" ON)
option(BUILD_STATIC_LIBS "Build the static library" OFF)
set (TARGET_NAME ${COLORWIDGET_PROJECT_NAME})
set (TARGET_OUTPUT_SUFFIX "")
set (INCLUDE_PREFIX "QtColorWidgets")
set (COLOR_WIDGETS_LIBRARY "${TARGET_NAME}")
if ( ${BUILD_STATIC_LIBS} )
add_definitions(-DQTCOLORWIDGETS_STATICALLY_LINKED)
endif()
add_library (${TARGET_NAME} "")
set_target_properties(${TARGET_NAME}
PROPERTIES
EXPORT_NAME "${TARGET_NAME}${TARGET_OUTPUT_SUFFIX}")
set_target_properties (${TARGET_NAME}
PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
VERSION ${${COLORWIDGET_PROJECT_NAME}_VERSION}
SOVERSION ${${COLORWIDGET_PROJECT_NAME}_VERSION_MAJOR}
"INTERFACE_${COLORWIDGET_PROJECT_NAME}_MAJOR_VERSION" ${${COLORWIDGET_PROJECT_NAME}_VERSION_MAJOR}
COMPATIBLE_INTERFACE_STRING "${COLORWIDGET_PROJECT_NAME}_MAJOR_VERSION"
COMPILE_DEFINITIONS QTCOLORWIDGETS_LIBRARY
OUTPUT_NAME "${TARGET_NAME}${TARGET_OUTPUT_SUFFIX}")
check_cxx_compiler_flag ("-Wall" Wall_FLAG_SUPPORTED)
if (Wall_FLAG_SUPPORTED)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall")
endif (Wall_FLAG_SUPPORTED)
check_cxx_compiler_flag ("-pedantic" pedantic_FLAG_SUPPORTED)
if (pedantic_FLAG_SUPPORTED)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pedantic")
endif (pedantic_FLAG_SUPPORTED)
check_cxx_compiler_flag ("-Wextra" Wextra_FLAG_SUPPORTED)
if (Wextra_FLAG_SUPPORTED)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wextra")
endif (Wextra_FLAG_SUPPORTED)
set (EXPORT_HEADER "${INCLUDE_PREFIX}/colorwidgets_global.hpp")
generate_versioning_information (
TARGET_NAME ${TARGET_NAME}
EXPORT_HEADER ${EXPORT_HEADER}
EXPORT_MACRO QCP_EXPORT
VERSIONED_ENTITY ${COLORWIDGET_PROJECT_NAME}
INCLUDE_PREFIX ${INCLUDE_PREFIX}
COMPANY_NAME "Mattia Basaglia"
COMPANY_COPYRIGHT "Mattia Basaglia Copyright (C) 2013-2017"
FILE_DESCRIPTION "Color wheel widget and dialog for Qt${QT_VERSION}"
)
target_include_directories(${TARGET_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PUBLIC
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>
)
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/include/${INCLUDE_PREFIX})
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/resources/${INCLUDE_PREFIX})
add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR}/src/${INCLUDE_PREFIX})
use_qt (
TARGET_NAME ${TARGET_NAME}
QT_SUPPORTED_VERSIONS "${QT_SUPPORTED_VERSIONS}"
REQUIRED_COMPONENTS "${REQUIRED_QT_COMPONENTS}"
OPTIONAL_COMPONENTS "")
install_project (
PROJECT_NAME ${COLORWIDGET_PROJECT_NAME}
TARGET_NAME ${TARGET_NAME}
EXPORT_HEADER ${EXPORT_HEADER}
INCLUDE_PREFIX ${INCLUDE_PREFIX}
HEADER_MATCHING_REGEX "^.*\.h$|^.*\.hpp$|^.*$"
VERSION_HEADER ${CMAKE_CURRENT_BINARY_DIR}/${COLORWIDGET_PROJECT_NAME}_version.h
NAMESPACE "")
add_subdirectory (gallery)
option(QTCOLORWIDGETS_DESIGNER_PLUGIN "Build QtDesigner plugin" ON)
if (${QTCOLORWIDGETS_DESIGNER_PLUGIN})
find_package (Qt5Designer QUIET)
if (Qt5Designer_FOUND)
add_subdirectory (color_widgets_designer_plugin)
endif(Qt5Designer_FOUND)
endif()
|