forked from qt-creator/qt-creator
cmake build: Handle turning on/off libraries the same as plugins
Previously the library targets were added, but with EXCLUDE_FROM_ALL. This had the effect that libraries were not compiled if nothing depends on them, but lead to various issues: It wasn't possible to manually control compilation, and it lead to the library targets still being exported, leading to configuration errors when building external plugins. Implement the same mechanism with BUILD_LIBRARY_* as with plugins, giving complete control. Change-Id: Idea3371d130593c5c2fdceee374021b6923db0c9 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
+26
-21
@@ -67,9 +67,9 @@ function(qtc_output_binary_dir varName)
|
||||
endfunction()
|
||||
|
||||
function(add_qtc_library name)
|
||||
cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION;BUILD_BY_DEFAULT;ALLOW_ASCII_CASTS;UNVERSIONED"
|
||||
"DESTINATION;COMPONENT;SOURCES_PREFIX"
|
||||
"DEPENDS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;EXTRA_TRANSLATIONS;PROPERTIES" ${ARGN}
|
||||
cmake_parse_arguments(_arg "STATIC;OBJECT;SKIP_TRANSLATION;ALLOW_ASCII_CASTS;UNVERSIONED"
|
||||
"DESTINATION;COMPONENT;SOURCES_PREFIX;BUILD_DEFAULT"
|
||||
"CONDITION;DEPENDS;PUBLIC_DEPENDS;DEFINES;PUBLIC_DEFINES;INCLUDES;PUBLIC_INCLUDES;SOURCES;EXPLICIT_MOC;SKIP_AUTOMOC;EXTRA_TRANSLATIONS;PROPERTIES" ${ARGN}
|
||||
)
|
||||
|
||||
set(default_defines_copy ${DEFAULT_DEFINES})
|
||||
@@ -83,18 +83,29 @@ function(add_qtc_library 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 ${BUILD_LIBRARIES_BY_DEFAULT})
|
||||
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 _arg_CONDITION)
|
||||
set(_arg_CONDITION ON)
|
||||
endif()
|
||||
|
||||
if (NOT ${_build_library_var})
|
||||
return()
|
||||
endif()
|
||||
string(TOUPPER "BUILD_LIBRARY_${name}" _build_library_var)
|
||||
if (DEFINED _arg_BUILD_DEFAULT)
|
||||
set(_build_library_default ${_arg_BUILD_DEFAULT})
|
||||
else()
|
||||
set(_build_library_default ${BUILD_LIBRARIES_BY_DEFAULT})
|
||||
endif()
|
||||
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 ((${_arg_CONDITION}) AND ${_build_library_var})
|
||||
set(_library_enabled ON)
|
||||
else()
|
||||
set(_library_enabled OFF)
|
||||
endif()
|
||||
|
||||
if (NOT _library_enabled)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# TODO copied from extend_qtc_target.
|
||||
@@ -121,13 +132,7 @@ function(add_qtc_library name)
|
||||
set(library_type OBJECT)
|
||||
endif()
|
||||
|
||||
set(_exclude_from_all EXCLUDE_FROM_ALL)
|
||||
if (_arg_BUILD_BY_DEFAULT)
|
||||
unset(_exclude_from_all)
|
||||
endif()
|
||||
|
||||
# Do not just build libraries...
|
||||
add_library(${name} ${library_type} ${_exclude_from_all} ${_arg_SOURCES})
|
||||
add_library(${name} ${library_type} ${_arg_SOURCES})
|
||||
add_library(${IDE_CASED_ID}::${name} ALIAS ${name})
|
||||
set_public_headers(${name} "${_arg_SOURCES}")
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ endforeach()
|
||||
|
||||
add_qtc_library(qtcreatorcdbext
|
||||
COMPONENT qtcreatorcdbext
|
||||
BUILD_BY_DEFAULT
|
||||
UNVERSIONED
|
||||
DEPENDS ${DbgEngLib}
|
||||
DESTINATION lib/qtcreatorcdbext${ArchSuffix}/
|
||||
|
||||
Reference in New Issue
Block a user