meson: Don't create static library target unless option is enabled
While we don't build these by default, all the source files still get added to the compile_commands.json file by meson, which can confuse tools as they might end up analyzing the source files twice or analyzing the wrong one. To avoid this issue, only define the static library target if the corresponding option is enabled.
This commit is contained in:
+45
-47
@@ -2067,34 +2067,33 @@ libsystemd = shared_library(
|
||||
install_tag: 'libsystemd',
|
||||
install_dir : libdir)
|
||||
|
||||
install_libsystemd_static = static_library(
|
||||
'systemd',
|
||||
libsystemd_sources,
|
||||
basic_sources,
|
||||
fundamental_sources,
|
||||
include_directories : libsystemd_includes,
|
||||
implicit_include_directories : false,
|
||||
build_by_default : static_libsystemd != 'false',
|
||||
install : static_libsystemd != 'false',
|
||||
install_tag: 'libsystemd',
|
||||
install_dir : libdir,
|
||||
pic : static_libsystemd_pic,
|
||||
dependencies : [libblkid,
|
||||
libcap,
|
||||
libdl,
|
||||
libgcrypt_cflags,
|
||||
liblz4_cflags,
|
||||
libm,
|
||||
libmount,
|
||||
libopenssl,
|
||||
librt,
|
||||
libxz_cflags,
|
||||
libzstd_cflags,
|
||||
threads,
|
||||
userspace],
|
||||
c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
|
||||
|
||||
if static_libsystemd != 'false'
|
||||
install_libsystemd_static = static_library(
|
||||
'systemd',
|
||||
libsystemd_sources,
|
||||
basic_sources,
|
||||
fundamental_sources,
|
||||
include_directories : libsystemd_includes,
|
||||
implicit_include_directories : false,
|
||||
install : true,
|
||||
install_tag: 'libsystemd',
|
||||
install_dir : libdir,
|
||||
pic : static_libsystemd_pic,
|
||||
dependencies : [libblkid,
|
||||
libcap,
|
||||
libdl,
|
||||
libgcrypt_cflags,
|
||||
liblz4_cflags,
|
||||
libm,
|
||||
libmount,
|
||||
libopenssl,
|
||||
librt,
|
||||
libxz_cflags,
|
||||
libzstd_cflags,
|
||||
threads,
|
||||
userspace],
|
||||
c_args : libsystemd_c_args + (static_libsystemd_pic ? [] : ['-fno-PIC']))
|
||||
|
||||
alias_target('libsystemd', libsystemd, install_libsystemd_static)
|
||||
else
|
||||
alias_target('libsystemd', libsystemd)
|
||||
@@ -2116,27 +2115,26 @@ libudev = shared_library(
|
||||
install_tag: 'libudev',
|
||||
install_dir : libdir)
|
||||
|
||||
install_libudev_static = static_library(
|
||||
'udev',
|
||||
basic_sources,
|
||||
fundamental_sources,
|
||||
shared_sources,
|
||||
libsystemd_sources,
|
||||
libudev_sources,
|
||||
include_directories : includes,
|
||||
implicit_include_directories : false,
|
||||
build_by_default : static_libudev != 'false',
|
||||
install : static_libudev != 'false',
|
||||
install_tag: 'libudev',
|
||||
install_dir : libdir,
|
||||
link_depends : libudev_sym,
|
||||
dependencies : [libmount,
|
||||
libshared_deps,
|
||||
userspace],
|
||||
c_args : static_libudev_pic ? [] : ['-fno-PIC'],
|
||||
pic : static_libudev_pic)
|
||||
|
||||
if static_libudev != 'false'
|
||||
install_libudev_static = static_library(
|
||||
'udev',
|
||||
basic_sources,
|
||||
fundamental_sources,
|
||||
shared_sources,
|
||||
libsystemd_sources,
|
||||
libudev_sources,
|
||||
include_directories : includes,
|
||||
implicit_include_directories : false,
|
||||
install : true,
|
||||
install_tag: 'libudev',
|
||||
install_dir : libdir,
|
||||
link_depends : libudev_sym,
|
||||
dependencies : [libmount,
|
||||
libshared_deps,
|
||||
userspace],
|
||||
c_args : static_libudev_pic ? [] : ['-fno-PIC'],
|
||||
pic : static_libudev_pic)
|
||||
|
||||
alias_target('libudev', libudev, install_libudev_static)
|
||||
else
|
||||
alias_target('libudev', libudev)
|
||||
|
||||
+28
-18
@@ -461,14 +461,6 @@ executables += [
|
||||
'link_with' : libsystemd,
|
||||
'suite' : 'libsystemd',
|
||||
},
|
||||
test_template + {
|
||||
'name' : 'test-libsystemd-static-sym',
|
||||
'sources' : test_libsystemd_sym_c,
|
||||
'link_with' : install_libsystemd_static,
|
||||
'build_by_default' : want_tests != 'false' and static_libsystemd != 'false',
|
||||
'install' : install_tests and static_libsystemd != 'false',
|
||||
'suite' : 'libsystemd',
|
||||
},
|
||||
test_template + {
|
||||
'name' : 'test-libudev-sym',
|
||||
'sources' : test_libudev_sym_c,
|
||||
@@ -477,16 +469,6 @@ executables += [
|
||||
'link_with' : libudev,
|
||||
'suite' : 'libudev',
|
||||
},
|
||||
test_template + {
|
||||
'name' : 'test-libudev-static-sym',
|
||||
'sources' : test_libudev_sym_c,
|
||||
'include_directories' : libudev_includes,
|
||||
'c_args' : ['-Wno-deprecated-declarations'] + test_cflags,
|
||||
'link_with' : install_libudev_static,
|
||||
'build_by_default' : want_tests != 'false' and static_libudev != 'false',
|
||||
'install' : install_tests and static_libudev != 'false',
|
||||
'suite' : 'libudev',
|
||||
},
|
||||
|
||||
# Tests that link to libcore, i.e. tests for pid1 code.
|
||||
core_test_template + {
|
||||
@@ -627,3 +609,31 @@ executables += [
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
if static_libsystemd != 'false'
|
||||
executables += [
|
||||
test_template + {
|
||||
'name' : 'test-libsystemd-static-sym',
|
||||
'sources' : test_libsystemd_sym_c,
|
||||
'link_with' : install_libsystemd_static,
|
||||
'build_by_default' : want_tests != 'false',
|
||||
'install' : install_tests,
|
||||
'suite' : 'libsystemd',
|
||||
},
|
||||
]
|
||||
endif
|
||||
|
||||
if static_libudev != 'false'
|
||||
executables += [
|
||||
test_template + {
|
||||
'name' : 'test-libudev-static-sym',
|
||||
'sources' : test_libudev_sym_c,
|
||||
'include_directories' : libudev_includes,
|
||||
'c_args' : ['-Wno-deprecated-declarations'] + test_cflags,
|
||||
'link_with' : install_libudev_static,
|
||||
'build_by_default' : want_tests != 'false',
|
||||
'install' : install_tests,
|
||||
'suite' : 'libudev',
|
||||
},
|
||||
]
|
||||
endif
|
||||
|
||||
Reference in New Issue
Block a user