aboutsummaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2020-11-02 17:20:26 +0100
committerEike Ziller <eike.ziller@qt.io>2020-11-02 19:10:05 +0000
commit495dee98fc1af69bd22ff7f815da85787694d8f4 (patch)
treefb95268ff66bc1d7a6228106f8224a31567696a2 /cmake
parent89644e4a06e11be0becd58d112974af4c6b64a82 (diff)
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>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtCreatorAPI.cmake45
1 files changed, 25 insertions, 20 deletions
diff --git a/cmake/QtCreatorAPI.cmake b/cmake/QtCreatorAPI.cmake
index 79b8494fac..d7a2a1081e 100644
--- a/cmake/QtCreatorAPI.cmake
+++ b/cmake/QtCreatorAPI.cmake
@@ -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)
+ if (NOT _arg_CONDITION)
+ set(_arg_CONDITION ON)
+ 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})
- 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}.")
+ 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 (NOT ${_build_library_var})
- return()
- endif()
+ 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}")