Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: use TARGET_OBJECTS to import object library #1048

Merged
merged 1 commit into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ freebsd_task:

pkginstall_script:
- pkg update -f
- pkg install -y cmake ninja pkgconf perl5 go llvm17-lite git
- pkg install -y cmake ninja pkgconf perl5 go llvm17-lite git ca_root_nss
submodules_script:
# unshallow must come first otherwise submodule may be get unshallowed
- git fetch --tags --unshallow
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/releases-android-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,9 @@ jobs:
- name: Run tests (non x86, under qemu emulation)
if: ${{ matrix.arch != 'x86' && matrix.arch != 'x64' }}
run: |
# required by leveldb unittests
mkdir -p $SYSROOT/data/local/tmp
# TMPDIR is required by leveldb unittests
qemu-${{ matrix.qemu_suffix }}-static -L $SYSROOT \
-E TMPDIR=$SYSROOT/data/local/tmp \
-E TMPDIR=$PWD/build-android${{ matrix.apilevel }}-${{ matrix.arch }} \
$PWD/build-android${{ matrix.apilevel }}-${{ matrix.arch }}/yass_test
- name: Upload dist tarball (including debuginfo)
if: ${{ github.event_name == 'release' }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/releases-linux-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,23 @@ jobs:
- name: Run tests (i386 and amd64)
if: ${{ matrix.arch == 'i386' || matrix.arch == 'amd64' }}
run: |
mkdir -p $SDK_ROOT/etc $SDK_ROOT/dev $SDK_ROOT/proc $SDK_ROOT/tmp
rm -rf $SDK_ROOT/tmp
mkdir -p $SDK_ROOT/etc/ssl/certs $SDK_ROOT/dev $SDK_ROOT/proc $SDK_ROOT/tmp $SDK_ROOT/build
touch $SDK_ROOT/etc/resolv.conf
bwrap --die-with-parent --bind $SDK_ROOT / \
--ro-bind /sys /sys \
--ro-bind /etc/resolv.conf /etc/resolv.conf \
--ro-bind /etc/ssl/certs /etc/ssl/certs \
--proc /proc --dev /dev \
--unshare-all --share-net \
--bind $PWD/build-linux-${{ matrix.arch }} /tmp \
/tmp/yass_test
- name: Run tests (non x86, under qemu emulation)
if: ${{ matrix.arch != 'i386' && matrix.arch != 'amd64' }}
run: |
# TMPDIR is required by leveldb unittests
qemu-${{ matrix.qemu_suffix }}-static -L $SDK_ROOT \
-E TMPDIR=$PWD/build-linux-${{ matrix.arch }} \
$PWD/build-linux-${{ matrix.arch }}/yass_test \
--no_exec_proc_tests
- name: Upload dist tarball (including debuginfo)
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/releases-openwrt-binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,10 @@ jobs:
- name: Run tests (x86 and x86_64)
if: ${{ matrix.arch_name == 'x86' || matrix.arch_name == 'x86_64' }}
run: |
mkdir -p ${{ env.SDK_ROOT }}/etc/ssl/certs ${{ env.SDK_ROOT }}/dev ${{ env.SDK_ROOT }}/proc ${{ env.SDK_ROOT }}/tmp
touch ${{ env.SDK_ROOT }}/etc/resolv.conf
bwrap --die-with-parent --ro-bind ${{ env.SDK_ROOT }} / \
rm -rf $SDK_ROOT/tmp
mkdir -p $SDK_ROOT/etc/ssl/certs $SDK_ROOT/dev $SDK_ROOT/proc $SDK_ROOT/tmp
touch $SDK_ROOT/etc/resolv.conf
bwrap --die-with-parent --ro-bind $SDK_ROOT / \
--ro-bind /etc/resolv.conf /etc/resolv.conf \
--ro-bind /etc/ssl/certs /etc/ssl/certs \
--proc /proc --dev /dev \
Expand All @@ -200,7 +201,9 @@ jobs:
- name: Run tests (non x86, under qemu emulation)
if: ${{ matrix.arch_name != 'x86' && matrix.arch_name != 'x86_64' }}
run: |
# TMPDIR is required by leveldb unittests
qemu-${{ matrix.qemu_suffix }}-static -L $SDK_ROOT \
-E TMPDIR=$PWD/build-linux-openwrt-${{ matrix.arch }} \
$PWD/build-linux-openwrt-${{ matrix.arch }}/yass_test \
--no_exec_proc_tests
- name: Upload dist tarball (including debuginfo)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/releases-rpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ jobs:
./tools/build --variant gui --arch ${{ matrix.arch }} --system linux --subsystem musl --sysroot "${{ env.SDK_ROOT }}" -build-test --cmake-build-type MinSizeRel -nc
- name: Run tests
run: |
bwrap --die-with-parent --bind "${{ env.SDK_ROOT }}" / \
bwrap --die-with-parent --bind "$SDK_ROOT" / \
--ro-bind /sys /sys \
--ro-bind /etc/resolv.conf /etc/resolv.conf \
--proc /proc --dev /dev \
Expand Down
29 changes: 14 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3079,11 +3079,12 @@ if (USE_BUILTIN_CA_BUNDLE_CRT)
endif()

add_library(asio_ca_bundle_crt OBJECT ${ASIO_CA_BUNDLE_CRT_SRC})
target_compile_definitions(asio_ca_bundle_crt PUBLIC HAVE_BUILTIN_CA_BUNDLE_CRT=1)
target_include_directories(asio_ca_bundle_crt PRIVATE third_party/ca-certificates)

list(APPEND YASS_APP_FEATURES "ca-certificates 20240203.3.98")
target_link_libraries(asio PUBLIC asio_ca_bundle_crt)
# macro used in yass_test
target_compile_definitions(asio PUBLIC HAVE_BUILTIN_CA_BUNDLE_CRT=1)
target_sources(asio PRIVATE $<TARGET_OBJECTS:asio_ca_bundle_crt>)
endif()

#
Expand Down Expand Up @@ -3127,7 +3128,7 @@ endif()
add_library(asio_supplementary_ca_bundle_crt OBJECT ${ASIO_SUPPLEMENARY_CA_BUNDLE_CRT_SRC})
target_include_directories(asio_supplementary_ca_bundle_crt PRIVATE third_party/ca-certificates)

target_link_libraries(asio PRIVATE asio_supplementary_ca_bundle_crt)
target_sources(asio PRIVATE $<TARGET_OBJECTS:asio_supplementary_ca_bundle_crt>)

set(SUPPORT_LIBS asio ${SUPPORT_LIBS})

Expand Down Expand Up @@ -4226,6 +4227,7 @@ target_link_libraries(yass_cli_lib PUBLIC yass_net)
if (CLI)
add_executable(yass_cli
src/cli/cli.cpp
$<TARGET_OBJECTS:yass_cli_nogui_lib>
)
minject_patch_exetuable(yass_cli)
if (USE_LTO_CMAKE)
Expand All @@ -4251,10 +4253,7 @@ if (CLI)
target_include_directories(yass_cli PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src)

target_link_libraries(yass_cli PUBLIC
yass_cli_nogui_lib
yass_net
)
target_link_libraries(yass_cli PUBLIC yass_net)

if (NOT CMAKE_SKIP_INSTALL_RULES AND NOT WIN32 AND NOT IOS)
install(TARGETS yass_cli RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down Expand Up @@ -4286,6 +4285,7 @@ target_link_libraries(yass_server_lib PUBLIC yass_net)
if (SERVER)
add_executable(yass_server
src/server/server.cpp
$<TARGET_OBJECTS:yass_server_lib>
)
minject_patch_exetuable(yass_server)
if (USE_LTO_CMAKE)
Expand All @@ -4311,10 +4311,7 @@ if (SERVER)
target_include_directories(yass_server PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src)

target_link_libraries(yass_server PUBLIC
yass_server_lib
yass_net
)
target_link_libraries(yass_server PUBLIC yass_net)

if (NOT CMAKE_SKIP_INSTALL_RULES AND NOT WIN32 AND NOT IOS)
install(TARGETS yass_server RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
Expand Down Expand Up @@ -4988,6 +4985,8 @@ if (BUILD_TESTS)
src/net/dns_message_test.cpp
src/net/doh_resolver_test.cpp
src/net/dot_resolver_test.cpp
$<TARGET_OBJECTS:yass_cli_nogui_lib>
$<TARGET_OBJECTS:yass_server_lib>
)

if (IOS)
Expand Down Expand Up @@ -5022,8 +5021,7 @@ if (BUILD_TESTS)
${CMAKE_CURRENT_SOURCE_DIR}/src/server
)
target_link_libraries(yass_test PUBLIC
yass_cli_nogui_lib
yass_server_lib
yass_net
yass_gtest
)
if (WIN32)
Expand Down Expand Up @@ -5132,6 +5130,8 @@ endif()
if (BUILD_BENCHMARKS)
set(yass_benchmark_SOURCE
src/ss_benchmark.cpp
$<TARGET_OBJECTS:yass_cli_nogui_lib>
$<TARGET_OBJECTS:yass_server_lib>
)
if (IOS)
enable_testing()
Expand Down Expand Up @@ -5166,8 +5166,7 @@ if (BUILD_BENCHMARKS)
${CMAKE_CURRENT_SOURCE_DIR}/src/server
)
target_link_libraries(yass_benchmark PUBLIC
yass_cli_nogui_lib
yass_server_lib
yass_net
benchmark::benchmark
)
if (WIN32)
Expand Down
5 changes: 3 additions & 2 deletions src/net/asio_ssl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ TEST(SSL_TEST, LoadSystemCa) {
} else {
GTEST_SKIP() << "skipped as system version is too low";
}
#elif BUILDFLAG(IS_MAC) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) || !defined(HAVE_BUILTIN_CA_BUNDLE_CRT)
#elif BUILDFLAG(IS_MAC) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) || BUILDFLAG(IS_FREEBSD) || \
BUILDFLAG(IS_LINUX) || !defined(HAVE_BUILTIN_CA_BUNDLE_CRT)
ASSERT_NE(result, 0);
#else
// we don't test on openwrt
// we don't test on iOS
GTEST_SKIP() << "skipped as system is not supported";
#endif
}
Loading