2018-10-24 13:20:27 +00:00
include ( CMakePackageConfigHelpers )
# Install locations:
set ( INSTALL_BINDIR "bin" CACHE PATH "Executables [PREFIX/bin]" )
set ( INSTALL_INCLUDEDIR "include" CACHE PATH "Header files [PREFIX/include]" )
set ( INSTALL_LIBDIR "lib" CACHE PATH "Libraries [PREFIX/lib]" )
set ( INSTALL_ARCHDATADIR "." CACHE PATH "Arch-dependent data [PREFIX]" )
set ( INSTALL_PLUGINSDIR "${INSTALL_ARCHDATADIR}/plugins" CACHE PATH
" P l u g i n s [ A R C H D A T A D I R / p l u g i n s ] " )
set ( INSTALL_TARGETS_DEFAULT_ARGS
R U N T I M E D E S T I N A T I O N " $ { I N S T A L L _ B I N D I R } "
L I B R A R Y D E S T I N A T I O N " $ { I N S T A L L _ L I B D I R } "
A R C H I V E D E S T I N A T I O N " $ { I N S T A L L _ L I B D I R } " C O M P O N E N T D e v e l
I N C L U D E S D E S T I N A T I O N " $ { I N S T A L L _ I N C L U D E D I R } "
)
if ( WIN32 )
set ( _default_libexec "${INSTALL_ARCHDATADIR}/bin" )
else ( )
set ( _default_libexec "${INSTALL_ARCHDATADIR}/libexec" )
endif ( )
set ( INSTALL_LIBEXECDIR "${_default_libexec}" CACHE PATH
" H e l p e r p r o g r a m s [ A R C H D A T A D I R / b i n o n W i n d o w s , A R C H D A T A D I R / l i b e x e c o t h e r w i s e ] " )
set ( INSTALL_IMPORTDIR "${INSTALL_ARCHDATADIR}/imports" CACHE PATH
" Q M L 1 i m p o r t s [ A R C H D A T A D I R / i m p o r t s ] " )
set ( INSTALL_QMLDIR "${INSTALL_ARCHDATADIR}/qml" CACHE PATH
" Q M L 2 i m p o r t s [ A R C H D A T A D I R / q m l ] " )
set ( INSTALL_DATADIR "." CACHE PATH "Arch-independent data [PREFIX]" )
set ( INSTALL_DOCDIR "${INSTALL_DATADIR}/doc" CACHE PATH "Documentation [DATADIR/doc]" )
set ( INSTALL_TRANSLATIONSDIR "${INSTALL_DATADIR}/translations" CACHE PATH
" T r a n s l a t i o n s [ D A T A D I R / t r a n s l a t i o n s ] " )
set ( INSTALL_SYSCONFDIR "etc/xdg" CACHE PATH
" S e t t i n g s u s e d b y Q t p r o g r a m s [ P R E F I X / e t c / x d g ] " )
set ( INSTALL_EXAMPLESDIR "examples" CACHE PATH "Examples [PREFIX/examples]" )
set ( INSTALL_TESTSDIR "tests" CACHE PATH "Tests [PREFIX/tests]" )
2019-02-11 10:34:35 +00:00
set ( INSTALL_CMAKE_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}" CACHE STRING "CMake namespace [Qt${PROJECT_VERSION_MAJOR}]" )
2019-02-12 09:02:15 +00:00
set ( QT_CMAKE_EXPORT_NAMESPACE "Qt${PROJECT_VERSION_MAJOR}" CACHE STRING "CMake namespace used when exporting targets [Qt${PROJECT_VERSION_MAJOR}]" )
2019-02-13 08:45:18 +00:00
set ( QT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}" )
2019-02-12 09:02:15 +00:00
2019-02-11 14:45:56 +00:00
# the default RPATH to be used when installing, but only if it's not a system directory
LIST ( FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir )
IF ( "${isSystemDir}" STREQUAL "-1" )
SET ( _default_install_rpath "${CMAKE_INSTALL_PREFIX}/lib" )
ENDIF ( "${isSystemDir}" STREQUAL "-1" )
# Default rpath settings: Use rpath for build tree as well as a full path for the installed binaries.
# For origin builds, one needs to override CMAKE_INSTALL_RPATH for example with $ORIGIN/../lib
SET ( CMAKE_INSTALL_RPATH "${_default_install_rpath}" CACHE PATH "RPATH for installed binaries" )
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET ( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
2018-10-24 13:20:27 +00:00
# Platform define path, etc.
if ( WIN32 )
set ( QT_DEFAULT_PLATFORM_DEFINITIONS UNICODE _UNICODE WIN32 _ENABLE_EXTENDED_ALIGNED_STORAGE )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
list ( APPEND QT_DEFAULT_PLATFORM_DEFINITIONS WIN64 _WIN64 )
endif ( )
if ( MSVC )
set ( QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/win32-msvc )
elseif ( CLANG )
set ( QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/win32-clang )
endif ( )
elseif ( LINUX )
if ( GCC )
set ( QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/linux-g++ )
elseif ( CLANG )
set ( QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/linux-clang )
endif ( )
elseif ( APPLE )
set ( QT_DEFAULT_PLATFORM_DEFINITION_DIR mkspecs/macx-clang )
endif ( )
if ( NOT DEFINED QT_DEFAULT_PLATFORM_DEFINITIONS )
set ( QT_DEFAULT_PLATFORM_DEFINITIONS "" )
endif ( )
set ( QT_PLATFORM_DEFINITIONS ${ QT_DEFAULT_PLATFORM_DEFINITIONS }
C A C H E S T R I N G " Q t p l a t f o r m s p e c i f i c p r e - p r o c e s s o r d e f i n e s " )
set ( QT_PLATFORM_DEFINITION_DIR ${ QT_DEFAULT_PLATFORM_DEFINITION_DIR }
C A C H E P A T H " P a t h t o d i r e c t o r y t h a t c o n t a i n s q p l a t f o r m d e f s . h " )
set ( QT_NAMESPACE "" CACHE STRING "Qt Namespace" )
2019-01-30 15:31:06 +00:00
if ( QT_NAMESPACE STREQUAL "" )
set ( QT_HAS_NAMESPACE OFF )
else ( )
set ( QT_HAS_NAMESPACE ON )
endif ( )
2018-10-24 13:20:27 +00:00
2018-12-07 13:04:42 +00:00
macro ( qt_internal_set_known_qt_modules )
2018-11-08 21:29:54 +00:00
set ( KNOWN_QT_MODULES ${ ARGN } CACHE INTERNAL "Known Qt modules" FORCE )
endmacro ( )
2018-10-24 13:20:27 +00:00
2018-11-08 21:29:54 +00:00
# Reset:
2018-12-07 13:04:42 +00:00
qt_internal_set_known_qt_modules ( "" )
2018-10-24 13:20:27 +00:00
# For adjusting variables when running tests, we need to know what
# the correct variable is for separating entries in PATH-alike
# variables.
if ( CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows" )
set ( QT_PATH_SEPARATOR "\\;" )
else ( )
set ( QT_PATH_SEPARATOR ":" )
endif ( )
# Functions and macros:
# Print all variables defined in the current scope.
macro ( qt_debug_print_variables )
cmake_parse_arguments ( __arg "DEDUP" "" "MATCH;IGNORE" ${ ARGN } )
message ( "Known Variables:" )
get_cmake_property ( __variableNames VARIABLES )
list ( SORT __variableNames )
if ( __arg_DEDUP )
list ( REMOVE_DUPLICATES __variableNames )
endif ( )
foreach ( __var ${ __variableNames } )
set ( __ignore OFF )
foreach ( __i ${ __arg_IGNORE } )
if ( __var MATCHES "${__i}" )
set ( __ignore ON )
break ( )
endif ( )
endforeach ( )
if ( __ignore )
continue ( )
endif ( )
set ( __show OFF )
foreach ( __i ${ __arg_MATCH } )
if ( __var MATCHES "${__i}" )
set ( __show ON )
break ( )
endif ( )
endforeach ( )
if ( __show )
message ( " ${__var}=${${__var}}." )
endif ( )
endforeach ( )
endmacro ( )
macro ( assert )
if ( ${ ARGN } )
else ( )
message ( FATAL_ERROR "ASSERT: ${ARGN}." )
endif ( )
endmacro ( )
2019-03-28 14:25:17 +00:00
function ( qt_create_nolink_target target )
if ( NOT TARGET "${target}" )
message ( FATAL_ERROR "${target} does not exist when trying to build a nolink target." )
endif ( )
get_target_property ( type "${target}" TYPE )
if ( type STREQUAL EXECUTABLE )
message ( FATAL_ERROR "${target} must be a library of some kind." )
endif ( )
if ( type STREQUAL OBJECT_LIBRARY )
message ( FATAL_ERROR "${target} must not be an object library." )
endif ( )
set ( nolink_target "${target}_nolink" )
if ( NOT TARGET "${nolink_target}" )
string ( REPLACE ":" "_" base_target "__${nolink_target}" )
add_library ( "${base_target}" INTERFACE )
target_include_directories ( "${base_target}" INTERFACE
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ I N C L U D E _ D I R E C T O R I E S > )
target_include_directories ( "${base_target}" INTERFACE SYSTEM
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ S Y S T E M _ I N C L U D E _ D I R E C T O R I E S > )
target_compile_definitions ( "${base_target}" INTERFACE
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ C O M P I L E _ D E F I N I T I O N S > )
target_compile_options ( "${base_target}" INTERFACE
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ C O M P I L E _ O P T I O N S > )
target_compile_features ( "${base_target}" INTERFACE
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N T E R F A C E _ C O M P I L E _ F E A T U R E S > )
add_library ( "${nolink_target}" ALIAS "${base_target}" )
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
function ( qt_ensure_perl )
if ( DEFINED HOST_PERL )
return ( )
endif ( )
find_program ( HOST_PERL "perl" DOC "Perl binary" )
if ( NOT HOST_PERL )
message ( FATAL_ERROR "Perl needs to be available to build Qt." )
endif ( )
endfunction ( )
2018-12-07 13:04:42 +00:00
function ( qt_ensure_sync_qt )
qt_ensure_perl ( )
2019-02-12 21:39:35 +00:00
if ( DEFINED QT_SYNCQT )
return ( )
2018-12-07 13:04:42 +00:00
endif ( )
2019-02-12 21:39:35 +00:00
get_target_property ( mocPath "${QT_CMAKE_EXPORT_NAMESPACE}::moc" LOCATION )
get_filename_component ( binDirectory "${mocPath}" DIRECTORY )
# We could put this into the cache, but on the other hand there's no real need to
# pollute the app's cache with this. For the first qtbase build, the variable is
# set in global scope.
set ( QT_SYNCQT "${binDirectory}/syncqt.pl" CACHE FILEPATH "syncqt script" )
2018-12-07 13:04:42 +00:00
endfunction ( )
2018-10-24 13:20:27 +00:00
# A version of cmake_parse_arguments that makes sure all arguments are processed and errors out
# with a message about ${type} having received unknown arguments.
macro ( qt_parse_all_arguments result type flags options multiopts )
cmake_parse_arguments ( ${ result } "${flags}" "${options}" "${multiopts}" ${ ARGN } )
if ( DEFINED ${ result } _UNPARSED_ARGUMENTS )
message ( FATAL_ERROR "Unknown arguments were passed to ${type} (${${result}_UNPARSED_ARGUMENTS})." )
endif ( )
endmacro ( )
2019-02-27 12:49:04 +00:00
function ( qt_internal_add_link_flags_no_undefined target )
if ( GCC OR CLANG )
if ( APPLE )
set ( no_undefined_flag "-Wl,-undefined,error" )
elseif ( LINUX )
set ( no_undefined_flag "-Wl,--no-undefined" )
else ( )
message ( FATAL_ERROR "Platform linker doesn't support erroring upon encountering undefined symbols. Target:\" ${ target } \".")
endif ( )
2019-03-04 12:05:54 +00:00
target_link_options ( "${target}" PRIVATE "${no_undefined_flag}" )
endif ( )
endfunction ( )
function ( qt_internal_add_link_flags_gc_sections target visibility )
set ( possible_visibilities PRIVATE INTERFACE PUBLIC )
list ( FIND possible_visibilities "${visibility}" known_visibility )
if ( known_visibility EQUAL "-1" )
message ( FATAL_ERROR "Visibitily setting must be one of PRIVATE, INTERFACE or PUBLIC." )
endif ( )
if ( GCC OR CLANG )
if ( APPLE )
set ( gc_sections_flag "-Wl,-dead_strip" )
elseif ( LINUX OR BSD OR SOLARIS OR WIN32 )
set ( gc_sections_flag "-Wl,--gc-sections" )
else ( )
message ( FATAL_ERROR "Platform linker doesn't support gc sections. Target:\" ${ target } \".")
endif ( )
target_link_options ( "${target}" ${ visibility } "${gc_sections_flag}" )
2019-02-27 12:49:04 +00:00
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
function ( qt_internal_add_linker_version_script target )
2018-12-07 12:13:24 +00:00
qt_parse_all_arguments ( arg "qt_internal_add_linker" "INTERNAL" "" "PRIVATE_HEADERS" ${ ARGN } )
2018-10-24 13:20:27 +00:00
if ( TEST_ld_version_script )
2018-12-07 12:13:24 +00:00
if ( arg_INTERNAL )
2018-10-24 13:20:27 +00:00
set ( contents "Qt_${PROJECT_VERSION_MAJOR}_PRIVATE_API { *; };" )
else ( )
set ( contents "Qt_${PROJECT_VERSION_MAJOR}_PRIVATE_API {\n qt_private_api_tag*;\n" )
2018-12-07 12:13:24 +00:00
foreach ( ph ${ arg_PRIVATE_HEADERS } )
2018-10-24 13:20:27 +00:00
string ( APPEND contents " @FILE:${ph}@\n" )
endforeach ( )
string ( APPEND contents "};\n" )
set ( current "Qt_${PROJECT_VERSION_MAJOR}" )
if ( QT_NAMESPACE STREQUAL "" )
set ( tag_symbol "qt_version_tag" )
else ( )
set ( tag_symbol "qt_version_tag_${QT_NAMESPACE}" )
endif ( )
string ( APPEND contents "${current} { *; };\n" )
foreach ( minor_version RANGE ${ PROJECT_VERSION_MINOR } )
set ( previous "${current}" )
set ( current "Qt_${PROJECT_VERSION_MAJOR}.${minor_version}" )
if ( minor_version EQUAL ${ PROJECT_VERSION_MINOR } )
string ( APPEND contents "${current} { ${tag_symbol}; } ${previous};\n" )
else ( )
string ( APPEND contents "${current} {} ${previous};\n" )
endif ( )
endforeach ( )
set ( infile "${CMAKE_CURRENT_BINARY_DIR}/${target}.version.in" )
set ( outfile "${CMAKE_CURRENT_BINARY_DIR}/${target}.version" )
file ( GENERATE OUTPUT "${infile}" CONTENT "${contents}" )
qt_ensure_perl ( )
add_custom_command ( TARGET "${target}" PRE_LINK
C O M M A N D " $ { H O S T _ P E R L } " " $ { P R O J E C T _ S O U R C E _ D I R } / m k s p e c s / f e a t u r e s / d a t a / u n i x / f i n d c l a s s l i s t . p l " < " $ { i n f i l e } " > " $ { o u t f i l e } "
B Y P R O D U C T S " $ { o u t f i l e } " D E P E N D S " $ { i n f i l e } "
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
C O M M E N T " G e n e r a t i n g v e r s i o n l i n k e r s c r i p t "
)
2019-03-04 12:05:54 +00:00
target_link_options ( "${target}" PRIVATE "-Wl,--version-script,${outfile}" )
2018-10-24 13:20:27 +00:00
endif ( )
endif ( )
endfunction ( )
2018-12-07 12:30:51 +00:00
# Get a set of Qt module related values based on the target name.
# When doing qt_internal_module_info(foo Core) this method will set
# the following variables in the caller's scope:
# * foo with the value "QtCore"
# * foo_versioned with the value "Qt5Core" (based on major Qt version)
# * foo_upper with the value "CORE"
# * foo_lower with the value "core"
2018-12-07 13:04:42 +00:00
# * foo_include_dir with the module's include directory in the binary tree
2018-12-07 12:30:51 +00:00
function ( qt_internal_module_info result target )
2018-12-07 13:04:42 +00:00
set ( module "Qt${target}" )
set ( "${result}" "${module}" PARENT_SCOPE )
2018-12-07 12:30:51 +00:00
set ( "${result}_versioned" "Qt${PROJECT_VERSION_MAJOR}${target}" PARENT_SCOPE )
string ( TOUPPER "${target}" upper )
string ( TOLOWER "${target}" lower )
set ( "${result}_upper" "${upper}" PARENT_SCOPE )
set ( "${result}_lower" "${lower}" PARENT_SCOPE )
2018-12-07 13:04:42 +00:00
set ( "${result}_include_dir" "${PROJECT_BINARY_DIR}/include/${module}" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-03-06 12:51:38 +00:00
set ( __default_private_args "SOURCES;LIBRARIES;INCLUDE_DIRECTORIES;DEFINES;DBUS_ADAPTOR_BASENAME;DBUS_ADAPTOR_FLAGS;DBUS_ADAPTOR_SOURCES;DBUS_INTERFACE_BASENAME;DBUS_INTERFACE_FLAGS;DBUS_INTERFACE_SOURCES;FEATURE_DEPENDENCIES;COMPILE_OPTIONS;LINK_OPTIONS;MOC_OPTIONS;DISABLE_AUTOGEN_TOOLS" )
2019-01-29 11:07:24 +00:00
set ( __default_public_args "PUBLIC_LIBRARIES;PUBLIC_INCLUDE_DIRECTORIES;PUBLIC_DEFINES;PUBLIC_COMPILE_OPTIONS;PUBLIC_LINK_OPTIONS" )
2018-10-24 13:20:27 +00:00
2019-01-30 15:36:30 +00:00
option ( QT_CMAKE_DEBUG_EXTEND_TARGET "Debug extend_target calls in Qt's build system" OFF )
2019-03-06 12:51:38 +00:00
# This function checks which autotools should be used: AUTOMOC/UIC/RCC
function ( qt_autogen_tools target )
qt_parse_all_arguments ( arg "qt_autogen_tools" "" "" "${__default_private_args}" ${ ARGN } )
set_property ( TARGET "${target}" PROPERTY INTERFACE_QT_MAJOR_VERSION ${ PROJECT_VERSION_MAJOR } )
set_property ( TARGET "${target}" APPEND PROPERTY
C O M P A T I B L E _ I N T E R F A C E _ S T R I N G Q T _ M A J O R _ V E R S I O N
)
list ( APPEND autogen_tools "moc" "uic" "rcc" )
if ( arg_DISABLE_AUTOGEN_TOOLS )
foreach ( disable_tool ${ arg_DISABLE_AUTOGEN_TOOLS } )
list ( REMOVE_ITEM autogen_tools "${disable_tool}" )
endforeach ( )
endif ( )
foreach ( autogen_tool ${ autogen_tools } )
string ( TOUPPER "${autogen_tool}" captitalAutogenTool )
set_target_properties ( "${target}"
P R O P E R T I E S
A U T O $ { c a p t i t a l A u t o g e n T o o l } O N
A U T O $ { c a p t i t a l A u t o g e n T o o l } _ E X E C U T A B L E " $ < T A R G E T _ F I L E : Q t : : $ { a u t o g e n _ t o o l } > " )
2019-03-22 14:17:02 +00:00
set_property ( TARGET ${ target } APPEND PROPERTY AUTOGEN_TARGET_DEPENDS Qt:: ${ autogen_tool } )
2019-03-06 12:51:38 +00:00
endforeach ( )
set_directory_properties ( PROPERTIES
Q T _ V E R S I O N _ M A J O R $ { P R O J E C T _ V E R S I O N _ M A J O R }
Q T _ V E R S I O N _ M I N O R $ { P R O J E C T _ V E R S I O N _ M I N O R } )
endfunction ( )
2018-10-24 13:20:27 +00:00
# This function can be used to add sources/libraries/etc. to the specified CMake target
# if the provided CONDITION evaluates to true.
function ( extend_target target )
if ( NOT TARGET "${target}" )
message ( FATAL_ERROR "Trying to extend non-existing target \" ${ target } \".")
endif ( )
2018-12-07 12:13:24 +00:00
qt_parse_all_arguments ( arg "extend_target" "" ""
2018-10-24 13:20:27 +00:00
" C O N D I T I O N ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } ; $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; C O M P I L E _ F L A G S " $ { A R G N } )
2018-12-07 12:13:24 +00:00
if ( "x${arg_CONDITION}" STREQUAL x )
set ( arg_CONDITION ON )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-07 12:13:24 +00:00
qt_evaluate_config_expression ( result ${ arg_CONDITION } )
2018-10-24 13:20:27 +00:00
if ( ${ result } )
2019-01-30 15:36:30 +00:00
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
message ( "extend_target(${target} CONDITION ${arg_CONDITION} ...): Evaluated" )
endif ( )
2018-10-29 15:53:51 +00:00
set ( dbus_sources "" )
2018-12-07 12:13:24 +00:00
foreach ( adaptor ${ arg_DBUS_ADAPTOR_SOURCES } )
2019-01-30 13:06:48 +00:00
qt_create_qdbusxml2cpp_command ( "${target}" "${adaptor}" ADAPTOR BASENAME "${arg_DBUS_ADAPTOR_BASENAME}" FLAGS "${arg_DBUS_ADAPTOR_FLAGS}" )
2018-10-29 15:53:51 +00:00
list ( APPEND dbus_sources "${sources}" )
endforeach ( )
2018-12-11 10:38:20 +00:00
2018-12-07 12:13:24 +00:00
foreach ( interface ${ arg_DBUS_INTERFACE_SOURCES } )
2019-01-30 13:06:48 +00:00
qt_create_qdbusxml2cpp_command ( "${target}" "${interface}" INTERFACE BASENAME "${arg_DBUS_INTERFACE_BASENAME}" FLAGS "${arg_DBUS_INTERFACE_FLAGS}" )
2018-10-29 15:53:51 +00:00
list ( APPEND dbus_sources "${sources}" )
endforeach ( )
2018-10-24 13:20:27 +00:00
2019-03-28 14:25:17 +00:00
foreach ( lib ${ arg_PUBLIC_LIBRARIES } ${ arg_LIBRARIES } )
string ( REGEX REPLACE "_nolink$" "" base_lib "${lib}" )
if ( NOT base_lib STREQUAL lib )
qt_create_nolink_target ( "${base_lib}" )
endif ( )
endforeach ( )
2018-12-07 12:13:24 +00:00
target_sources ( "${target}" PRIVATE ${ arg_SOURCES } ${ dbus_sources } )
if ( arg_COMPILE_FLAGS )
set_source_files_properties ( ${ arg_SOURCES } PROPERTIES COMPILE_FLAGS "${arg_COMPILE_FLAGS}" )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-07 12:13:24 +00:00
target_include_directories ( "${target}" PUBLIC ${ arg_PUBLIC_INCLUDE_DIRECTORIES } PRIVATE ${ arg_INCLUDE_DIRECTORIES } )
target_compile_definitions ( "${target}" PUBLIC ${ arg_PUBLIC_DEFINES } PRIVATE ${ arg_DEFINES } )
target_link_libraries ( "${target}" PUBLIC ${ arg_PUBLIC_LIBRARIES } PRIVATE ${ arg_LIBRARIES } )
2019-01-29 11:07:24 +00:00
target_compile_options ( "${target}" PUBLIC ${ arg_PUBLIC_COMPILE_OPTIONS } PRIVATE ${ arg_COMPILE_OPTIONS } )
target_link_options ( "${target}" PUBLIC ${ arg_PUBLIC_LINK_OPTIONS } PRIVATE ${ arg_LINK_OPTIONS } )
2019-01-30 15:43:11 +00:00
set_target_properties ( "${target}" PROPERTIES AUTOMOC_MOC_OPTIONS "${arg_MOC_OPTIONS}" )
2019-01-30 15:36:30 +00:00
else ( )
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
message ( "extend_target(${target} CONDITION ${arg_CONDITION} ...): Skipped" )
endif ( )
2018-11-08 21:29:55 +00:00
endif ( )
2018-10-24 13:20:27 +00:00
endfunction ( )
function ( qt_internal_library_deprecation_level result )
if ( WIN32 )
# On Windows, due to the way DLLs work, we need to export all functions,
# including the inlines
set ( "${result}" "QT_DISABLE_DEPRECATED_BEFORE=0x040800" PARENT_SCOPE )
else ( )
# On other platforms, Qt's own compilation goes needs to compile the Qt 5.0 API
set ( "${result}" "QT_DISABLE_DEPRECATED_BEFORE=0x050000" PARENT_SCOPE )
endif ( )
endfunction ( )
2019-02-11 16:09:03 +00:00
function ( qt_install_injections module )
set ( injections ${ ARGN } )
# examples:
# SYNCQT.INJECTIONS = src/corelib/global/qconfig.h:qconfig.h:QtConfig src/corelib/global/qconfig_p.h:5.12.0/QtCore/private/qconfig_p.h
# SYNCQT.INJECTIONS = src/gui/vulkan/qvulkanfunctions.h:^qvulkanfunctions.h:QVulkanFunctions:QVulkanDeviceFunctions src/gui/vulkan/qvulkanfunctions_p.h:^5.12.0/QtGui/private/qvulkanfunctions_p.h
separate_arguments ( injections UNIX_COMMAND "${injections}" )
foreach ( injection ${ injections } )
string ( REPLACE ":" ";" injection ${ injection } )
list ( GET injection 0 file )
list ( GET injection 1 destination )
string ( REGEX REPLACE "^\\^" "" destination "${destination}" )
list ( REMOVE_AT injection 0 1 )
set ( fwd_hdrs ${ injection } )
get_filename_component ( destinationdir ${ destination } DIRECTORY )
get_filename_component ( destinationname ${ destination } NAME )
2019-02-12 13:57:58 +00:00
install ( FILES ${ PROJECT_BINARY_DIR } / ${ file } DESTINATION ${ INSTALL_INCLUDEDIR } / ${ module } / ${ destinationdir } RENAME ${ destinationname } OPTIONAL )
2019-02-11 16:09:03 +00:00
foreach ( fwd_hdr ${ fwd_hdrs } )
file ( GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${fwd_hdr}" CONTENT "#include \" ${ destinationname } \"\n")
2019-02-12 13:57:58 +00:00
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/${fwd_hdr}" DESTINATION ${ INSTALL_INCLUDEDIR } / ${ module } / ${ destinationdir } OPTIONAL )
2019-02-11 16:09:03 +00:00
endforeach ( )
endforeach ( )
endfunction ( )
2018-12-07 13:04:42 +00:00
function ( qt_read_headers_pri target resultVarPrefix )
qt_internal_module_info ( module "${target}" )
file ( STRINGS "${module_include_dir}/headers.pri" headers_pri_contents )
2018-10-24 13:20:27 +00:00
foreach ( line ${ headers_pri_contents } )
if ( "${line}" MATCHES "SYNCQT.HEADER_FILES = (.*)" )
set ( public_module_headers "${CMAKE_MATCH_1}" )
separate_arguments ( public_module_headers UNIX_COMMAND "${public_module_headers}" )
elseif ( "${line}" MATCHES "SYNCQT.PRIVATE_HEADER_FILES = (.*)" )
set ( private_module_headers "${CMAKE_MATCH_1}" )
separate_arguments ( private_module_headers UNIX_COMMAND "${private_module_headers}" )
elseif ( "${line}" MATCHES "SYNCQT.GENERATED_HEADER_FILES = (.*)" )
set ( generated_module_headers "${CMAKE_MATCH_1}" )
separate_arguments ( generated_module_headers UNIX_COMMAND "${generated_module_headers}" )
foreach ( generated_header ${ generated_module_headers } )
2018-12-07 13:04:42 +00:00
list ( APPEND public_module_headers "${module_include_dir}/${generated_header}" )
2018-10-24 13:20:27 +00:00
endforeach ( )
2019-02-11 16:09:03 +00:00
elseif ( "${line}" MATCHES "SYNCQT.INJECTIONS = (.*)" )
set ( injections "${CMAKE_MATCH_1}" )
2018-10-24 13:20:27 +00:00
elseif ( "${line}" MATCHES "SYNCQT.([A-Z_]+)_HEADER_FILES = (.+)" )
set ( prefix "${CMAKE_MATCH_1}" )
string ( TOLOWER "${prefix}" prefix )
set ( entries "${CMAKE_MATCH_2}" )
separate_arguments ( entries UNIX_COMMAND "${entries}" )
set ( "${resultVarPrefix}_${prefix}" "${entries}" PARENT_SCOPE )
endif ( )
endforeach ( )
set ( ${ resultVarPrefix } _public "${public_module_headers}" PARENT_SCOPE )
set ( ${ resultVarPrefix } _private "${private_module_headers}" PARENT_SCOPE )
2019-02-11 16:09:03 +00:00
set ( ${ resultVarPrefix } _injections "${injections}" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2018-12-07 12:48:36 +00:00
# Add Qt::target and Qt6::target as aliases for the target
function ( qt_internal_add_target_aliases target )
get_target_property ( type "${target}" TYPE )
if ( type STREQUAL EXECUTABLE )
add_executable ( "Qt::${target}" ALIAS "${target}" )
add_executable ( "Qt${PROJECT_VERSION_MAJOR}::${target}" ALIAS "${target}" )
else ( )
add_library ( "Qt::${target}" ALIAS "${target}" )
add_library ( "Qt${PROJECT_VERSION_MAJOR}::${target}" ALIAS "${target}" )
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
# This is the main entry function for creating a Qt module, that typically
# consists of a library, public header files, private header files and configurable
# features.
#
2018-12-07 12:30:51 +00:00
# A CMake target with the specified target parameter is created. If the current source
2018-10-24 13:20:27 +00:00
# directory has a configure.cmake file, then that is also processed for feature definition
# and testing. Any features defined as well as any features coming from dependencies to
# this module are imported into the scope of the calling feature.
2018-12-07 12:30:51 +00:00
#
# Target is without leading "Qt". So e.g. the "QtCore" module has the target "Core".
function ( add_qt_module target )
2018-12-07 13:04:42 +00:00
qt_internal_module_info ( module "${target}" )
# Process arguments:
2018-12-07 12:13:24 +00:00
qt_parse_all_arguments ( arg "add_qt_module" "NO_MODULE_HEADERS;STATIC" "CONFIG_MODULE_NAME"
2018-12-11 10:38:20 +00:00
" $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } " $ { A R G N } )
2018-10-24 13:20:27 +00:00
2018-12-07 13:04:42 +00:00
if ( NOT DEFINED arg_CONFIG_MODULE_NAME )
set ( arg_CONFIG_MODULE_NAME "${module_lower}" )
endif ( )
2018-10-24 13:20:27 +00:00
2018-12-07 13:04:42 +00:00
qt_internal_set_known_qt_modules ( "${KNOWN_QT_MODULES}" "${target}" )
2018-10-24 13:20:27 +00:00
### Define Targets:
2018-12-07 12:13:24 +00:00
if ( ${ arg_STATIC } )
2018-10-24 13:20:27 +00:00
add_library ( "${target}" STATIC )
elseif ( ${ QT_BUILD_SHARED_LIBS } )
add_library ( "${target}" SHARED )
else ( )
add_library ( "${target}" STATIC )
endif ( )
2018-12-07 12:48:36 +00:00
qt_internal_add_target_aliases ( "${target}" )
2018-10-24 13:20:27 +00:00
# Add _private target to link against the private headers:
set ( target_private "${target}Private" )
add_library ( "${target_private}" INTERFACE )
2018-12-07 12:48:36 +00:00
qt_internal_add_target_aliases ( "${target_private}" )
2018-10-24 13:20:27 +00:00
2018-12-11 10:38:20 +00:00
# Module headers:
2018-12-07 12:48:36 +00:00
if ( ${ arg_NO_MODULE_HEADERS } )
set_target_properties ( "${target}" PROPERTIES MODULE_HAS_HEADERS OFF )
else ( )
2018-12-07 13:04:42 +00:00
qt_ensure_sync_qt ( )
2018-10-24 13:20:27 +00:00
execute_process ( COMMAND "${HOST_PERL}" -w "${QT_SYNCQT}" -quiet -module "${module}" -version "${PROJECT_VERSION}" -outdir "${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}" )
set_target_properties ( "${target}" PROPERTIES MODULE_HAS_HEADERS ON )
2018-12-11 10:38:20 +00:00
### FIXME: Can we replace headers.pri?
qt_read_headers_pri ( "${target}" "module_headers" )
set_property ( TARGET "${target}" APPEND PROPERTY PUBLIC_HEADER "${module_headers_public}" )
set_property ( TARGET "${target}" APPEND PROPERTY PUBLIC_HEADER "${module_include_dir}/${module}Depends" )
set_property ( TARGET "${target}" APPEND PROPERTY PRIVATE_HEADER "${module_headers_private}" )
2019-02-11 16:09:03 +00:00
qt_install_injections ( "${module}" ${ module_headers_injections } )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-07 12:48:36 +00:00
set_target_properties ( "${target}" PROPERTIES
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } / $ { I N S T A L L _ L I B D I R } "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { C M A K E _ B I N A R Y _ D I R } / $ { I N S T A L L _ B I N D I R } "
2019-02-12 10:20:22 +00:00
V E R S I O N $ { P R O J E C T _ V E R S I O N }
S O V E R S I O N $ { P R O J E C T _ V E R S I O N _ M A J O R }
2019-02-12 08:29:34 +00:00
O U T P U T _ N A M E " $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } " )
2018-10-24 13:20:27 +00:00
qt_internal_library_deprecation_level ( deprecation_define )
2019-03-06 12:51:38 +00:00
qt_autogen_tools ( "${target}"
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
)
2018-10-24 13:20:27 +00:00
extend_target ( "${target}"
2018-12-07 12:13:24 +00:00
S O U R C E S $ { a r g _ S O U R C E S }
2018-10-24 13:20:27 +00:00
P U B L I C _ I N C L U D E _ D I R E C T O R I E S
2018-12-07 13:04:42 +00:00
$ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ i n c l u d e _ d i r } >
2018-10-24 13:20:27 +00:00
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e / $ { m o d u l e } >
2018-12-07 12:13:24 +00:00
$ { a r g _ P U B L I C _ I N C L U D E _ D I R E C T O R I E S }
2018-10-24 13:20:27 +00:00
I N C L U D E _ D I R E C T O R I E S
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
$ < B U I L D _ I N T E R F A C E : $ { P R O J E C T _ B I N A R Y _ D I R } / i n c l u d e >
2018-12-07 13:04:42 +00:00
" $ { m o d u l e _ i n c l u d e _ d i r } / $ { P R O J E C T _ V E R S I O N } "
" $ { m o d u l e _ i n c l u d e _ d i r } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } "
2018-12-07 12:13:24 +00:00
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
2018-10-24 13:20:27 +00:00
P U B L I C _ D E F I N E S
2018-12-07 12:13:24 +00:00
$ { a r g _ P U B L I C _ D E F I N E S }
2018-12-07 12:30:51 +00:00
Q T _ $ { m o d u l e _ u p p e r } _ L I B
2018-10-24 13:20:27 +00:00
D E F I N E S
2018-12-07 12:13:24 +00:00
$ { a r g _ D E F I N E S }
2018-10-24 13:20:27 +00:00
Q T _ N O _ C A S T _ T O _ A S C I I Q T _ A S C I I _ C A S T _ W A R N I N G S
Q T _ M O C _ C O M P A T #we don't need warnings from calling moc code in our generated code
Q T _ U S E _ Q S T R I N G B U I L D E R
Q T _ D E P R E C A T E D _ W A R N I N G S
Q T _ B U I L D I N G _ Q T
2018-12-07 12:30:51 +00:00
Q T _ B U I L D _ $ { m o d u l e _ u p p e r } _ L I B ### FIXME: use QT_BUILD_ADDON for Add-ons or remove if we don't have add-ons anymore
2018-10-24 13:20:27 +00:00
" $ { d e p r e c a t i o n _ d e f i n e } "
2018-12-11 10:38:20 +00:00
P U B L I C _ L I B R A R I E S $ { a r g _ P U B L I C _ L I B R A R I E S }
L I B R A R I E S $ { a r g _ L I B R A R I E S }
F E A T U R E _ D E P E N D E N C I E S $ { a r g _ F E A T U R E _ D E P E N D E N C I E S }
D B U S _ A D A P T O R _ S O U R C E S $ { a r g _ D B U S _ A D A P T O R _ S O U R C E S }
D B U S _ A D A P T O R _ F L A G S $ { a r g _ D B U S _ A D A P T O R _ F L A G S }
D B U S _ I N T E R F A C E _ S O U R C E S $ { a r g _ D B U S _ I N T E R F A C E _ S O U R C E S }
D B U S _ I N T E R F A C E _ F L A G S $ { a r g _ D B U S _ I N T E R F A C E _ F L A G S }
2019-01-29 11:07:24 +00:00
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
P U B L I C _ C O M P I L E _ O P T I O N S $ { a r g _ P U B L I C _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
P U B L I C _ L I N K _ O P T I O N S $ { a r g _ P U B L I C _ L I N K _ O P T I O N S }
2019-01-30 15:43:11 +00:00
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
2018-10-24 13:20:27 +00:00
)
2018-12-11 10:38:20 +00:00
set ( configureFile "${CMAKE_CURRENT_SOURCE_DIR}/configure.cmake" )
if ( EXISTS "${configureFile}" )
qt_feature_module_begin (
L I B R A R Y " $ { t a r g e t } "
P U B L I C _ F I L E " q t $ { a r g _ C O N F I G _ M O D U L E _ N A M E } - c o n f i g . h "
P R I V A T E _ F I L E " q t $ { a r g _ C O N F I G _ M O D U L E _ N A M E } - c o n f i g _ p . h "
P U B L I C _ D E P E N D E N C I E S $ { a r g _ F E A T U R E _ D E P E N D E N C I E S }
P R I V A T E _ D E P E N D E N C I E S $ { a r g _ F E A T U R E _ D E P E N D E N C I E S }
)
include ( ${ configureFile } )
qt_feature_module_end ( "${target}" )
set_property ( TARGET "${target}" APPEND PROPERTY PUBLIC_HEADER "${CMAKE_CURRENT_BINARY_DIR}/qt${arg_CONFIG_MODULE_NAME}-config.h" )
set_property ( TARGET "${target}" APPEND PROPERTY PRIVATE_HEADER "${CMAKE_CURRENT_BINARY_DIR}/qt${arg_CONFIG_MODULE_NAME}-config_p.h" )
2018-10-24 13:20:27 +00:00
endif ( )
if ( DEFINED module_headers_private )
qt_internal_add_linker_version_script ( "${target}" PRIVATE_HEADERS ${ module_headers_private } )
else ( )
qt_internal_add_linker_version_script ( "${target}" )
endif ( )
2019-02-12 08:29:34 +00:00
install ( TARGETS "${target}" "${target_private}" EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets"
2018-10-24 13:20:27 +00:00
L I B R A R Y D E S T I N A T I O N $ { I N S T A L L _ L I B D I R }
A R C H I V E D E S T I N A T I O N $ { I N S T A L L _ L I B D I R }
P U B L I C _ H E A D E R D E S T I N A T I O N $ { I N S T A L L _ I N C L U D E D I R } / $ { m o d u l e }
P R I V A T E _ H E A D E R D E S T I N A T I O N $ { I N S T A L L _ I N C L U D E D I R } / $ { m o d u l e } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } / p r i v a t e
)
2019-02-11 10:34:35 +00:00
set ( config_install_dir "${INSTALL_LIBDIR}/cmake/${INSTALL_CMAKE_NAMESPACE}${target}" )
2019-02-12 08:29:34 +00:00
install ( EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets" NAMESPACE ${ QT_CMAKE_EXPORT_NAMESPACE } :: DESTINATION ${ config_install_dir } )
2018-10-24 13:20:27 +00:00
2019-02-12 11:21:56 +00:00
set ( extra_cmake_files )
set ( extra_cmake_includes )
if ( EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake" )
list ( APPEND extra_cmake_files "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake" )
list ( APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}Macros.cmake" )
endif ( )
if ( EXISTS "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in" )
configure_file ( "${CMAKE_CURRENT_LIST_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake.in"
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g E x t r a s . c m a k e "
@ O N L Y )
list ( APPEND extra_cmake_files "${CMAKE_CURRENT_BINARY_DIR}/${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake" )
list ( APPEND extra_cmake_includes "${INSTALL_CMAKE_NAMESPACE}${target}ConfigExtras.cmake" )
endif ( )
2018-10-24 13:20:27 +00:00
### fixme: cmake is missing a built-in variable for this. We want to apply it only to modules and plugins
# that belong to Qt.
2019-02-27 12:49:04 +00:00
qt_internal_add_link_flags_no_undefined ( "${target}" )
2018-10-24 13:20:27 +00:00
# When a public module depends on private, also make its private depend on the other's private
2018-12-07 12:13:24 +00:00
set ( qt_libs_private "" )
2018-10-24 13:20:27 +00:00
foreach ( it ${ KNOWN_QT_MODULES } )
2018-12-07 12:13:24 +00:00
list ( FIND arg_LIBRARIES "Qt::${it}Private" pos )
if ( pos GREATER -1 )
list ( APPEND qt_libs_private "Qt::${it}Private" )
2018-10-24 13:20:27 +00:00
endif ( )
endforeach ( )
2018-12-07 12:13:24 +00:00
target_link_libraries ( "${target_private}" INTERFACE "${target}" "${qt_libs_private}" )
2018-10-24 13:20:27 +00:00
target_include_directories ( "${target_private}" INTERFACE
$ < B U I L D _ I N T E R F A C E : $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } >
2018-12-07 13:04:42 +00:00
$ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ i n c l u d e _ d i r } / $ { P R O J E C T _ V E R S I O N } >
$ < B U I L D _ I N T E R F A C E : $ { m o d u l e _ i n c l u d e _ d i r } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } >
2018-10-24 13:20:27 +00:00
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e / $ { m o d u l e } / $ { P R O J E C T _ V E R S I O N } >
$ < I N S T A L L _ I N T E R F A C E : i n c l u d e / $ { m o d u l e } / $ { P R O J E C T _ V E R S I O N } / $ { m o d u l e } >
)
2019-02-12 19:17:57 +00:00
set ( target_deps )
foreach ( lib IN LISTS arg_PUBLIC_LIBRARIES qt_libs_private )
if ( "${lib}" MATCHES "^Qt::(.*)" )
set ( lib "${CMAKE_MATCH_1}" )
if ( lib STREQUAL Platform OR lib STREQUAL GlobalConfig )
list ( APPEND target_deps "Qt5\;${PROJECT_VERSION}" )
elseif ( "${lib}" MATCHES "(.*)Private" )
list ( APPEND target_deps "${INSTALL_CMAKE_NAMESPACE}${CMAKE_MATCH_1}\;${PROJECT_VERSION}" )
else ( )
list ( APPEND target_deps "${INSTALL_CMAKE_NAMESPACE}${lib}\;${PROJECT_VERSION}" )
endif ( )
endif ( )
endforeach ( )
configure_package_config_file (
" $ { Q T _ C M A K E _ D I R } / Q t M o d u l e C o n f i g . c m a k e . i n "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g . c m a k e "
I N S T A L L _ D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
)
write_basic_package_version_file (
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g V e r s i o n . c m a k e
V E R S I O N $ { P R O J E C T _ V E R S I O N }
C O M P A T I B I L I T Y A n y N e w e r V e r s i o n
)
install ( FILES
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g . c m a k e "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / $ { I N S T A L L _ C M A K E _ N A M E S P A C E } $ { t a r g e t } C o n f i g V e r s i o n . c m a k e "
$ { e x t r a _ c m a k e _ f i l e s }
D E S T I N A T I O N " $ { c o n f i g _ i n s t a l l _ d i r } "
C O M P O N E N T D e v e l
)
2018-10-24 13:20:27 +00:00
endfunction ( )
2019-03-26 12:32:34 +00:00
function ( qt_internal_check_directory_or_type name dir type default result_var )
if ( "x${dir}" STREQUAL x )
if ( "x${type}" STREQUAL x )
message ( FATAL_ERROR "add_qt_plugin called without setting either TYPE or ${name}." )
endif ( )
set ( ${ result_var } "${default}" PARENT_SCOPE )
else ( )
set ( ${ result_var } "${dir}" PARENT_SCOPE )
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
# This is the main entry point for defining Qt plugins.
2018-12-11 10:38:20 +00:00
# A CMake target is created with the given target. The TYPE parameter is needed to place the
2018-10-24 13:20:27 +00:00
# plugin into the correct plugins/ sub-directory.
2018-12-11 10:38:20 +00:00
function ( add_qt_plugin target )
qt_internal_module_info ( module "${target}" )
2018-10-24 13:20:27 +00:00
2019-03-26 12:32:34 +00:00
qt_parse_all_arguments ( arg "add_qt_plugin" "STATIC"
" T Y P E ; O U T P U T _ D I R E C T O R Y ; I N S T A L L _ D I R E C T O R Y ; A R C H I V E _ I N S T A L L _ D I R E C T O R Y "
" $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; $ { _ _ d e f a u l t _ p u b l i c _ a r g s } " $ { A R G N } )
qt_internal_check_directory_or_type ( OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}" "${arg_TYPE}"
" $ { C M A K E _ B I N A R Y _ D I R } / $ { I N S T A L L _ P L U G I N S D I R } / $ { a r g _ T Y P E } " o u t p u t _ d i r e c t o r y )
qt_internal_check_directory_or_type ( INSTALL_DIRECTORY "${arg_INSTALL_DIRECTORY}" "${arg_TYPE}"
" $ { I N S T A L L _ P L U G I N S D I R } / $ { a r g _ T Y P E } " i n s t a l l _ d i r e c t o r y )
qt_internal_check_directory_or_type ( ARCHIVE_INSTALL_DIRECTORY
" $ { a r g _ A R C H I V E _ I N S T A L L _ D I R E C T O R Y } " " $ { a r g _ T Y P E } "
" $ { I N S T A L L _ L I B D I R } / $ { a r g _ T Y P E } " a r c h i v e _ i n s t a l l _ d i r e c t o r y )
2018-10-24 13:20:27 +00:00
2019-03-26 12:32:34 +00:00
if ( arg_STATIC )
add_library ( "${target}" STATIC )
else ( )
add_library ( "${target}" )
endif ( )
2018-12-11 10:38:20 +00:00
qt_internal_add_target_aliases ( "${target}" )
2018-10-24 13:20:27 +00:00
2018-12-11 10:38:20 +00:00
set_target_properties ( "${target}" PROPERTIES
2019-03-26 12:32:34 +00:00
L I B R A R Y _ O U T P U T _ D I R E C T O R Y " $ { o u t p u t _ d i r e c t o r y } "
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { o u t p u t _ d i r e c t o r y } "
A R C H I V E _ O U T P U T _ D I R E C T O R Y " $ { o u t p u t _ d i r e c t o r y } " )
2018-10-24 13:20:27 +00:00
qt_internal_library_deprecation_level ( deprecation_define )
2019-03-06 12:51:38 +00:00
qt_autogen_tools ( "${target}"
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
)
2019-03-26 12:39:43 +00:00
set ( static_plugin_define "" )
if ( arg_STATIC OR NOT QT_BUILD_SHARED_LIBS )
set ( static_plugin_define "QT_STATICPLUGIN" )
endif ( )
2018-12-11 10:38:20 +00:00
extend_target ( "${target}"
2018-12-07 12:13:24 +00:00
S O U R C E S $ { a r g _ S O U R C E S }
2018-10-24 13:20:27 +00:00
I N C L U D E _ D I R E C T O R I E S
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
2018-12-07 12:13:24 +00:00
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
P U B L I C _ I N C L U D E _ D I R E C T O R I E S $ { a r g _ P U B L I C _ I N C L U D E _ D I R E C T O R I E S }
L I B R A R I E S $ { a r g _ L I B R A R I E S }
P U B L I C _ L I B R A R I E S $ { a r g _ P U B L I C _ L I B R A R I E S }
2018-10-24 13:20:27 +00:00
D E F I N E S
2018-12-07 12:13:24 +00:00
$ { a r g _ D E F I N E S }
2018-10-24 13:20:27 +00:00
Q T _ N O _ C A S T _ T O _ A S C I I Q T _ A S C I I _ C A S T _ W A R N I N G S
Q T _ M O C _ C O M P A T #we don't need warnings from calling moc code in our generated code
Q T _ U S E _ Q S T R I N G B U I L D E R
Q T _ D E P R E C A T E D _ W A R N I N G S
Q T _ B U I L D I N G _ Q T
2018-12-11 10:38:20 +00:00
Q T _ B U I L D _ $ { m o d u l e _ u p p e r } _ L I B ### FIXME: use QT_BUILD_ADDON for Add-ons or remove if we don't have add-ons anymore
2018-10-24 13:20:27 +00:00
" $ { d e p r e c a t i o n _ d e f i n e } "
2019-03-26 12:39:43 +00:00
" $ { s t a t i c _ p l u g i n _ d e f i n e } "
2019-03-11 11:34:52 +00:00
Q T _ P L U G I N
2018-10-24 13:20:27 +00:00
P U B L I C _ D E F I N E S
2018-12-11 10:38:20 +00:00
Q T _ $ { m o d u l e _ u p p e r } _ L I B
2018-12-07 12:13:24 +00:00
$ { a r g _ P U B L I C _ D E F I N E S }
2018-12-11 10:38:20 +00:00
F E A T U R E _ D E P E N D E N C I E S $ { a r g _ F E A T U R E _ D E P E N D E N C I E S }
2018-12-07 12:13:24 +00:00
D B U S _ A D A P T O R _ S O U R C E S " $ { a r g _ D B U S _ A D A P T O R _ S O U R C E S } "
D B U S _ A D A P T O R _ F L A G S " $ { a r g _ D B U S _ A D A P T O R _ F L A G S } "
D B U S _ I N T E R F A C E _ S O U R C E S " $ { a r g _ D B U S _ I N T E R F A C E _ S O U R C E S } "
D B U S _ I N T E R F A C E _ F L A G S " $ { a r g _ D B U S _ I N T E R F A C E _ F L A G S } "
2019-01-29 11:07:24 +00:00
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
P U B L I C _ C O M P I L E _ O P T I O N S $ { a r g _ P U B L I C _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
P U B L I C _ L I N K _ O P T I O N S $ { a r g _ P U B L I C _ L I N K _ O P T I O N S }
2019-01-30 15:43:11 +00:00
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
2018-10-24 13:20:27 +00:00
)
2018-12-11 10:38:20 +00:00
install ( TARGETS "${target}" EXPORT "${target}Targets"
2019-03-26 12:32:34 +00:00
L I B R A R Y D E S T I N A T I O N " $ { i n s t a l l _ d i r e c t o r y } "
A R C H I V E D E S T I N A T I O N " $ { a r c h i v e _ i n s t a l l _ d i r e c t o r y } " )
2019-02-12 09:02:15 +00:00
install ( EXPORT "${target}Targets" NAMESPACE ${ QT_CMAKE_EXPORT_NAMESPACE } :: DESTINATION ${ INSTALL_LIBDIR } /cmake )
2018-10-24 13:20:27 +00:00
### fixme: cmake is missing a built-in variable for this. We want to apply it only to modules and plugins
# that belong to Qt.
2019-02-27 12:49:04 +00:00
qt_internal_add_link_flags_no_undefined ( "${target}" )
2018-10-24 13:20:27 +00:00
2018-12-11 10:38:20 +00:00
qt_internal_add_linker_version_script ( ${ target } )
2018-10-24 13:20:27 +00:00
endfunction ( )
# This function creates a CMake target for a generic console or GUI binary.
# Please consider to use a more specific version target like the one created
# by add_qt_test or add_qt_tool below.
function ( add_qt_executable name )
2019-04-03 09:33:28 +00:00
qt_parse_all_arguments ( arg "add_qt_executable" "GUI;BOOTSTRAP;NO_INSTALL" "OUTPUT_DIRECTORY;INSTALL_DIRECTORY" "EXE_FLAGS;${__default_private_args}" ${ ARGN } )
2018-10-24 13:20:27 +00:00
2018-12-07 12:13:24 +00:00
if ( "x${arg_OUTPUT_DIRECTORY}" STREQUAL "x" )
set ( arg_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_BINDIR}" )
2018-10-24 13:20:27 +00:00
endif ( )
2019-03-18 17:49:04 +00:00
get_filename_component ( arg_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
A B S O L U T E B A S E _ D I R " $ { C M A K E _ B I N A R Y _ D I R } " )
2019-03-18 18:09:27 +00:00
if ( "x${arg_INSTALL_DIRECTORY}" STREQUAL "x" )
set ( arg_INSTALL_DIRECTORY "${INSTALL_BINDIR}" )
endif ( )
2018-12-07 12:13:24 +00:00
add_executable ( "${name}" ${ arg_EXE_FLAGS } )
2019-03-06 12:51:38 +00:00
qt_autogen_tools ( "${name}"
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
)
2019-03-20 11:09:12 +00:00
set ( extra_libraries "" )
if ( NOT arg_BOOTSTRAP )
set ( extra_libraries "Qt::Core" )
endif ( )
2018-10-24 13:20:27 +00:00
extend_target ( "${name}"
2018-12-07 12:13:24 +00:00
S O U R C E S $ { a r g _ S O U R C E S }
2018-10-24 13:20:27 +00:00
I N C L U D E _ D I R E C T O R I E S
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
2018-12-07 12:13:24 +00:00
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
D E F I N E S $ { a r g _ D E F I N E S }
2019-03-20 11:09:12 +00:00
L I B R A R I E S $ { a r g _ L I B R A R I E S } $ { e x t r a _ l i b r a r i e s }
2018-12-07 12:13:24 +00:00
D B U S _ A D A P T O R _ S O U R C E S " $ { a r g _ D B U S _ A D A P T O R _ S O U R C E S } "
D B U S _ A D A P T O R _ F L A G S " $ { a r g _ D B U S _ A D A P T O R _ F L A G S } "
D B U S _ I N T E R F A C E _ S O U R C E S " $ { a r g _ D B U S _ I N T E R F A C E _ S O U R C E S } "
D B U S _ I N T E R F A C E _ F L A G S " $ { a r g _ D B U S _ I N T E R F A C E _ F L A G S } "
2019-01-29 11:07:24 +00:00
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
2019-01-30 15:43:11 +00:00
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
2018-10-24 13:20:27 +00:00
)
set_target_properties ( "${name}" PROPERTIES
2018-12-07 12:13:24 +00:00
R U N T I M E _ O U T P U T _ D I R E C T O R Y " $ { a r g _ O U T P U T _ D I R E C T O R Y } "
W I N 3 2 _ E X E C U T A B L E " $ { a r g _ G U I } "
M A C O S X _ B U N D L E " $ { a r g _ G U I } "
2018-10-24 13:20:27 +00:00
)
2019-03-18 18:09:27 +00:00
2019-04-03 09:33:28 +00:00
if ( NOT arg_NO_INSTALL )
install ( TARGETS "${name}"
R U N T I M E D E S T I N A T I O N " $ { a r g _ I N S T A L L _ D I R E C T O R Y } "
B U N D L E D E S T I N A T I O N " $ { a r g _ I N S T A L L _ D I R E C T O R Y } " )
endif ( )
2018-10-24 13:20:27 +00:00
endfunction ( )
# This function creates a CMake test target with the specified name for use with CTest.
function ( add_qt_test name )
2018-12-07 12:13:24 +00:00
qt_parse_all_arguments ( arg "add_qt_test" "RUN_SERIAL" "" "${__default_private_args}" ${ ARGN } )
set ( path "${CMAKE_CURRENT_BINARY_DIR}" )
2018-10-24 13:20:27 +00:00
add_qt_executable ( "${name}"
2019-04-03 09:33:28 +00:00
N O _ I N S T A L L
2018-12-07 12:13:24 +00:00
O U T P U T _ D I R E C T O R Y " $ { p a t h } "
S O U R C E S " $ { a r g _ S O U R C E S } "
2018-10-24 13:20:27 +00:00
I N C L U D E _ D I R E C T O R I E S
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } "
2018-12-07 12:13:24 +00:00
" $ { a r g _ I N C L U D E _ D I R E C T O R I E S } "
D E F I N E S " $ { a r g _ D E F I N E S } "
2019-02-12 09:02:15 +00:00
L I B R A R I E S $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : C o r e $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : T e s t $ { a r g _ L I B R A R I E S }
2019-01-29 11:07:24 +00:00
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
2019-01-30 15:43:11 +00:00
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
2019-03-06 12:51:38 +00:00
D I S A B L E _ A U T O G E N _ T O O L S $ { a r g _ D I S A B L E _ A U T O G E N _ T O O L S }
2018-10-24 13:20:27 +00:00
)
2019-04-05 15:23:16 +00:00
add_test ( NAME "${name}" COMMAND "${name}" WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
2018-10-24 13:20:27 +00:00
2018-12-07 12:13:24 +00:00
set_tests_properties ( "${name}" PROPERTIES RUN_SERIAL "${arg_RUN_SERIAL}" )
set_property ( TEST "${name}" APPEND PROPERTY ENVIRONMENT "PATH=${path}${QT_PATH_SEPARATOR}${CMAKE_CURRENT_BINARY_DIR}${QT_PATH_SEPARATOR}$ENV{PATH}" )
2018-10-24 13:20:27 +00:00
set_property ( TEST "${name}" APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}" )
endfunction ( )
# This function creates an executable for use as helper program with tests. Some
# tests launch separate programs to test certainly input/output behavior.
function ( add_qt_test_helper name )
2019-04-05 09:17:24 +00:00
add_qt_executable ( "${name}" NO_INSTALL OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/.." ${ ARGN } )
2018-10-24 13:20:27 +00:00
endfunction ( )
# This function is used to define a "Qt tool", such as moc, uic or rcc.
# The BOOTSTRAP option allows building it as standalone program, otherwise
# it will be linked against QtCore.
function ( add_qt_tool name )
2019-02-11 14:50:17 +00:00
set01 ( _build_tools "x${HOST_QT_TOOLS_DIRECTORY}" STREQUAL "x" )
if ( NOT _build_tools )
message ( "Searching for ${name}." )
find_program ( "_PROG_${name}" "${name}" PATHS "${HOST_QT_TOOLS_DIRECTORY}" NO_DEFAULT_PATH )
if ( _PROG_ ${ name } STREQUAL "_PROG_${name}-NOTFOUND" )
message ( FATAL_ERROR "The name \" ${ name } \" was not found in the "
" HOST_QT_TOOLS_DIRECTORY ( \"${HOST_QT_TOOLS_DIRECTORY}\").")
else ( )
message ( STATUS "${name} was found at ${_PROG_${name}}." )
add_executable ( "${name}" IMPORTED GLOBAL )
set_target_properties ( "${name}" PROPERTIES IMPORTED_LOCATION "${_PROG_${name}}" )
qt_internal_add_target_aliases ( "${name}" )
endif ( )
return ( )
endif ( )
2019-04-03 09:33:28 +00:00
qt_parse_all_arguments ( arg "add_qt_tool" "BOOTSTRAP;NO_INSTALL" "" "${__default_private_args}" ${ ARGN } )
2018-10-24 13:20:27 +00:00
2019-03-06 12:51:38 +00:00
set ( disable_autogen_tools "${arg_DISABLE_AUTOGEN_TOOLS}" )
2018-12-07 12:13:24 +00:00
if ( arg_BOOTSTRAP )
2019-02-12 09:02:15 +00:00
set ( corelib ${ QT_CMAKE_EXPORT_NAMESPACE } ::Bootstrap )
2019-03-06 12:51:38 +00:00
list ( APPEND disable_autogen_tools "uic" "moc" "rcc" )
2018-10-24 13:20:27 +00:00
else ( )
2019-02-12 09:02:15 +00:00
set ( corelib ${ QT_CMAKE_EXPORT_NAMESPACE } ::Core )
2018-10-24 13:20:27 +00:00
endif ( )
2019-03-20 11:09:12 +00:00
set ( bootstrap "" )
if ( arg_BOOTSTRAP )
set ( bootstrap BOOTSTRAP )
endif ( )
2019-04-03 09:33:28 +00:00
set ( no_install "" )
if ( arg_NO_INSTALL )
set ( no_install NO_INSTALL )
endif ( )
2018-10-24 13:20:27 +00:00
add_qt_executable ( "${name}" OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${INSTALL_BINDIR}"
2019-03-20 11:09:12 +00:00
$ { b o o t s t r a p }
2019-04-03 09:33:28 +00:00
$ { n o _ i n s t a l l }
2018-12-12 09:55:20 +00:00
S O U R C E S $ { a r g _ S O U R C E S }
2018-10-24 13:20:27 +00:00
I N C L U D E _ D I R E C T O R I E S
2018-12-07 12:13:24 +00:00
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
D E F I N E S $ { a r g _ D E F I N E S }
L I B R A R I E S $ { c o r e l i b } $ { a r g _ L I B R A R I E S }
2019-01-29 11:07:24 +00:00
C O M P I L E _ O P T I O N S $ { a r g _ C O M P I L E _ O P T I O N S }
L I N K _ O P T I O N S $ { a r g _ L I N K _ O P T I O N S }
2019-01-30 15:43:11 +00:00
M O C _ O P T I O N S $ { a r g _ M O C _ O P T I O N S }
2019-03-06 12:51:38 +00:00
D I S A B L E _ A U T O G E N _ T O O L S $ { d i s a b l e _ a u t o g e n _ t o o l s }
2018-10-24 13:20:27 +00:00
)
2018-12-07 12:48:36 +00:00
qt_internal_add_target_aliases ( "${name}" )
2018-10-24 13:20:27 +00:00
2019-04-03 09:33:28 +00:00
if ( NOT arg_NO_INSTALL )
install ( TARGETS "${name}" EXPORT "Qt${PROJECT_VERSION_MAJOR}ToolsTargets" DESTINATION ${ INSTALL_TARGETS_DEFAULT_ARGS } )
endif ( )
2018-10-24 13:20:27 +00:00
endfunction ( )
function ( qt_create_tracepoints name tracePointsFile )
#### TODO
string ( TOLOWER "${name}" name )
file ( GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/qt${name}_tracepoints_p.h" CONTENT
" #include <private/qtrace_p.h>")
endfunction ( )
function ( add_qt_resource target resourceName )
2019-03-07 09:05:10 +00:00
qt_parse_all_arguments ( rcc "add_qt_resource" "" "PREFIX;LANG;BASE" "FILES" ${ ARGN } )
2018-10-24 13:20:27 +00:00
2019-03-07 09:05:10 +00:00
# Generate .qrc file:
# <RCC><qresource ...>
set ( qrcContents "<RCC>\n <qresource" )
if ( rcc_PREFIX )
string ( APPEND qrcContents " prefix=\" ${ rcc_PREFIX } \"")
2018-10-24 13:20:27 +00:00
endif ( )
2019-03-07 09:05:10 +00:00
if ( rcc_LANG )
string ( APPEND qrcContents " lang=\" ${ rcc_LANG } \"")
endif ( )
string ( APPEND qrcContents ">\n" )
2018-10-24 13:20:27 +00:00
foreach ( file ${ rcc_FILES } )
2019-03-07 09:05:10 +00:00
if ( rcc_BASE )
set ( based_file "${rcc_BASE}/${file}" )
else ( )
set ( based_file "${file}" )
endif ( )
get_property ( alias SOURCE ${ based_file } PROPERTY alias )
2018-10-24 13:20:27 +00:00
if ( NOT alias )
set ( alias "${file}" )
endif ( )
### FIXME: escape file paths to be XML conform
2019-03-07 09:05:10 +00:00
# <file ...>...</file>
string ( APPEND qrcContents " <file alias=\" ${ alias } \">")
string ( APPEND qrcContents "${CMAKE_CURRENT_SOURCE_DIR}/${based_file}</file>\n" )
2018-10-24 13:20:27 +00:00
endforeach ( )
2019-03-07 09:05:10 +00:00
# </qresource></RCC>
2018-10-24 13:20:27 +00:00
string ( APPEND qrcContents " </qresource>\n</RCC>\n" )
2019-03-07 09:05:10 +00:00
2018-10-24 13:20:27 +00:00
set ( generatedResourceFile "${CMAKE_CURRENT_BINARY_DIR}/${resourceName}.qrc" )
file ( GENERATE OUTPUT "${generatedResourceFile}" CONTENT "${qrcContents}" )
2019-03-07 09:05:10 +00:00
# Process .qrc file:
2018-10-24 13:20:27 +00:00
set ( generatedSourceCode "${CMAKE_CURRENT_BINARY_DIR}/qrc_${resourceName}.cpp" )
add_custom_command ( OUTPUT "${generatedSourceCode}"
2019-02-12 09:02:15 +00:00
C O M M A N D " $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : r c c "
2018-10-24 13:20:27 +00:00
A R G S - - n a m e " $ { r e s o u r c e N a m e } "
- - o u t p u t " $ { g e n e r a t e d S o u r c e C o d e } " " $ { g e n e r a t e d R e s o u r c e F i l e } "
D E P E N D S $ { f i l e s }
C O M M E N T " R C C $ { r e s o u r c e N a m e } "
V E R B A T I M )
target_sources ( ${ target } PRIVATE "${generatedSourceCode}" )
endfunction ( )
2019-03-11 14:09:33 +00:00
# Handle files that need special SIMD-related flags.
# This creates an object library and makes target link
# to it (privately).
function ( add_qt_simd_part target )
qt_parse_all_arguments ( arg "add_qt_simd_part" "" ""
" N A M E ; S I M D ; $ { _ _ d e f a u l t _ p r i v a t e _ a r g s } ; C O M P I L E _ F L A G S " $ { A R G N } )
if ( "x${arg_SIMD}" STREQUAL x )
message ( FATAL_ERROR "add_qt_simd_part needs a SIMD type to be set." )
endif ( )
set ( condition "QT_FEATURE_${arg_SIMD}" )
if ( "${arg_SIMD}" STREQUAL arch_haswell )
set ( condition "TEST_subarch_avx2 AND TEST_subarch_bmi AND TEST_subarch_bmi2 AND TEST_subarch_f16c AND TEST_subarch_fma AND TEST_subarch_lzcnt AND TEST_subarch_popcnt" )
elseif ( "${arg_SIMD}" STREQUAL avx512common )
set ( condition "TEST_subarch_avx512cd" )
elseif ( "${arg_SIMD}" STREQUAL avx512core )
set ( condition "TEST_subarch_avx512cd AND TEST_subarch_avx512bw AND TEST_subarch_avx512dq AND TEST_subarch_avx512vl" )
endif ( )
set ( name "${arg_NAME}" )
if ( "x${name}" STREQUAL x )
set ( name "${target}_simd_${arg_SIMD}" )
endif ( )
qt_evaluate_config_expression ( result ${ condition } )
if ( ${ result } )
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
message ( "add_qt_simd_part(${target} SIMD ${arg_SIMD} ...): Evaluated" )
endif ( )
string ( TOUPPER "QT_CFLAGS_${arg_SIMD}" simd_flags )
add_library ( "${name}" OBJECT )
target_sources ( "${name}" PRIVATE ${ arg_SOURCES } )
target_include_directories ( "${name}" PRIVATE
$ { a r g _ I N C L U D E _ D I R E C T O R I E S }
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , I N C L U D E _ D I R E C T O R I E S > )
target_compile_options ( "${name}" PRIVATE
$ { $ { s i m d _ f l a g s } }
$ { a r g _ C O M P I L E _ F L A G S }
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , C O M P I L E _ O P T I O N S > )
target_compile_definitions ( "${name}" PRIVATE
$ < T A R G E T _ P R O P E R T Y : $ { t a r g e t } , C O M P I L E _ D E F I N I T I O N S > )
target_link_libraries ( "${target}" PRIVATE "${name}" )
else ( )
if ( QT_CMAKE_DEBUG_EXTEND_TARGET )
message ( "add_qt_simd_part(${target} SIMD ${arg_SIMD} ...): Skipped" )
endif ( )
endif ( )
endfunction ( )
2018-10-24 13:20:27 +00:00
# From Qt5CoreMacros
# Function used to create the names of output files preserving relative dirs
2018-11-08 21:29:27 +00:00
function ( qt_make_output_file infile prefix suffix source_dir binary_dir result )
get_filename_component ( outfilename "${infile}" NAME_WE )
set ( base_dir "${source_dir}" )
string ( FIND "${infile}" "${binary_dir}/" in_binary )
if ( in_binary EQUAL 0 )
set ( base_dir "${binary_dir}" )
2018-10-24 13:20:27 +00:00
endif ( )
2018-11-08 21:29:27 +00:00
get_filename_component ( abs_infile "${infile}" ABSOLUTE BASE_DIR "${base_dir}" )
file ( RELATIVE_PATH rel_infile "${base_dir}" "${abs_infile}" )
string ( REPLACE "../" "__/" mapped_infile "${rel_infile}" )
get_filename_component ( abs_mapped_infile "${mapped_infile}" ABSOLUTE BASE_DIR "${binary_dir}" )
get_filename_component ( outpath "${abs_mapped_infile}" PATH )
2018-10-24 13:20:27 +00:00
file ( MAKE_DIRECTORY "${outpath}" )
2018-12-07 12:13:24 +00:00
set ( "${result}" "${outpath}/${prefix}${outfilename}${suffix}" PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2018-11-08 21:29:27 +00:00
2018-12-12 09:55:20 +00:00
# Complete manual moc invocation with full control.
# Use AUTOMOC whenever possible.
function ( qt_manual_moc result )
cmake_parse_arguments ( arg "" "" "FLAGS" ${ ARGN } )
set ( moc_files )
foreach ( infile ${ arg_UNPARSED_ARGUMENTS } )
qt_make_output_file ( "${infile}" "moc_" ".cpp"
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } " " $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } " o u t f i l e )
list ( APPEND moc_files "${outfile}" )
2018-10-24 13:20:27 +00:00
2018-12-12 09:55:20 +00:00
set ( moc_parameters_file "${outfile}_parameters$<$<BOOL:$<CONFIGURATION>>:_$<CONFIGURATION>>" )
set ( moc_parameters ${ arg_FLAGS } -o "${outfile}" "${infile}" )
string ( REPLACE ";" "\n" moc_parameters "${moc_parameters}" )
2018-10-24 13:20:27 +00:00
2018-12-12 09:55:20 +00:00
file ( GENERATE OUTPUT "${moc_parameters_file}" CONTENT "${moc_parameters}\n" )
2018-10-24 13:20:27 +00:00
2018-12-12 09:55:20 +00:00
add_custom_command ( OUTPUT "${outfile}"
2019-02-12 09:02:15 +00:00
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : m o c " @ $ { m o c _ p a r a m e t e r s _ f i l e } "
D E P E N D S " $ { i n f i l e } " $ { m o c _ d e p e n d s } $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : m o c
2018-12-12 09:55:20 +00:00
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } " V E R B A T I M )
2018-10-24 13:20:27 +00:00
endforeach ( )
2018-12-12 09:55:20 +00:00
set ( "${result}" ${ moc_files } PARENT_SCOPE )
2018-10-24 13:20:27 +00:00
endfunction ( )
2018-10-29 15:53:51 +00:00
# helper to set up a qdbusxml2cpp rule
function ( qt_create_qdbusxml2cpp_command target infile )
2019-01-30 13:06:48 +00:00
qt_parse_all_arguments ( arg "qt_create_qdbusxml2cpp_command" "ADAPTOR;INTERFACE" "BASENAME" "FLAGS" ${ ARGN } )
2018-12-07 12:13:24 +00:00
if ( ( arg_ADAPTOR AND arg_INTERFACE ) OR ( NOT arg_ADAPTOR AND NOT arg_INTERFACE ) )
2018-10-29 15:53:51 +00:00
message ( FATAL_ERROR "qt_create_dbusxml2cpp_command needs either ADAPTOR or INTERFACE." )
endif ( )
2018-12-07 12:13:24 +00:00
set ( option "-a" )
set ( type "adaptor" )
if ( arg_INTERFACE )
set ( option "-p" )
set ( type "interface" )
2018-10-29 15:53:51 +00:00
endif ( )
2019-01-30 13:06:48 +00:00
if ( "${arg_BASENAME}" STREQUAL "" )
2019-03-18 18:10:28 +00:00
get_filename_component ( file_dir "${infile}" DIRECTORY )
get_filename_component ( file_name "${infile}" NAME_WLE )
get_filename_component ( file_ext "${infile}" LAST_EXT )
if ( "${file_ext}" STREQUAL ".xml" )
else ( )
message ( FATAL_ERROR "DBUS ${type} input file is not xml." )
endif ( )
# use last part of io.qt.something.xml!
get_filename_component ( file_ext "${file_name}" LAST_EXT )
if ( "x${file_ext}" STREQUAL "x" )
else ( )
string ( SUBSTRING "${file_ext}" 1 -1 file_name ) # cut of leading '.'
endif ( )
2019-01-30 13:06:48 +00:00
string ( TOLOWER "${file_name}" file_name )
set ( file_name "${file_name}_${type}" )
else ( )
set ( file_name ${ arg_BASENAME } )
endif ( )
2018-10-29 15:53:51 +00:00
2019-01-30 13:06:48 +00:00
set ( header_file "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.h" )
set ( source_file "${CMAKE_CURRENT_BINARY_DIR}/${file_name}.cpp" )
2018-10-29 15:53:51 +00:00
add_custom_command ( OUTPUT "${header_file}" "${source_file}"
2019-02-12 09:02:15 +00:00
C O M M A N D $ { Q T _ C M A K E _ E X P O R T _ N A M E S P A C E } : : q d b u s x m l 2 c p p $ { a r g _ F L A G S } " $ { o p t i o n } " " $ { h e a d e r _ f i l e } : $ { s o u r c e _ f i l e } " " $ { i n f i l e } "
2018-10-29 15:53:51 +00:00
D E P E N D S " $ { i n f i l e } "
W O R K I N G _ D I R E C T O R Y " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
V E R B A T I M )
2018-12-12 09:55:20 +00:00
target_sources ( "${target}" PRIVATE "${header_file}" "${source_file}" )
2018-10-29 15:53:51 +00:00
endfunction ( )
2018-12-07 13:04:42 +00:00
function ( qt_generate_forwarding_headers target )
2018-12-07 12:13:24 +00:00
qt_parse_all_arguments ( arg "qt_generate_forwarding_headers"
2018-10-24 13:20:27 +00:00
" P R I V A T E " " S O U R C E ; D E S T I N A T I O N " " C L A S S E S " $ { A R G N } )
2018-12-07 13:04:42 +00:00
qt_internal_module_info ( module "${target}" )
2018-10-24 13:20:27 +00:00
2018-12-07 12:13:24 +00:00
if ( NOT arg_DESTINATION )
get_filename_component ( arg_DESTINATION "${arg_SOURCE}" NAME )
2018-10-24 13:20:27 +00:00
endif ( )
2018-12-07 12:13:24 +00:00
if ( arg_PRIVATE )
2018-12-07 13:04:42 +00:00
set ( main_fwd "${module_include_dir}/${PROJECT_VERSION}/${module}/private/${arg_DESTINATION}" )
2018-10-24 13:20:27 +00:00
else ( )
2018-12-07 13:04:42 +00:00
set ( main_fwd "${module_include_dir}/${arg_DESTINATION}" )
2018-10-24 13:20:27 +00:00
endif ( )
get_filename_component ( main_fwd_dir "${main_fwd}" DIRECTORY )
2018-12-07 12:13:24 +00:00
file ( RELATIVE_PATH relpath "${main_fwd_dir}" "${CMAKE_CURRENT_BINARY_DIR}/${arg_SOURCE}" )
2018-10-24 13:20:27 +00:00
set ( main_contents "#include \" ${ relpath } \"")
file ( GENERATE OUTPUT "${main_fwd}" CONTENT "${main_contents}" )
2018-12-07 12:13:24 +00:00
foreach ( class_fwd ${ arg_CLASSES } )
2018-10-24 13:20:27 +00:00
set ( class_fwd_contents "#include \" ${ fwd_hdr } \"")
message ( "Generating forwarding header: ${class_fwd} -> ${relpath}." )
2018-12-07 13:04:42 +00:00
file ( GENERATE OUTPUT "${module_include_dir}/${class_fwd}" CONTENT "${class_fwd_contents}" )
2018-10-24 13:20:27 +00:00
endforeach ( )
endfunction ( )
function ( add_qt_docs qdocFile )
# TODO
endfunction ( )