2020-01-31 13:50:50 +01:00
|
|
|
if(QT_CREATOR_API_DEFINED)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
set(QT_CREATOR_API_DEFINED TRUE)
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
include(FeatureSummary)
|
|
|
|
|
2019-09-10 13:13:30 +02:00
|
|
|
#
|
|
|
|
# Default Qt compilation defines
|
|
|
|
#
|
|
|
|
|
|
|
|
list(APPEND DEFAULT_DEFINES
|
|
|
|
QT_CREATOR
|
|
|
|
QT_NO_JAVA_STYLE_ITERATORS
|
|
|
|
QT_NO_CAST_TO_ASCII QT_RESTRICTED_CAST_FROM_ASCII
|
|
|
|
QT_DISABLE_DEPRECATED_BEFORE=0x050900
|
|
|
|
QT_USE_FAST_OPERATOR_PLUS
|
|
|
|
QT_USE_FAST_CONCATENATION
|
|
|
|
)
|
|
|
|
|
2019-09-10 18:31:53 +02:00
|
|
|
if (WIN32)
|
|
|
|
list(APPEND DEFAULT_DEFINES UNICODE _UNICODE _CRT_SECURE_NO_WARNINGS)
|
2019-10-23 09:26:31 +02:00
|
|
|
|
|
|
|
if (NOT BUILD_WITH_PCH)
|
|
|
|
# Windows 8 0x0602
|
|
|
|
list(APPEND DEFAULT_DEFINES
|
|
|
|
WINVER=0x0602 _WIN32_WINNT=0x0602
|
|
|
|
WIN32_LEAN_AND_MEAN)
|
|
|
|
endif()
|
2019-09-10 18:31:53 +02:00
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
#
|
|
|
|
# Setup path handling
|
|
|
|
#
|
|
|
|
|
|
|
|
if (APPLE)
|
2020-01-24 12:14:38 +01:00
|
|
|
set(_IDE_APP_PATH ".")
|
2019-06-26 17:51:06 +02:00
|
|
|
set(_IDE_APP_TARGET "${IDE_DISPLAY_NAME}")
|
|
|
|
|
|
|
|
set(_IDE_OUTPUT_PATH "${_IDE_APP_PATH}/${_IDE_APP_TARGET}.app/Contents")
|
|
|
|
|
|
|
|
set(_IDE_PLUGIN_PATH "${_IDE_OUTPUT_PATH}/PlugIns")
|
|
|
|
set(_IDE_LIBRARY_BASE_PATH "Frameworks")
|
|
|
|
set(_IDE_LIBRARY_PATH "${_IDE_OUTPUT_PATH}/Frameworks")
|
2019-10-28 16:06:00 +01:00
|
|
|
set(_IDE_LIBEXEC_PATH "${_IDE_OUTPUT_PATH}/Resources/libexec")
|
2019-06-26 17:51:06 +02:00
|
|
|
set(_IDE_DATA_PATH "${_IDE_OUTPUT_PATH}/Resources")
|
|
|
|
set(_IDE_DOC_PATH "${_IDE_OUTPUT_PATH}/Resources/doc")
|
|
|
|
set(_IDE_BIN_PATH "${_IDE_OUTPUT_PATH}/MacOS")
|
2020-02-06 13:17:20 +01:00
|
|
|
|
|
|
|
set(QT_DEST_PLUGIN_PATH "${_IDE_PLUGIN_PATH}")
|
|
|
|
set(QT_DEST_QML_PATH "${_IDE_DATA_PATH}/../Imports/qtquick2")
|
2019-06-26 17:51:06 +02:00
|
|
|
else ()
|
2020-01-24 12:14:38 +01:00
|
|
|
set(_IDE_APP_PATH "bin")
|
2019-06-26 17:51:06 +02:00
|
|
|
set(_IDE_APP_TARGET "${IDE_ID}")
|
|
|
|
|
|
|
|
set(_IDE_LIBRARY_BASE_PATH "lib")
|
|
|
|
set(_IDE_LIBRARY_PATH "lib/${IDE_ID}")
|
|
|
|
set(_IDE_PLUGIN_PATH "lib/${IDE_ID}/plugins")
|
|
|
|
if (WIN32)
|
|
|
|
set(_IDE_LIBEXEC_PATH "bin")
|
2020-02-06 13:17:20 +01:00
|
|
|
set(QT_DEST_PLUGIN_PATH "bin/plugins")
|
|
|
|
set(QT_DEST_QML_PATH "bin/qml")
|
2019-06-26 17:51:06 +02:00
|
|
|
else ()
|
2020-02-12 09:11:21 +01:00
|
|
|
set(_IDE_LIBEXEC_PATH "libexec/${IDE_ID}")
|
2020-02-06 13:17:20 +01:00
|
|
|
set(QT_DEST_PLUGIN_PATH "lib/Qt/plugins")
|
|
|
|
set(QT_DEST_QML_PATH "lib/Qt/qml")
|
2019-06-26 17:51:06 +02:00
|
|
|
endif ()
|
|
|
|
set(_IDE_DATA_PATH "share/${IDE_ID}")
|
|
|
|
set(_IDE_DOC_PATH "share/doc/${IDE_ID}")
|
|
|
|
set(_IDE_BIN_PATH "bin")
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
set(IDE_APP_PATH "${_IDE_APP_PATH}") # The target path of the IDE application (relative to CMAKE_INSTALL_PREFIX).
|
|
|
|
set(IDE_APP_TARGET "${_IDE_APP_TARGET}") # The IDE application name.
|
|
|
|
set(IDE_PLUGIN_PATH "${_IDE_PLUGIN_PATH}") # The IDE plugin path (relative to CMAKE_INSTALL_PREFIX).
|
|
|
|
set(IDE_LIBRARY_BASE_PATH "${_IDE_LIBRARY_BASE_PATH}") # The IDE library base path (relative to CMAKE_INSTALL_PREFIX).
|
|
|
|
set(IDE_LIBRARY_PATH "${_IDE_LIBRARY_PATH}") # The IDE library path (relative to CMAKE_INSTALL_PREFIX).
|
|
|
|
set(IDE_LIBEXEC_PATH "${_IDE_LIBEXEC_PATH}") # The IDE libexec path (relative to CMAKE_INSTALL_PREFIX).
|
|
|
|
set(IDE_DATA_PATH "${_IDE_DATA_PATH}") # The IDE data path (relative to CMAKE_INSTALL_PREFIX).
|
|
|
|
set(IDE_DOC_PATH "${_IDE_DOC_PATH}") # The IDE documentation path (relative to CMAKE_INSTALL_PREFIX).
|
|
|
|
set(IDE_BIN_PATH "${_IDE_BIN_PATH}") # The IDE bin path (relative to CMAKE_INSTALL_PREFIX).
|
|
|
|
|
|
|
|
file(RELATIVE_PATH RELATIVE_PLUGIN_PATH "/${IDE_BIN_PATH}" "/${IDE_PLUGIN_PATH}")
|
|
|
|
file(RELATIVE_PATH RELATIVE_LIBEXEC_PATH "/${IDE_BIN_PATH}" "/${IDE_LIBEXEC_PATH}")
|
|
|
|
file(RELATIVE_PATH RELATIVE_DATA_PATH "/${IDE_BIN_PATH}" "/${IDE_DATA_PATH}")
|
|
|
|
file(RELATIVE_PATH RELATIVE_DOC_PATH "/${IDE_BIN_PATH}" "/${IDE_DOC_PATH}")
|
|
|
|
|
|
|
|
list(APPEND DEFAULT_DEFINES
|
|
|
|
RELATIVE_PLUGIN_PATH="${RELATIVE_PLUGIN_PATH}"
|
|
|
|
RELATIVE_LIBEXEC_PATH="${RELATIVE_LIBEXEC_PATH}"
|
|
|
|
RELATIVE_DATA_PATH="${RELATIVE_DATA_PATH}"
|
|
|
|
RELATIVE_DOC_PATH="${RELATIVE_DOC_PATH}"
|
|
|
|
)
|
|
|
|
|
|
|
|
file(RELATIVE_PATH _PLUGIN_TO_LIB "/${IDE_PLUGIN_PATH}" "/${IDE_LIBRARY_PATH}")
|
2020-02-04 13:22:28 +01:00
|
|
|
file(RELATIVE_PATH _PLUGIN_TO_QT "/${IDE_PLUGIN_PATH}" "/${IDE_LIBRARY_BASE_PATH}/Qt/lib")
|
|
|
|
file(RELATIVE_PATH _LIB_TO_QT "/${IDE_LIBRARY_PATH}" "/${IDE_LIBRARY_BASE_PATH}/Qt/lib")
|
2019-06-26 17:51:06 +02:00
|
|
|
|
|
|
|
if (APPLE)
|
|
|
|
set(_RPATH_BASE "@executable_path")
|
|
|
|
set(_LIB_RPATH "@loader_path")
|
|
|
|
set(_PLUGIN_RPATH "@loader_path;@loader_path/${_PLUGIN_TO_LIB}")
|
|
|
|
elseif (WIN32)
|
|
|
|
set(_RPATH_BASE "")
|
|
|
|
set(_LIB_RPATH "")
|
|
|
|
set(_PLUGIN_RPATH "")
|
|
|
|
else()
|
|
|
|
set(_RPATH_BASE "\$ORIGIN")
|
2020-02-04 13:22:28 +01:00
|
|
|
set(_LIB_RPATH "\$ORIGIN;\$ORIGIN/${_LIB_TO_QT}")
|
|
|
|
set(_PLUGIN_RPATH "\$ORIGIN;\$ORIGIN/${_PLUGIN_TO_LIB};\$ORIGIN/${_PLUGIN_TO_QT}")
|
2019-06-26 17:51:06 +02:00
|
|
|
endif ()
|
|
|
|
|
|
|
|
set(__QTC_PLUGINS "" CACHE INTERNAL "*** Internal ***")
|
2020-01-29 13:15:50 +01:00
|
|
|
set(__QTC_INSTALLED_PLUGINS "" CACHE INTERNAL "*** Internal ***")
|
2019-06-26 17:51:06 +02:00
|
|
|
set(__QTC_LIBRARIES "" CACHE INTERNAL "*** Internal ***")
|
2020-01-29 13:15:50 +01:00
|
|
|
set(__QTC_INSTALLED_LIBRARIES "" CACHE INTERNAL "*** Internal ***")
|
2019-06-26 17:51:06 +02:00
|
|
|
set(__QTC_EXECUTABLES "" CACHE INTERNAL "*** Internal ***")
|
2020-01-29 13:15:50 +01:00
|
|
|
set(__QTC_INSTALLED_EXECUTABLES "" CACHE INTERNAL "*** Internal ***")
|
2019-06-26 17:51:06 +02:00
|
|
|
set(__QTC_TESTS "" CACHE INTERNAL "*** Internal ***")
|
|
|
|
|
|
|
|
#
|
|
|
|
# Internal functions
|
|
|
|
#
|
|
|
|
|
2019-05-23 15:13:06 +02:00
|
|
|
function(append_extra_translations target_name)
|
|
|
|
if(NOT ARGN)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(TARGET "${target_name}")
|
|
|
|
get_target_property(_input "${target_name}" QT_EXTRA_TRANSLATIONS)
|
|
|
|
if (_input)
|
|
|
|
set(_output "${_input}" "${ARGN}")
|
|
|
|
else()
|
|
|
|
set(_output "${ARGN}")
|
|
|
|
endif()
|
|
|
|
set_target_properties("${target_name}" PROPERTIES QT_EXTRA_TRANSLATIONS "${_output}")
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
function(update_cached_list name value)
|
|
|
|
set(_tmp_list "${${name}}")
|
|
|
|
list(APPEND _tmp_list "${value}")
|
|
|
|
set("${name}" "${_tmp_list}" CACHE INTERNAL "*** Internal ***")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(compare_sources_with_existing_disk_files target_name sources)
|
|
|
|
if(NOT WITH_DEBUG_CMAKE)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
file(GLOB_RECURSE existing_files RELATIVE ${CMAKE_CURRENT_LIST_DIR} "*.cpp" "*.hpp" "*.c" "*.h" "*.ui" "*.qrc")
|
|
|
|
foreach(file IN LISTS existing_files)
|
|
|
|
if(NOT ${file} IN_LIST sources)
|
|
|
|
if (NOT WITH_TESTS AND ${file} MATCHES "test")
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
message(STATUS "${target_name} doesn't include ${file}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(source IN LISTS "${sources}")
|
|
|
|
if(NOT ${source} IN_LIST existing_files)
|
|
|
|
if (NOT WITH_TESTS AND ${file} MATCHES "test")
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
message(STATUS "${target_name} contains non existing ${source}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endfunction(compare_sources_with_existing_disk_files)
|
|
|
|
|
|
|
|
function(separate_object_libraries libraries REGULAR_LIBS OBJECT_LIBS OBJECT_LIB_OBJECTS)
|
|
|
|
if (CMAKE_VERSION VERSION_LESS 3.14)
|
|
|
|
foreach(lib IN LISTS libraries)
|
|
|
|
if (TARGET ${lib})
|
|
|
|
get_target_property(lib_type ${lib} TYPE)
|
|
|
|
if (lib_type STREQUAL "OBJECT_LIBRARY")
|
|
|
|
list(APPEND object_libs ${lib})
|
|
|
|
list(APPEND object_libs_objects $<TARGET_OBJECTS:${lib}>)
|
|
|
|
else()
|
|
|
|
list(APPEND regular_libs ${lib})
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
list(APPEND regular_libs ${lib})
|
|
|
|
endif()
|
|
|
|
set(${REGULAR_LIBS} ${regular_libs} PARENT_SCOPE)
|
|
|
|
set(${OBJECT_LIBS} ${object_libs} PARENT_SCOPE)
|
|
|
|
set(${OBJECT_LIB_OBJECTS} ${object_libs_objects} PARENT_SCOPE)
|
|
|
|
endforeach()
|
|
|
|
else()
|
|
|
|
set(${REGULAR_LIBS} ${libraries} PARENT_SCOPE)
|
|
|
|
unset(${OBJECT_LIBS} PARENT_SCOPE)
|
|
|
|
unset(${OBJECT_LIB_OBJECTS} PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction(separate_object_libraries)
|
|
|
|
|
|
|
|
function(set_explicit_moc target_name file)
|
2019-11-07 14:56:15 +01:00
|
|
|
unset(file_dependencies)
|
|
|
|
if (file MATCHES "^.*plugin.h$")
|
|
|
|
set(file_dependencies DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${target_name}.json")
|
|
|
|
endif()
|
2019-06-26 17:51:06 +02:00
|
|
|
set_property(SOURCE "${file}" PROPERTY SKIP_AUTOMOC ON)
|
2019-11-07 14:56:15 +01:00
|
|
|
qt5_wrap_cpp(file_moc "${file}" ${file_dependencies})
|
2019-06-26 17:51:06 +02:00
|
|
|
target_sources(${target_name} PRIVATE "${file_moc}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(set_public_headers target sources)
|
|
|
|
foreach(source IN LISTS sources)
|
|
|
|
if (source MATCHES "\.h$|\.hpp$")
|
|
|
|
|
|
|
|
if (NOT IS_ABSOLUTE ${source})
|
|
|
|
set(source "${CMAKE_CURRENT_SOURCE_DIR}/${source}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
get_filename_component(source_dir ${source} DIRECTORY)
|
|
|
|
file(RELATIVE_PATH include_dir_relative_path ${PROJECT_SOURCE_DIR} ${source_dir})
|
|
|
|
|
|
|
|
install(
|
|
|
|
FILES ${source}
|
|
|
|
DESTINATION "include/${include_dir_relative_path}"
|
|
|
|
COMPONENT Devel EXCLUDE_FROM_ALL
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(set_public_includes target includes)
|
|
|
|
foreach(inc_dir IN LISTS includes)
|
|
|
|
if (NOT IS_ABSOLUTE ${inc_dir})
|
|
|
|
set(inc_dir "${CMAKE_CURRENT_SOURCE_DIR}/${inc_dir}")
|
|
|
|
endif()
|
|
|
|
target_include_directories(${target} PUBLIC $<BUILD_INTERFACE:${inc_dir}>)
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
2019-09-18 14:10:52 +02:00
|
|
|
function(finalize_test_setup test_name)
|
|
|
|
# Never translate tests:
|
2020-01-27 12:57:25 +01:00
|
|
|
set_tests_properties(${name}
|
|
|
|
PROPERTIES
|
|
|
|
QT_SKIP_TRANSLATION ON
|
|
|
|
TIMEOUT 5
|
|
|
|
)
|
2019-09-18 14:10:52 +02:00
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
if (WIN32)
|
|
|
|
list(APPEND env_path $ENV{PATH})
|
|
|
|
list(APPEND env_path ${CMAKE_BINARY_DIR}/${IDE_PLUGIN_PATH})
|
|
|
|
list(APPEND env_path ${CMAKE_BINARY_DIR}/${IDE_BIN_PATH})
|
|
|
|
list(APPEND env_path $<TARGET_FILE_DIR:Qt5::Test>)
|
|
|
|
if (TARGET libclang)
|
|
|
|
list(APPEND env_path $<TARGET_FILE_DIR:libclang>)
|
|
|
|
endif()
|
|
|
|
|
2020-01-24 17:09:56 +01:00
|
|
|
if (TARGET elfutils::elf)
|
|
|
|
list(APPEND env_path $<TARGET_FILE_DIR:elfutils::elf>)
|
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
string(REPLACE "/" "\\" env_path "${env_path}")
|
|
|
|
string(REPLACE ";" "\\;" env_path "${env_path}")
|
|
|
|
|
|
|
|
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT "PATH=${env_path}")
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(add_qtc_depends target_name)
|
|
|
|
cmake_parse_arguments(_arg "" "" "PRIVATE;PUBLIC" ${ARGN})
|
|
|
|
if (${_arg_UNPARSED_ARGUMENTS})
|
|
|
|
message(FATAL_ERROR "add_qtc_depends had unparsed arguments")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
separate_object_libraries("${_arg_PRIVATE}"
|
|
|
|
depends object_lib_depends object_lib_depends_objects)
|
|
|
|
separate_object_libraries("${_arg_PUBLIC}"
|
|
|
|
public_depends object_public_depends object_public_depends_objects)
|
|
|
|
|
|
|
|
target_sources(${target_name} PRIVATE ${object_lib_depends_objects} ${object_public_depends_objects})
|
|
|
|
|
|
|
|
get_target_property(target_type ${target_name} TYPE)
|
|
|
|
if (NOT target_type STREQUAL "OBJECT_LIBRARY")
|
|
|
|
target_link_libraries(${target_name} PRIVATE ${depends} PUBLIC ${public_depends})
|
|
|
|
else()
|
|
|
|
list(APPEND object_lib_depends ${depends})
|
|
|
|
list(APPEND object_public_depends ${public_depends})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(obj_lib IN LISTS object_lib_depends)
|
|
|
|
target_compile_definitions(${target_name} PRIVATE $<TARGET_PROPERTY:${obj_lib},INTERFACE_COMPILE_DEFINITIONS>)
|
|
|
|
target_include_directories(${target_name} PRIVATE $<TARGET_PROPERTY:${obj_lib},INTERFACE_INCLUDE_DIRECTORIES>)
|
|
|
|
endforeach()
|
|
|
|
foreach(obj_lib IN LISTS object_public_depends)
|
|
|
|
target_compile_definitions(${target_name} PUBLIC $<TARGET_PROPERTY:${obj_lib},INTERFACE_COMPILE_DEFINITIONS>)
|
|
|
|
target_include_directories(${target_name} PUBLIC $<TARGET_PROPERTY:${obj_lib},INTERFACE_INCLUDE_DIRECTORIES>)
|
|
|
|
endforeach()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(find_dependent_plugins varName)
|
|
|
|
set(_RESULT ${ARGN})
|
|
|
|
|
|
|
|
foreach(i ${ARGN})
|
|
|
|
get_property(_dep TARGET "${i}" PROPERTY _arg_DEPENDS)
|
|
|
|
if (_dep)
|
|
|
|
find_dependent_plugins(_REC ${_dep})
|
|
|
|
list(APPEND _RESULT ${_REC})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if (_RESULT)
|
|
|
|
list(REMOVE_DUPLICATES _RESULT)
|
|
|
|
list(SORT _RESULT)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set("${varName}" ${_RESULT} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(qtc_plugin_enabled varName name)
|
|
|
|
if (NOT (name IN_LIST __QTC_PLUGINS))
|
|
|
|
message(FATAL_ERROR "extend_qtc_plugin: Unknown plugin target \"${name}\"")
|
|
|
|
endif()
|
|
|
|
if (TARGET ${name})
|
|
|
|
set(${varName} ON PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
set(${varName} OFF PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2020-02-05 15:55:21 +01:00
|
|
|
function(qtc_library_enabled varName name)
|
|
|
|
if (NOT (name IN_LIST __QTC_LIBRARIES))
|
|
|
|
message(FATAL_ERROR "extend_qtc_library: Unknown library target \"${name}\"")
|
|
|
|
endif()
|
|
|
|
if (TARGET ${name})
|
|
|
|
set(${varName} ON PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
set(${varName} OFF PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2019-07-13 11:57:35 +02:00
|
|
|
function(enable_pch target)
|
|
|
|
if (BUILD_WITH_PCH)
|
2019-10-11 13:14:42 +02:00
|
|
|
# Skip PCH for targets that do not use the expected visibility settings:
|
|
|
|
get_target_property(visibility_property "${target}" CXX_VISIBILITY_PRESET)
|
|
|
|
get_target_property(inlines_property "${target}" VISIBILITY_INLINES_HIDDEN)
|
|
|
|
|
|
|
|
if (NOT visibility_property STREQUAL "hidden" OR NOT inlines_property)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2020-02-14 11:59:15 +01:00
|
|
|
# Skip PCH for targets that do not have QT_NO_CAST_TO_ASCII
|
|
|
|
get_target_property(target_defines "${target}" COMPILE_DEFINITIONS)
|
|
|
|
if (NOT "QT_NO_CAST_TO_ASCII" IN_LIST target_defines)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2019-09-10 18:31:53 +02:00
|
|
|
get_target_property(target_type ${target} TYPE)
|
|
|
|
if (NOT ${target_type} STREQUAL "OBJECT_LIBRARY")
|
2019-07-13 11:57:35 +02:00
|
|
|
function(_recursively_collect_dependencies input_target)
|
|
|
|
get_target_property(input_type ${input_target} TYPE)
|
|
|
|
if (${input_type} STREQUAL "INTERFACE_LIBRARY")
|
|
|
|
set(prefix "INTERFACE_")
|
|
|
|
endif()
|
|
|
|
get_target_property(link_libraries ${input_target} ${prefix}LINK_LIBRARIES)
|
|
|
|
foreach(library IN LISTS link_libraries)
|
|
|
|
if(TARGET ${library} AND NOT ${library} IN_LIST dependencies)
|
|
|
|
list(APPEND dependencies ${library})
|
|
|
|
_recursively_collect_dependencies(${library})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
set(dependencies ${dependencies} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
_recursively_collect_dependencies(${target})
|
|
|
|
|
2019-09-10 18:31:53 +02:00
|
|
|
function(_add_pch_target pch_target pch_file pch_dependency)
|
|
|
|
if (EXISTS ${pch_file})
|
|
|
|
add_library(${pch_target} STATIC
|
2019-10-08 17:36:54 +02:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/empty_pch.cpp
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c)
|
2019-09-10 18:31:53 +02:00
|
|
|
target_compile_definitions(${pch_target} PRIVATE ${DEFAULT_DEFINES})
|
|
|
|
set_target_properties(${pch_target} PROPERTIES
|
2019-10-11 13:14:42 +02:00
|
|
|
PRECOMPILE_HEADERS ${pch_file}
|
|
|
|
CXX_VISIBILITY_PRESET hidden
|
|
|
|
VISIBILITY_INLINES_HIDDEN ON)
|
2019-09-10 18:31:53 +02:00
|
|
|
target_link_libraries(${pch_target} PRIVATE ${pch_dependency})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
if (NOT TARGET QtCreatorPchGui AND NOT TARGET QtCreatorPchConsole)
|
2019-10-08 17:36:54 +02:00
|
|
|
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c_cpp.in "/*empty file*/")
|
2019-09-10 18:31:53 +02:00
|
|
|
configure_file(
|
2019-10-08 17:36:54 +02:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c_cpp.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/empty_pch.cpp)
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c_cpp.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/empty_pch.c)
|
2019-09-10 18:31:53 +02:00
|
|
|
|
|
|
|
_add_pch_target(QtCreatorPchGui
|
|
|
|
"${PROJECT_SOURCE_DIR}/src/shared/qtcreator_gui_pch.h" Qt5::Widgets)
|
|
|
|
_add_pch_target(QtCreatorPchConsole
|
|
|
|
"${PROJECT_SOURCE_DIR}/src/shared/qtcreator_pch.h" Qt5::Core)
|
|
|
|
endif()
|
|
|
|
|
2019-09-27 22:52:15 +02:00
|
|
|
unset(PCH_TARGET)
|
2019-07-13 11:57:35 +02:00
|
|
|
if ("Qt5::Widgets" IN_LIST dependencies)
|
2019-09-10 18:31:53 +02:00
|
|
|
set(PCH_TARGET QtCreatorPchGui)
|
2019-09-27 22:52:15 +02:00
|
|
|
elseif ("Qt5::Core" IN_LIST dependencies)
|
|
|
|
set(PCH_TARGET QtCreatorPchConsole)
|
2019-07-13 11:57:35 +02:00
|
|
|
endif()
|
|
|
|
|
2019-09-27 22:52:15 +02:00
|
|
|
if (TARGET "${PCH_TARGET}")
|
2019-09-10 18:31:53 +02:00
|
|
|
set_target_properties(${target} PROPERTIES
|
|
|
|
PRECOMPILE_HEADERS_REUSE_FROM ${PCH_TARGET})
|
2019-07-13 11:57:35 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2019-08-19 11:10:20 +02:00
|
|
|
function(qtc_output_binary_dir varName)
|
|
|
|
if (QTC_MERGE_BINARY_DIR)
|
|
|
|
set(${varName} ${QtCreator_BINARY_DIR} PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
set(${varName} ${PROJECT_BINARY_DIR} PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2019-08-30 11:43:19 +02:00
|
|
|
function(condition_info varName condition)
|
|
|
|
if (NOT ${condition})
|
|
|
|
set(${varName} "" PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
string(REPLACE ";" " " _contents "${${condition}}")
|
|
|
|
set(${varName} "with CONDITION ${_contents}" PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
#
|
|
|
|
# Public API functions
|
|
|
|
#
|
|
|
|
|
|
|
|
function(add_qtc_library name)
|
2020-01-24 17:09:56 +01:00
|
|
|
cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION;BUILD_BY_DEFAULT;ALLOW_ASCII_CASTS"
|
2020-02-05 15:55:21 +01:00
|
|
|
"DESTINATION;COMPONENT"
|
2019-05-23 15:13:06 +02:00
|
|
|
"DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;PUBLIC_DEFINES;PUBLIC_DEPENDS;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;PROPERTIES" ${ARGN}
|
2019-06-26 17:51:06 +02:00
|
|
|
)
|
|
|
|
|
2020-01-24 17:09:56 +01:00
|
|
|
set(default_defines_copy ${DEFAULT_DEFINES})
|
|
|
|
if (_arg_ALLOW_ASCII_CASTS)
|
|
|
|
list(REMOVE_ITEM default_defines_copy QT_NO_CAST_TO_ASCII QT_RESTRICTED_CAST_FROM_ASCII)
|
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
if (${_arg_UNPARSED_ARGUMENTS})
|
|
|
|
message(FATAL_ERROR "add_qtc_library had unparsed arguments")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
update_cached_list(__QTC_LIBRARIES "${name}")
|
|
|
|
|
2020-02-05 15:55:21 +01:00
|
|
|
# special libraries can be turned off
|
|
|
|
if (_arg_BUILD_BY_DEFAULT)
|
|
|
|
string(TOUPPER "BUILD_LIBRARY_${name}" _build_library_var)
|
|
|
|
set(_build_library_default "ON")
|
|
|
|
if (DEFINED ENV{QTC_${_build_library_var}})
|
|
|
|
set(_build_library_default "$ENV{QTC_${_build_library_var}}")
|
|
|
|
endif()
|
|
|
|
set(${_build_library_var} "${_build_library_default}" CACHE BOOL "Build library ${name}.")
|
|
|
|
|
|
|
|
if (NOT ${_build_library_var})
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
compare_sources_with_existing_disk_files(${name} "${_arg_SOURCES}")
|
|
|
|
|
|
|
|
set(library_type SHARED)
|
|
|
|
if (_arg_STATIC)
|
|
|
|
set(library_type STATIC)
|
|
|
|
endif()
|
|
|
|
if (_arg_OBJECT)
|
|
|
|
set(library_type OBJECT)
|
|
|
|
endif()
|
|
|
|
|
2019-09-27 22:52:15 +02:00
|
|
|
set(_exclude_from_all EXCLUDE_FROM_ALL)
|
|
|
|
if (_arg_BUILD_BY_DEFAULT)
|
|
|
|
unset(_exclude_from_all)
|
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
# Do not just build libraries...
|
2019-09-27 22:52:15 +02:00
|
|
|
add_library(${name} ${library_type} ${_exclude_from_all} ${_arg_SOURCES})
|
2019-06-26 17:51:06 +02:00
|
|
|
add_library(${IDE_CASED_ID}::${name} ALIAS ${name})
|
|
|
|
set_public_headers(${name} "${_arg_SOURCES}")
|
|
|
|
|
2019-07-30 15:26:31 +02:00
|
|
|
if (${name} MATCHES "^[^0-9-]+$")
|
2019-06-26 17:51:06 +02:00
|
|
|
string(TOUPPER "${name}_LIBRARY" EXPORT_SYMBOL)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (WITH_TESTS)
|
|
|
|
set(TEST_DEFINES WITH_TESTS SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
file(RELATIVE_PATH include_dir_relative_path ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
target_include_directories(${name}
|
|
|
|
PRIVATE ${_arg_INCLUDES}
|
|
|
|
PUBLIC
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>"
|
|
|
|
"$<INSTALL_INTERFACE:include/${include_dir_relative_path}>"
|
|
|
|
"$<INSTALL_INTERFACE:include/${include_dir_relative_path}/..>"
|
|
|
|
)
|
|
|
|
set_public_includes(${name} "${_arg_PUBLIC_INCLUDES}")
|
|
|
|
|
|
|
|
target_compile_definitions(${name}
|
2020-01-24 17:09:56 +01:00
|
|
|
PRIVATE ${EXPORT_SYMBOL} ${default_defines_copy} ${_arg_DEFINES} ${TEST_DEFINES}
|
2019-06-26 17:51:06 +02:00
|
|
|
PUBLIC ${_arg_PUBLIC_DEFINES}
|
|
|
|
)
|
|
|
|
|
|
|
|
add_qtc_depends(${name}
|
2019-09-23 17:58:34 +02:00
|
|
|
PRIVATE ${_arg_DEPENDS} ${IMPLICIT_DEPENDS}
|
2019-06-26 17:51:06 +02:00
|
|
|
PUBLIC ${_arg_PUBLIC_DEPENDS}
|
|
|
|
)
|
|
|
|
|
|
|
|
foreach(file IN LISTS _arg_EXPLICIT_MOC)
|
|
|
|
set_explicit_moc(${name} "${file}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(file IN LISTS _arg_SKIP_AUTOMOC)
|
|
|
|
set_property(SOURCE ${file} PROPERTY SKIP_AUTOMOC ON)
|
|
|
|
endforeach()
|
|
|
|
|
2019-05-23 15:13:06 +02:00
|
|
|
set(skip_translation OFF)
|
|
|
|
if (_arg_SKIP_TRANSLATION)
|
|
|
|
set(skip_translation ON)
|
|
|
|
endif()
|
|
|
|
|
2019-09-27 22:52:15 +02:00
|
|
|
set(_DESTINATION "${IDE_BIN_PATH}")
|
|
|
|
if (_arg_DESTINATION)
|
|
|
|
set(_DESTINATION "${_arg_DESTINATION}")
|
|
|
|
endif()
|
|
|
|
|
2019-08-19 11:10:20 +02:00
|
|
|
qtc_output_binary_dir(_output_binary_dir)
|
2019-06-26 17:51:06 +02:00
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
VERSION "${IDE_VERSION}"
|
2020-01-14 16:03:47 +01:00
|
|
|
SOVERSION "${PROJECT_VERSION_MAJOR}"
|
2019-06-26 17:51:06 +02:00
|
|
|
CXX_VISIBILITY_PRESET hidden
|
|
|
|
VISIBILITY_INLINES_HIDDEN ON
|
|
|
|
BUILD_RPATH "${_LIB_RPATH}"
|
|
|
|
INSTALL_RPATH "${_LIB_RPATH}"
|
2019-09-27 22:52:15 +02:00
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${_DESTINATION}"
|
2019-08-19 11:10:20 +02:00
|
|
|
LIBRARY_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_LIBRARY_PATH}"
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY "${_output_binary_dir}/${IDE_LIBRARY_PATH}"
|
2019-06-26 17:51:06 +02:00
|
|
|
${_arg_PROPERTIES}
|
|
|
|
)
|
2019-07-13 11:57:35 +02:00
|
|
|
enable_pch(${name})
|
2019-06-26 17:51:06 +02:00
|
|
|
|
2020-01-15 16:54:52 +01:00
|
|
|
if (WIN32 AND library_type STREQUAL "SHARED")
|
2020-01-14 17:48:58 +01:00
|
|
|
# Match qmake naming scheme e.g. Library4.dll
|
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
SUFFIX "${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}"
|
|
|
|
PREFIX ""
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
unset(NAMELINK_OPTION)
|
|
|
|
if (library_type STREQUAL "SHARED")
|
|
|
|
set(NAMELINK_OPTION NAMELINK_SKIP)
|
|
|
|
endif()
|
|
|
|
|
2020-02-05 15:55:21 +01:00
|
|
|
unset(COMPONENT_OPTION)
|
|
|
|
if (_arg_COMPONENT)
|
|
|
|
set(COMPONENT_OPTION "COMPONENT" "${_arg_COMPONENT}")
|
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
install(TARGETS ${name}
|
|
|
|
EXPORT ${IDE_CASED_ID}
|
2020-02-05 15:55:21 +01:00
|
|
|
RUNTIME
|
|
|
|
DESTINATION "${_DESTINATION}"
|
|
|
|
${COMPONENT_OPTION}
|
|
|
|
OPTIONAL
|
2019-06-26 17:51:06 +02:00
|
|
|
LIBRARY
|
|
|
|
DESTINATION "${IDE_LIBRARY_PATH}"
|
|
|
|
${NAMELINK_OPTION}
|
2020-02-05 15:55:21 +01:00
|
|
|
${COMPONENT_OPTION}
|
2019-12-03 14:15:55 +01:00
|
|
|
OPTIONAL
|
2019-06-26 17:51:06 +02:00
|
|
|
OBJECTS
|
|
|
|
DESTINATION "${IDE_LIBRARY_PATH}"
|
|
|
|
COMPONENT Devel EXCLUDE_FROM_ALL
|
|
|
|
ARCHIVE
|
|
|
|
DESTINATION "${IDE_LIBRARY_PATH}"
|
|
|
|
COMPONENT Devel EXCLUDE_FROM_ALL
|
2019-12-03 14:15:55 +01:00
|
|
|
OPTIONAL
|
2019-06-26 17:51:06 +02:00
|
|
|
)
|
|
|
|
|
2020-01-29 13:15:50 +01:00
|
|
|
if (library_type STREQUAL "SHARED")
|
|
|
|
set(target_prefix ${CMAKE_SHARED_LIBRARY_PREFIX})
|
|
|
|
if (WIN32)
|
|
|
|
set(target_suffix ${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX})
|
|
|
|
set(target_prefix "")
|
|
|
|
elseif(APPLE)
|
|
|
|
set(target_suffix .${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX})
|
|
|
|
else()
|
|
|
|
set(target_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX}.${PROJECT_VERSION_MAJOR})
|
|
|
|
endif()
|
|
|
|
set(lib_dir "${IDE_LIBRARY_PATH}")
|
|
|
|
if (WIN32)
|
|
|
|
set(lib_dir "${_DESTINATION}")
|
|
|
|
endif()
|
|
|
|
update_cached_list(__QTC_INSTALLED_LIBRARIES
|
|
|
|
"${lib_dir}/${target_prefix}${name}${target_suffix}")
|
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
if (NAMELINK_OPTION)
|
|
|
|
install(TARGETS ${name}
|
|
|
|
LIBRARY
|
|
|
|
DESTINATION "${IDE_LIBRARY_PATH}"
|
|
|
|
NAMELINK_ONLY
|
|
|
|
COMPONENT Devel EXCLUDE_FROM_ALL
|
2019-12-03 14:15:55 +01:00
|
|
|
OPTIONAL
|
2019-06-26 17:51:06 +02:00
|
|
|
)
|
|
|
|
endif()
|
2019-05-23 15:13:06 +02:00
|
|
|
|
|
|
|
append_extra_translations("${name}" "${_arg_EXTRA_TRANSLATIONS}")
|
2019-06-26 17:51:06 +02:00
|
|
|
endfunction(add_qtc_library)
|
|
|
|
|
|
|
|
function(add_qtc_plugin target_name)
|
|
|
|
cmake_parse_arguments(_arg
|
2019-05-23 15:13:06 +02:00
|
|
|
"EXPERIMENTAL;SKIP_DEBUG_CMAKE_FILE_CHECK;SKIP_INSTALL;INTERNAL_ONLY;SKIP_TRANSLATION"
|
2019-06-26 17:51:06 +02:00
|
|
|
"VERSION;COMPAT_VERSION;PLUGIN_JSON_IN;PLUGIN_PATH;PLUGIN_NAME;OUTPUT_NAME"
|
2019-05-23 15:13:06 +02:00
|
|
|
"CONDITION;DEPENDS;EXTRA_TRANSLATIONS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;PUBLIC_INCLUDES;PLUGIN_DEPENDS;PLUGIN_RECOMMENDS;SOURCES;EXPLICIT_MOC"
|
2019-06-26 17:51:06 +02:00
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
|
|
|
if (${_arg_UNPARSED_ARGUMENTS})
|
|
|
|
message(FATAL_ERROR "add_qtc_plugin had unparsed arguments")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
update_cached_list(__QTC_PLUGINS "${target_name}")
|
|
|
|
|
|
|
|
set(name ${target_name})
|
|
|
|
if (_arg_PLUGIN_NAME)
|
|
|
|
set(name ${_arg_PLUGIN_NAME})
|
|
|
|
endif()
|
|
|
|
|
2019-08-30 11:43:19 +02:00
|
|
|
condition_info(_extra_text _arg_CONDITION)
|
2019-06-26 17:51:06 +02:00
|
|
|
if (NOT _arg_CONDITION)
|
|
|
|
set(_arg_CONDITION ON)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
string(TOUPPER "BUILD_PLUGIN_${target_name}" _build_plugin_var)
|
|
|
|
set(_build_plugin_default "ON")
|
|
|
|
if (DEFINED ENV{QTC_${_build_plugin_var}})
|
|
|
|
set(_build_plugin_default "$ENV{QTC_${_build_plugin_var}}")
|
|
|
|
endif()
|
2019-08-07 10:46:06 +02:00
|
|
|
if (_arg_INTERNAL_ONLY)
|
|
|
|
set(${_build_plugin_var} "${_build_plugin_default}")
|
|
|
|
else()
|
|
|
|
set(${_build_plugin_var} "${_build_plugin_default}" CACHE BOOL "Build plugin ${name}.")
|
|
|
|
endif()
|
2019-06-26 17:51:06 +02:00
|
|
|
|
|
|
|
if ((${_arg_CONDITION}) AND ${_build_plugin_var})
|
|
|
|
set(_plugin_enabled ON)
|
|
|
|
else()
|
|
|
|
set(_plugin_enabled OFF)
|
|
|
|
endif()
|
|
|
|
|
2019-08-07 10:46:06 +02:00
|
|
|
if (NOT _arg_INTERNAL_ONLY)
|
|
|
|
add_feature_info("Plugin ${name}" _plugin_enabled "${_extra_text}")
|
|
|
|
endif()
|
2019-06-26 17:51:06 +02:00
|
|
|
if (NOT _plugin_enabled)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
### Generate plugin.json file:
|
|
|
|
if (NOT _arg_VERSION)
|
|
|
|
set(_arg_VERSION ${IDE_VERSION})
|
|
|
|
endif()
|
|
|
|
if (NOT _arg_COMPAT_VERSION)
|
|
|
|
set(_arg_COMPAT_VERSION ${_arg_VERSION})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT _arg_SKIP_DEBUG_CMAKE_FILE_CHECK)
|
|
|
|
compare_sources_with_existing_disk_files(${target_name} "${_arg_SOURCES}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Generate dependency list:
|
|
|
|
find_dependent_plugins(_DEP_PLUGINS ${_arg_PLUGIN_DEPENDS})
|
|
|
|
|
|
|
|
set(_arg_DEPENDENCY_STRING "\"Dependencies\" : [\n")
|
|
|
|
foreach(i IN LISTS _DEP_PLUGINS)
|
|
|
|
if (i MATCHES "^${IDE_CASED_ID}::")
|
|
|
|
set(_v ${IDE_VERSION})
|
|
|
|
string(REPLACE "${IDE_CASED_ID}::" "" i ${i})
|
|
|
|
else()
|
|
|
|
get_property(_v TARGET "${i}" PROPERTY _arg_VERSION)
|
|
|
|
endif()
|
|
|
|
string(APPEND _arg_DEPENDENCY_STRING
|
|
|
|
" { \"Name\" : \"${i}\", \"Version\" : \"${_v}\" }"
|
|
|
|
)
|
|
|
|
endforeach(i)
|
|
|
|
string(REPLACE "} {" "},\n {"
|
|
|
|
_arg_DEPENDENCY_STRING "${_arg_DEPENDENCY_STRING}"
|
|
|
|
)
|
|
|
|
foreach(i IN LISTS ${_arg_RECOMMENDS})
|
|
|
|
if (i MATCHES "^${IDE_CASED_ID}::")
|
|
|
|
set(_v ${IDE_VERSION})
|
|
|
|
string(REPLACE "${IDE_CASED_ID}::" "" i ${i})
|
|
|
|
else()
|
|
|
|
get_property(_v TARGET "${i}" PROPERTY _arg_VERSION)
|
|
|
|
endif()
|
|
|
|
string(APPEND _arg_DEPENDENCY_STRING
|
|
|
|
" { \"Name\" : \"${i}\", \"Version\" : \"${_v}\", \"Type\" : \"optional\" }"
|
|
|
|
)
|
|
|
|
endforeach(i)
|
|
|
|
string(APPEND _arg_DEPENDENCY_STRING "\n ]")
|
|
|
|
if (_arg_EXPERIMENTAL)
|
|
|
|
string(APPEND _arg_DEPENDENCY_STRING ",\n \"Experimental\" : true")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(IDE_PLUGIN_DEPENDENCY_STRING ${_arg_DEPENDENCY_STRING})
|
|
|
|
|
|
|
|
### Configure plugin.json file:
|
|
|
|
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.json.in")
|
|
|
|
file(READ "${name}.json.in" plugin_json_in)
|
|
|
|
string(REPLACE "\\\"" "\"" plugin_json_in ${plugin_json_in})
|
|
|
|
string(REPLACE "\\'" "'" plugin_json_in ${plugin_json_in})
|
|
|
|
string(REPLACE "$$QTCREATOR_VERSION" "\${IDE_VERSION}" plugin_json_in ${plugin_json_in})
|
|
|
|
string(REPLACE "$$QTCREATOR_COMPAT_VERSION" "\${IDE_VERSION_COMPAT}" plugin_json_in ${plugin_json_in})
|
|
|
|
string(REPLACE "$$QTCREATOR_COPYRIGHT_YEAR" "\${IDE_COPYRIGHT_YEAR}" plugin_json_in ${plugin_json_in})
|
|
|
|
string(REPLACE "$$dependencyList" "\${IDE_PLUGIN_DEPENDENCY_STRING}" plugin_json_in ${plugin_json_in})
|
|
|
|
if(_arg_PLUGIN_JSON_IN)
|
|
|
|
#e.g. UPDATEINFO_EXPERIMENTAL_STR=true
|
|
|
|
string(REGEX REPLACE "=.*$" "" json_key ${_arg_PLUGIN_JSON_IN})
|
|
|
|
string(REGEX REPLACE "^.*=" "" json_value ${_arg_PLUGIN_JSON_IN})
|
|
|
|
string(REPLACE "$$${json_key}" "${json_value}" plugin_json_in ${plugin_json_in})
|
|
|
|
endif()
|
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${name}.json.cmakein" ${plugin_json_in})
|
|
|
|
|
|
|
|
configure_file("${CMAKE_CURRENT_BINARY_DIR}/${name}.json.cmakein" "${name}.json")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_library(${target_name} SHARED ${_arg_SOURCES})
|
|
|
|
add_library(${IDE_CASED_ID}::${target_name} ALIAS ${target_name})
|
|
|
|
set_public_headers(${target_name} "${_arg_SOURCES}")
|
|
|
|
|
|
|
|
### Generate EXPORT_SYMBOL
|
|
|
|
string(TOUPPER "${name}_LIBRARY" EXPORT_SYMBOL)
|
|
|
|
|
|
|
|
if (WITH_TESTS)
|
|
|
|
set(TEST_DEFINES WITH_TESTS SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
file(RELATIVE_PATH include_dir_relative_path ${PROJECT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
target_include_directories(${target_name}
|
|
|
|
PRIVATE
|
|
|
|
${_arg_INCLUDES}
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
"${CMAKE_BINARY_DIR}/src"
|
|
|
|
PUBLIC
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
|
|
|
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>"
|
|
|
|
"$<INSTALL_INTERFACE:include/${include_dir_relative_path}>"
|
|
|
|
"$<INSTALL_INTERFACE:include/${include_dir_relative_path}/..>"
|
|
|
|
)
|
|
|
|
set_public_includes(${target_name} "${_arg_PUBLIC_INCLUDES}")
|
|
|
|
|
|
|
|
target_compile_definitions(${target_name}
|
|
|
|
PRIVATE ${EXPORT_SYMBOL} ${DEFAULT_DEFINES} ${_arg_DEFINES} ${TEST_DEFINES}
|
2019-07-31 14:23:31 +02:00
|
|
|
PUBLIC ${_arg_PUBLIC_DEFINES}
|
2019-06-26 17:51:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
add_qtc_depends(${target_name}
|
2019-09-23 17:58:34 +02:00
|
|
|
PRIVATE ${_arg_DEPENDS} ${_DEP_PLUGINS} ${IMPLICIT_DEPENDS}
|
2019-06-26 17:51:06 +02:00
|
|
|
PUBLIC ${_arg_PUBLIC_DEPENDS}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(plugin_dir "${IDE_PLUGIN_PATH}")
|
|
|
|
if (_arg_PLUGIN_PATH)
|
|
|
|
set(plugin_dir "${_arg_PLUGIN_PATH}")
|
|
|
|
endif()
|
|
|
|
|
2019-05-23 15:13:06 +02:00
|
|
|
set(skip_translation OFF)
|
|
|
|
if (_arg_SKIP_TRANSLATION)
|
|
|
|
set(skip_translation ON)
|
|
|
|
endif()
|
|
|
|
|
2019-08-19 11:10:20 +02:00
|
|
|
qtc_output_binary_dir(_output_binary_dir)
|
2019-06-26 17:51:06 +02:00
|
|
|
set_target_properties(${target_name} PROPERTIES
|
|
|
|
SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
CXX_VISIBILITY_PRESET hidden
|
|
|
|
VISIBILITY_INLINES_HIDDEN ON
|
|
|
|
_arg_DEPENDS "${_arg_PLUGIN_DEPENDS}"
|
|
|
|
_arg_VERSION "${_arg_VERSION}"
|
|
|
|
BUILD_RPATH "${_PLUGIN_RPATH}"
|
|
|
|
INSTALL_RPATH "${_PLUGIN_RPATH}"
|
2019-08-19 11:10:20 +02:00
|
|
|
LIBRARY_OUTPUT_DIRECTORY "${_output_binary_dir}/${plugin_dir}"
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY "${_output_binary_dir}/${plugin_dir}"
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${plugin_dir}"
|
2019-06-26 17:51:06 +02:00
|
|
|
OUTPUT_NAME "${name}"
|
2019-05-23 15:13:06 +02:00
|
|
|
QT_SKIP_TRANSLATION "${skip_translation}"
|
2019-06-26 17:51:06 +02:00
|
|
|
${_arg_PROPERTIES}
|
|
|
|
)
|
2020-01-14 17:48:58 +01:00
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
# Match qmake naming scheme e.g. Plugin4.dll
|
|
|
|
set_target_properties(${target_name} PROPERTIES
|
|
|
|
SUFFIX "${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}"
|
|
|
|
PREFIX ""
|
|
|
|
)
|
|
|
|
endif()
|
2019-05-23 15:13:06 +02:00
|
|
|
append_extra_translations("${target_name}" "${_arg_EXTRA_TRANSLATIONS}")
|
2019-07-13 11:57:35 +02:00
|
|
|
enable_pch(${target_name})
|
2019-06-26 17:51:06 +02:00
|
|
|
|
|
|
|
foreach(file IN LISTS _arg_EXPLICIT_MOC)
|
|
|
|
set_explicit_moc(${target_name} "${file}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if (NOT _arg_SKIP_INSTALL)
|
|
|
|
install(TARGETS ${target_name}
|
|
|
|
EXPORT ${IDE_CASED_ID}
|
2019-12-03 14:15:55 +01:00
|
|
|
RUNTIME DESTINATION "${plugin_dir}" OPTIONAL
|
|
|
|
LIBRARY DESTINATION "${plugin_dir}" OPTIONAL
|
2019-06-26 17:51:06 +02:00
|
|
|
ARCHIVE
|
|
|
|
DESTINATION "${plugin_dir}"
|
|
|
|
COMPONENT Devel EXCLUDE_FROM_ALL
|
2019-12-03 14:15:55 +01:00
|
|
|
OPTIONAL
|
2019-06-26 17:51:06 +02:00
|
|
|
)
|
2020-01-29 13:15:50 +01:00
|
|
|
get_target_property(target_suffix ${target_name} SUFFIX)
|
|
|
|
get_target_property(target_prefix ${target_name} PREFIX)
|
|
|
|
if (target_suffix STREQUAL "target_suffix-NOTFOUND")
|
|
|
|
set(target_suffix ${CMAKE_SHARED_LIBRARY_SUFFIX})
|
|
|
|
endif()
|
|
|
|
if (target_prefix STREQUAL "target_prefix-NOTFOUND")
|
|
|
|
set(target_prefix ${CMAKE_SHARED_LIBRARY_PREFIX})
|
|
|
|
endif()
|
|
|
|
update_cached_list(__QTC_INSTALLED_PLUGINS
|
|
|
|
"${plugin_dir}/${target_prefix}${target_name}${target_suffix}")
|
2019-06-26 17:51:06 +02:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(extend_qtc_target target_name)
|
|
|
|
cmake_parse_arguments(_arg
|
|
|
|
""
|
2019-08-30 11:43:19 +02:00
|
|
|
"SOURCES_PREFIX;FEATURE_INFO"
|
2019-07-31 14:23:31 +02:00
|
|
|
"CONDITION;DEPENDS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC"
|
2019-06-26 17:51:06 +02:00
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
|
|
|
if (${_arg_UNPARSED_ARGUMENTS})
|
|
|
|
message(FATAL_ERROR "extend_qtc_target had unparsed arguments")
|
|
|
|
endif()
|
|
|
|
|
2019-08-30 11:43:19 +02:00
|
|
|
condition_info(_extra_text _arg_CONDITION)
|
2019-06-26 17:51:06 +02:00
|
|
|
if (NOT _arg_CONDITION)
|
|
|
|
set(_arg_CONDITION ON)
|
|
|
|
endif()
|
2019-09-18 15:47:42 +02:00
|
|
|
if (${_arg_CONDITION})
|
|
|
|
set(_feature_enabled ON)
|
|
|
|
else()
|
|
|
|
set(_feature_enabled OFF)
|
|
|
|
endif()
|
2019-08-30 11:43:19 +02:00
|
|
|
if (_arg_FEATURE_INFO)
|
2019-09-18 15:47:42 +02:00
|
|
|
add_feature_info(${_arg_FEATURE_INFO} _feature_enabled "${_extra_text}")
|
2019-08-30 11:43:19 +02:00
|
|
|
endif()
|
2019-09-18 15:47:42 +02:00
|
|
|
if (NOT _feature_enabled)
|
2019-06-26 17:51:06 +02:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_qtc_depends(${target_name}
|
|
|
|
PRIVATE ${_arg_DEPENDS}
|
|
|
|
PUBLIC ${_arg_PUBLIC_DEPENDS}
|
|
|
|
)
|
2019-07-31 14:23:31 +02:00
|
|
|
target_compile_definitions(${target_name}
|
|
|
|
PRIVATE ${_arg_DEFINES}
|
|
|
|
PUBLIC ${_arg_PUBLIC_DEFINES}
|
|
|
|
)
|
2019-06-26 17:51:06 +02:00
|
|
|
target_include_directories(${target_name} PRIVATE ${_arg_INCLUDES})
|
|
|
|
|
|
|
|
set_public_includes(${target_name} "${_arg_PUBLIC_INCLUDES}")
|
|
|
|
|
|
|
|
if (_arg_SOURCES_PREFIX)
|
|
|
|
foreach(source IN LISTS _arg_SOURCES)
|
|
|
|
list(APPEND prefixed_sources "${_arg_SOURCES_PREFIX}/${source}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
if (NOT IS_ABSOLUTE ${_arg_SOURCES_PREFIX})
|
|
|
|
set(_arg_SOURCES_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/${_arg_SOURCES_PREFIX}")
|
|
|
|
endif()
|
|
|
|
target_include_directories(${target_name} PUBLIC $<BUILD_INTERFACE:${_arg_SOURCES_PREFIX}>)
|
|
|
|
|
|
|
|
set(_arg_SOURCES ${prefixed_sources})
|
|
|
|
endif()
|
|
|
|
target_sources(${target_name} PRIVATE ${_arg_SOURCES})
|
2019-07-13 11:57:35 +02:00
|
|
|
|
|
|
|
if (APPLE AND BUILD_WITH_PCH)
|
|
|
|
foreach(source IN LISTS _arg_SOURCES)
|
|
|
|
if (source MATCHES "^.*\.mm$")
|
|
|
|
set_source_files_properties(${source} PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
set_public_headers(${target_name} "${_arg_SOURCES}")
|
|
|
|
|
|
|
|
foreach(file IN LISTS _arg_EXPLICIT_MOC)
|
|
|
|
set_explicit_moc(${target_name} "${file}")
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(extend_qtc_plugin target_name)
|
|
|
|
qtc_plugin_enabled(_plugin_enabled ${target_name})
|
|
|
|
if (NOT _plugin_enabled)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
extend_qtc_target(${target_name} ${ARGN})
|
|
|
|
endfunction()
|
|
|
|
|
2020-02-05 15:55:21 +01:00
|
|
|
function(extend_qtc_library target_name)
|
|
|
|
qtc_library_enabled(_library_enabled ${target_name})
|
|
|
|
if (NOT _library_enabled)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
extend_qtc_target(${target_name} ${ARGN})
|
|
|
|
endfunction()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
function(add_qtc_executable name)
|
2020-01-24 17:09:56 +01:00
|
|
|
cmake_parse_arguments(_arg "SKIP_INSTALL;SKIP_TRANSLATION;ALLOW_ASCII_CASTS"
|
2020-02-05 15:55:21 +01:00
|
|
|
"DESTINATION;COMPONENT"
|
2019-05-23 15:13:06 +02:00
|
|
|
"DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;SOURCES;PROPERTIES" ${ARGN})
|
2019-06-26 17:51:06 +02:00
|
|
|
|
|
|
|
if ($_arg_UNPARSED_ARGUMENTS)
|
|
|
|
message(FATAL_ERROR "add_qtc_executable had unparsed arguments!")
|
|
|
|
endif()
|
|
|
|
|
2020-01-24 17:09:56 +01:00
|
|
|
set(default_defines_copy ${DEFAULT_DEFINES})
|
|
|
|
if (_arg_ALLOW_ASCII_CASTS)
|
|
|
|
list(REMOVE_ITEM default_defines_copy QT_NO_CAST_TO_ASCII QT_RESTRICTED_CAST_FROM_ASCII)
|
|
|
|
endif()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
update_cached_list(__QTC_EXECUTABLES "${name}")
|
|
|
|
|
|
|
|
string(TOUPPER "BUILD_EXECUTABLE_${name}" _build_executable_var)
|
|
|
|
set(_build_executable_default "ON")
|
|
|
|
if (DEFINED ENV{QTC_${_build_executable_var}})
|
|
|
|
set(_build_executable_default "$ENV{QTC_${_build_executable_var}}")
|
|
|
|
endif()
|
|
|
|
set(${_build_executable_var} "${_build_executable_default}" CACHE BOOL "Build executable ${name}.")
|
|
|
|
|
|
|
|
if (NOT ${_build_executable_var})
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(_DESTINATION "${IDE_LIBEXEC_PATH}")
|
|
|
|
if (_arg_DESTINATION)
|
|
|
|
set(_DESTINATION "${_arg_DESTINATION}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(_EXECUTABLE_PATH "${_DESTINATION}")
|
|
|
|
if (APPLE)
|
|
|
|
# path of executable might be inside app bundle instead of DESTINATION directly
|
|
|
|
cmake_parse_arguments(_prop "" "MACOSX_BUNDLE;OUTPUT_NAME" "" "${_arg_PROPERTIES}")
|
|
|
|
if (_prop_MACOSX_BUNDLE)
|
|
|
|
set(_BUNDLE_NAME "${name}")
|
|
|
|
if (_prop_OUTPUT_NAME)
|
|
|
|
set(_BUNDLE_NAME "${_prop_OUTPUT_NAME}")
|
|
|
|
endif()
|
|
|
|
set(_EXECUTABLE_PATH "${_DESTINATION}/${_BUNDLE_NAME}.app/Contents/MacOS")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_executable("${name}" ${_arg_SOURCES})
|
|
|
|
target_include_directories("${name}" PRIVATE "${CMAKE_BINARY_DIR}/src" ${_arg_INCLUDES})
|
2020-01-24 17:09:56 +01:00
|
|
|
target_compile_definitions("${name}" PRIVATE ${default_defines_copy} ${TEST_DEFINES} ${_arg_DEFINES} )
|
2019-09-23 17:58:34 +02:00
|
|
|
target_link_libraries("${name}" PRIVATE ${_arg_DEPENDS} ${IMPLICIT_DEPENDS})
|
2019-05-23 15:13:06 +02:00
|
|
|
|
|
|
|
set(skip_translation OFF)
|
|
|
|
if (_arg_SKIP_TRANSLATION)
|
|
|
|
set(skip_translation ON)
|
|
|
|
endif()
|
|
|
|
|
2020-02-04 13:22:28 +01:00
|
|
|
file(RELATIVE_PATH relative_lib_path "/${_EXECUTABLE_PATH}" "/${IDE_LIBRARY_PATH}")
|
|
|
|
|
|
|
|
set(build_rpath "${_RPATH_BASE}/${relative_lib_path}")
|
|
|
|
set(install_rpath "${_RPATH_BASE}/${relative_lib_path}")
|
|
|
|
if (NOT WIN32 AND NOT APPLE)
|
|
|
|
file(RELATIVE_PATH relative_qt_path "/${_EXECUTABLE_PATH}" "/${IDE_LIBRARY_BASE_PATH}/Qt/lib")
|
|
|
|
file(RELATIVE_PATH relative_plugins_path "/${_EXECUTABLE_PATH}" "/${IDE_PLUGIN_PATH}")
|
|
|
|
set(install_rpath "${install_rpath};${_RPATH_BASE}/${relative_qt_path};${_RPATH_BASE}/${relative_plugins_path}")
|
|
|
|
endif()
|
|
|
|
|
2019-08-19 11:10:20 +02:00
|
|
|
qtc_output_binary_dir(_output_binary_dir)
|
2019-06-26 17:51:06 +02:00
|
|
|
set_target_properties("${name}" PROPERTIES
|
2020-02-04 13:22:28 +01:00
|
|
|
BUILD_RPATH "${build_rpath}"
|
|
|
|
INSTALL_RPATH "${install_rpath}"
|
2019-08-19 11:10:20 +02:00
|
|
|
RUNTIME_OUTPUT_DIRECTORY "${_output_binary_dir}/${_DESTINATION}"
|
2019-05-23 15:13:06 +02:00
|
|
|
QT_SKIP_TRANSLATION "${skip_translation}"
|
2019-10-11 13:15:11 +02:00
|
|
|
CXX_VISIBILITY_PRESET hidden
|
|
|
|
VISIBILITY_INLINES_HIDDEN ON
|
2019-06-26 17:51:06 +02:00
|
|
|
${_arg_PROPERTIES}
|
|
|
|
)
|
2019-05-23 15:13:06 +02:00
|
|
|
append_extra_translations("${name}" "${_arg_EXTRA_TRANSLATIONS}")
|
2019-07-13 11:57:35 +02:00
|
|
|
enable_pch(${name})
|
2019-06-26 17:51:06 +02:00
|
|
|
|
|
|
|
if (NOT _arg_SKIP_INSTALL)
|
2020-02-05 15:55:21 +01:00
|
|
|
unset(COMPONENT_OPTION)
|
|
|
|
if (_arg_COMPONENT)
|
|
|
|
set(COMPONENT_OPTION "COMPONENT" "${_arg_COMPONENT}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(TARGETS ${name}
|
|
|
|
DESTINATION "${_DESTINATION}"
|
|
|
|
${COMPONENT_OPTION}
|
|
|
|
OPTIONAL
|
|
|
|
)
|
2020-01-29 13:15:50 +01:00
|
|
|
update_cached_list(__QTC_INSTALLED_EXECUTABLES
|
|
|
|
"${_DESTINATION}/${name}${CMAKE_EXECUTABLE_SUFFIX}")
|
2020-02-06 13:17:20 +01:00
|
|
|
|
|
|
|
install(CODE "
|
|
|
|
function(create_qt_conf location base_dir)
|
|
|
|
get_filename_component(install_prefix \"\${CMAKE_INSTALL_PREFIX}\" ABSOLUTE)
|
|
|
|
file(RELATIVE_PATH qt_conf_binaries
|
|
|
|
\"\${install_prefix}/\${location}\"
|
|
|
|
\"\${install_prefix}/\${base_dir}\"
|
|
|
|
)
|
|
|
|
if (NOT qt_conf_binaries)
|
|
|
|
set(qt_conf_binaries .)
|
|
|
|
endif()
|
|
|
|
file(RELATIVE_PATH qt_conf_plugins
|
|
|
|
\"\${install_prefix}/\${base_dir}\"
|
|
|
|
\"\${install_prefix}/${QT_DEST_PLUGIN_PATH}\"
|
|
|
|
)
|
|
|
|
file(RELATIVE_PATH qt_conf_qml
|
|
|
|
\"\${install_prefix}/\${base_dir}\"
|
|
|
|
\"\${install_prefix}/${QT_DEST_QML_PATH}\"
|
|
|
|
)
|
|
|
|
file(WRITE \"\${CMAKE_INSTALL_PREFIX}/\${location}/qt.conf\"
|
|
|
|
\"[Paths]\n\"
|
|
|
|
\"Plugins=\${qt_conf_plugins}\n\"
|
|
|
|
\"Qml2Imports=\${qt_conf_qml}\n\"
|
|
|
|
)
|
|
|
|
# For Apple for Qt Creator do not add a Prefix
|
|
|
|
if (NOT APPLE OR NOT qt_conf_binaries STREQUAL \"../\")
|
|
|
|
file(APPEND \"\${CMAKE_INSTALL_PREFIX}/\${location}/qt.conf\"
|
|
|
|
\"Prefix=\${qt_conf_binaries}\n\"
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
endfunction()
|
|
|
|
if(APPLE)
|
|
|
|
create_qt_conf(\"${_EXECUTABLE_PATH}\" \"${IDE_DATA_PATH}/..\")
|
|
|
|
elseif (WIN32)
|
|
|
|
create_qt_conf(\"${_EXECUTABLE_PATH}\" \"${IDE_APP_PATH}\")
|
|
|
|
else()
|
|
|
|
create_qt_conf(\"${_EXECUTABLE_PATH}\" \"${IDE_LIBRARY_BASE_PATH}/Qt\")
|
|
|
|
endif()
|
|
|
|
"
|
2020-02-12 08:24:50 +01:00
|
|
|
COMPONENT Dependencies
|
2020-02-13 12:29:04 +01:00
|
|
|
EXCLUDE_FROM_ALL
|
2020-02-06 13:17:20 +01:00
|
|
|
)
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(extend_qtc_executable name)
|
|
|
|
if (NOT (name IN_LIST __QTC_EXECUTABLES))
|
|
|
|
message(FATAL_ERROR "extend_qtc_executable: Unknown executable target \"${name}\"")
|
|
|
|
endif()
|
|
|
|
if (TARGET ${name})
|
|
|
|
extend_qtc_target(${name} ${ARGN})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(add_qtc_test name)
|
|
|
|
cmake_parse_arguments(_arg "GTEST" "" "DEFINES;DEPENDS;INCLUDES;SOURCES" ${ARGN})
|
|
|
|
|
2020-01-16 17:11:41 +01:00
|
|
|
foreach(dependency ${_arg_DEPENDS})
|
2020-01-24 17:09:56 +01:00
|
|
|
if (NOT TARGET ${dependency} AND NOT _arg_GTEST)
|
|
|
|
if (WITH_DEBUG_CMAKE)
|
|
|
|
message(STATUS "'${dependency}' is not a target")
|
|
|
|
endif()
|
2020-01-16 17:11:41 +01:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2019-06-26 17:51:06 +02:00
|
|
|
if ($_arg_UNPARSED_ARGUMENTS)
|
|
|
|
message(FATAL_ERROR "add_qtc_test had unparsed arguments!")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
update_cached_list(__QTC_TESTS "${name}")
|
|
|
|
|
|
|
|
set(TEST_DEFINES SRCDIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
|
|
|
file(RELATIVE_PATH _RPATH "/${IDE_BIN_PATH}" "/${IDE_LIBRARY_PATH}")
|
|
|
|
|
|
|
|
add_executable(${name} ${_arg_SOURCES})
|
|
|
|
|
|
|
|
add_qtc_depends(${name}
|
2019-09-23 17:58:34 +02:00
|
|
|
PRIVATE ${_arg_DEPENDS} ${IMPLICIT_DEPENDS}
|
2019-06-26 17:51:06 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(${name} PRIVATE "${CMAKE_BINARY_DIR}/src" ${_arg_INCLUDES})
|
|
|
|
target_compile_definitions(${name} PRIVATE ${_arg_DEFINES} ${TEST_DEFINES} ${DEFAULT_DEFINES})
|
|
|
|
|
|
|
|
set_target_properties(${name} PROPERTIES
|
|
|
|
BUILD_RPATH "${_RPATH_BASE}/${_RPATH}"
|
|
|
|
INSTALL_RPATH "${_RPATH_BASE}/${_RPATH}"
|
|
|
|
)
|
2019-07-13 11:57:35 +02:00
|
|
|
enable_pch(${name})
|
2019-06-26 17:51:06 +02:00
|
|
|
|
|
|
|
if (NOT _arg_GTEST)
|
|
|
|
add_test(NAME ${name} COMMAND ${name})
|
2019-09-18 14:10:52 +02:00
|
|
|
finalize_test_setup(${name})
|
2019-06-26 17:51:06 +02:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(finalize_qtc_gtest test_name)
|
2020-01-31 12:45:20 +01:00
|
|
|
if (NOT TARGET ${test_name})
|
2020-01-24 17:09:56 +01:00
|
|
|
return()
|
|
|
|
endif()
|
2019-06-26 17:51:06 +02:00
|
|
|
get_target_property(test_sources ${test_name} SOURCES)
|
|
|
|
include(GoogleTest)
|
|
|
|
gtest_add_tests(TARGET ${test_name} SOURCES ${test_sources} TEST_LIST test_list)
|
|
|
|
|
|
|
|
foreach(test IN LISTS test_list)
|
2019-09-18 14:10:52 +02:00
|
|
|
finalize_test_setup(${test})
|
2019-06-26 17:51:06 +02:00
|
|
|
endforeach()
|
|
|
|
endfunction()
|