CMake build: Put wininterrupt and cdbextension into separate components

And make it possible to turn off building the cdbextension library.
So they can be installed and packaged separately

Change-Id: Ic7da1411aa3973604b897e1cbf57ad9c5b0fe460
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2020-02-05 15:55:21 +01:00
parent 2555f4b8dd
commit 0e0c0185d2
3 changed files with 103 additions and 44 deletions

View File

@@ -322,6 +322,17 @@ function(qtc_plugin_enabled varName name)
endif() endif()
endfunction() endfunction()
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()
function(enable_pch target) function(enable_pch target)
if (BUILD_WITH_PCH) if (BUILD_WITH_PCH)
# Skip PCH for targets that do not use the expected visibility settings: # Skip PCH for targets that do not use the expected visibility settings:
@@ -417,7 +428,7 @@ endfunction()
function(add_qtc_library name) function(add_qtc_library name)
cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION;BUILD_BY_DEFAULT;ALLOW_ASCII_CASTS" cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION;BUILD_BY_DEFAULT;ALLOW_ASCII_CASTS"
"DESTINATION" "DESTINATION;COMPONENT"
"DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;PUBLIC_DEFINES;PUBLIC_DEPENDS;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;PROPERTIES" ${ARGN} "DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;PUBLIC_DEFINES;PUBLIC_DEPENDS;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;PROPERTIES" ${ARGN}
) )
@@ -432,6 +443,20 @@ function(add_qtc_library name)
update_cached_list(__QTC_LIBRARIES "${name}") update_cached_list(__QTC_LIBRARIES "${name}")
# 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()
compare_sources_with_existing_disk_files(${name} "${_arg_SOURCES}") compare_sources_with_existing_disk_files(${name} "${_arg_SOURCES}")
set(library_type SHARED) set(library_type SHARED)
@@ -529,12 +554,21 @@ function(add_qtc_library name)
set(NAMELINK_OPTION NAMELINK_SKIP) set(NAMELINK_OPTION NAMELINK_SKIP)
endif() endif()
unset(COMPONENT_OPTION)
if (_arg_COMPONENT)
set(COMPONENT_OPTION "COMPONENT" "${_arg_COMPONENT}")
endif()
install(TARGETS ${name} install(TARGETS ${name}
EXPORT ${IDE_CASED_ID} EXPORT ${IDE_CASED_ID}
RUNTIME DESTINATION "${_DESTINATION}" OPTIONAL RUNTIME
DESTINATION "${_DESTINATION}"
${COMPONENT_OPTION}
OPTIONAL
LIBRARY LIBRARY
DESTINATION "${IDE_LIBRARY_PATH}" DESTINATION "${IDE_LIBRARY_PATH}"
${NAMELINK_OPTION} ${NAMELINK_OPTION}
${COMPONENT_OPTION}
OPTIONAL OPTIONAL
OBJECTS OBJECTS
DESTINATION "${IDE_LIBRARY_PATH}" DESTINATION "${IDE_LIBRARY_PATH}"
@@ -871,9 +905,18 @@ function(extend_qtc_plugin target_name)
extend_qtc_target(${target_name} ${ARGN}) extend_qtc_target(${target_name} ${ARGN})
endfunction() endfunction()
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()
function(add_qtc_executable name) function(add_qtc_executable name)
cmake_parse_arguments(_arg "SKIP_INSTALL;SKIP_TRANSLATION;ALLOW_ASCII_CASTS" cmake_parse_arguments(_arg "SKIP_INSTALL;SKIP_TRANSLATION;ALLOW_ASCII_CASTS"
"DESTINATION" "DESTINATION;COMPONENT"
"DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;SOURCES;PROPERTIES" ${ARGN}) "DEFINES;DEPENDS;EXTRA_TRANSLATIONS;INCLUDES;SOURCES;PROPERTIES" ${ARGN})
if ($_arg_UNPARSED_ARGUMENTS) if ($_arg_UNPARSED_ARGUMENTS)
@@ -950,7 +993,16 @@ function(add_qtc_executable name)
enable_pch(${name}) enable_pch(${name})
if (NOT _arg_SKIP_INSTALL) if (NOT _arg_SKIP_INSTALL)
install(TARGETS ${name} DESTINATION "${_DESTINATION}" OPTIONAL) unset(COMPONENT_OPTION)
if (_arg_COMPONENT)
set(COMPONENT_OPTION "COMPONENT" "${_arg_COMPONENT}")
endif()
install(TARGETS ${name}
DESTINATION "${_DESTINATION}"
${COMPONENT_OPTION}
OPTIONAL
)
update_cached_list(__QTC_INSTALLED_EXECUTABLES update_cached_list(__QTC_INSTALLED_EXECUTABLES
"${_DESTINATION}/${name}${CMAKE_EXECUTABLE_SUFFIX}") "${_DESTINATION}/${name}${CMAKE_EXECUTABLE_SUFFIX}")

View File

@@ -33,6 +33,7 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
endif() endif()
add_qtc_library(qtcreatorcdbext add_qtc_library(qtcreatorcdbext
COMPONENT qtcreatorcdbext
BUILD_BY_DEFAULT BUILD_BY_DEFAULT
DEPENDS ${DbgEngLib} DEPENDS ${DbgEngLib}
DESTINATION lib/qtcreatorcdbext${ArchSuffix}/ DESTINATION lib/qtcreatorcdbext${ArchSuffix}/
@@ -53,33 +54,35 @@ add_qtc_library(qtcreatorcdbext
symbolgroupvalue.cpp symbolgroupvalue.h symbolgroupvalue.cpp symbolgroupvalue.h
) )
find_package(PythonLibs 3.5) qtc_library_enabled(_library_enabled qtcreatorcdbext)
if (NOT ${PYTHONLIBS_FOUND}) if (_library_enabled)
find_package(PythonLibs 3.5)
if (NOT ${PYTHONLIBS_FOUND})
message(WARNING "PythonLibs (at least version 3.5) not found. qtcreatorcdbext will be built without Python support.") message(WARNING "PythonLibs (at least version 3.5) not found. qtcreatorcdbext will be built without Python support.")
return() return()
endif() endif()
set(PythonRegex "^(.*)/(.*)/(python[0-9]+)${CMAKE_IMPORT_LIBRARY_SUFFIX}$") set(PythonRegex "^(.*)/(.*)/(python[0-9]+)${CMAKE_IMPORT_LIBRARY_SUFFIX}$")
if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
set(PythonRegex "^(.*)/(.*)/(python[0-9]+_d)${CMAKE_IMPORT_LIBRARY_SUFFIX}$") set(PythonRegex "^(.*)/(.*)/(python[0-9]+_d)${CMAKE_IMPORT_LIBRARY_SUFFIX}$")
endif() endif()
foreach(lib IN LISTS PYTHON_LIBRARIES) foreach(lib IN LISTS PYTHON_LIBRARIES)
if (lib MATCHES ${PythonRegex}) if (lib MATCHES ${PythonRegex})
set(PythonDll "${CMAKE_MATCH_1}/${CMAKE_MATCH_3}${CMAKE_SHARED_LIBRARY_SUFFIX}") set(PythonDll "${CMAKE_MATCH_1}/${CMAKE_MATCH_3}${CMAKE_SHARED_LIBRARY_SUFFIX}")
break() break()
endif() endif()
endforeach() endforeach()
if (NOT PythonDll) if (NOT PythonDll)
if (CMAKE_BUILD_TYPE STREQUAL "Debug") if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message(WARNING "The Debug build of Qt Creator requires Debug Python libraries. Please check your Python installation") message(WARNING "The Debug build of Qt Creator requires Debug Python libraries. Please check your Python installation")
endif() endif()
message(WARNING "PythonDll not found. qtcreatorcdbext will be built without Python support.") message(WARNING "PythonDll not found. qtcreatorcdbext will be built without Python support.")
return() return()
endif() endif()
extend_qtc_target(qtcreatorcdbext extend_qtc_target(qtcreatorcdbext
DEPENDS "${PYTHON_LIBRARIES}" DEPENDS "${PYTHON_LIBRARIES}"
INCLUDES "${PYTHON_INCLUDE_DIR}" INCLUDES "${PYTHON_INCLUDE_DIR}"
DEFINES WITH_PYTHON=1 DEFINES WITH_PYTHON=1
@@ -89,12 +92,15 @@ extend_qtc_target(qtcreatorcdbext
pystdoutredirect.cpp pystdoutredirect.h pystdoutredirect.cpp pystdoutredirect.h
pytype.cpp pytype.h pytype.cpp pytype.h
pyvalue.cpp pyvalue.h pyvalue.cpp pyvalue.h
) )
install(FILES "${PythonDll}" DESTINATION lib/qtcreatorcdbext${ArchSuffix}/) install(FILES "${PythonDll}"
DESTINATION lib/qtcreatorcdbext${ArchSuffix}/
COMPONENT qtcreatorcdbext)
add_custom_target(copy_python_dll ALL VERBATIM) add_custom_target(copy_python_dll ALL VERBATIM)
add_custom_command(TARGET copy_python_dll POST_BUILD add_custom_command(TARGET copy_python_dll POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy "${PythonDll}" "${PROJECT_BINARY_DIR}/lib/qtcreatorcdbext${ArchSuffix}/" COMMAND "${CMAKE_COMMAND}" -E copy "${PythonDll}" "${PROJECT_BINARY_DIR}/lib/qtcreatorcdbext${ArchSuffix}/"
VERBATIM VERBATIM
) )
endif()

View File

@@ -8,5 +8,6 @@ if (CMAKE_SIZEOF_VOID_P EQUAL 8)
endif() endif()
add_qtc_executable(win${Arch}interrupt add_qtc_executable(win${Arch}interrupt
COMPONENT wininterrupt
SOURCES wininterrupt.c SOURCES wininterrupt.c
) )