dwarfs/cmake/libdwarfs_tool.cmake
Marcus Holland-Moritz 6b17f3d31f refactor: only link jemalloc against executables, not libraries
Linking `jemalloc` against executables is enough to replace *all* malloc
functionality with `jemalloc`. Linking it against a library will cause
issues for example with Python bindings. The downside is that Python
won't be using `jemalloc` by default, but likely malloc won't be the
bottleneck when using Python.
2025-03-17 09:42:52 +01:00

53 lines
1.5 KiB
CMake

#
# Copyright (c) Marcus Holland-Moritz
#
# This file is part of dwarfs.
#
# dwarfs is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# dwarfs is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# dwarfs. If not, see <https://www.gnu.org/licenses/>.
#
cmake_minimum_required(VERSION 3.28.0)
add_library(
dwarfs_tool OBJECT
tools/src/tool/iolayer.cpp
tools/src/tool/main_adapter.cpp
tools/src/tool/safe_main.cpp
tools/src/tool/sys_char.cpp
tools/src/tool/tool.cpp
)
if(WITH_MAN_OPTION)
target_sources(dwarfs_tool PRIVATE
tools/src/tool/pager.cpp
tools/src/tool/render_manpage.cpp
)
endif()
target_link_libraries(dwarfs_tool PUBLIC dwarfs_common)
target_include_directories(dwarfs_tool PUBLIC tools/include)
if(USE_JEMALLOC AND JEMALLOC_FOUND)
target_link_libraries(dwarfs_tool PRIVATE PkgConfig::JEMALLOC)
target_compile_definitions(dwarfs_tool PRIVATE DWARFS_USE_JEMALLOC)
endif()
target_compile_definitions(
dwarfs_tool PRIVATE DWARFS_BUILD_ID="${CMAKE_SYSTEM_PROCESSOR}, ${CMAKE_SYSTEM}, ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}"
)
list(APPEND LIBDWARFS_OBJECT_TARGETS
dwarfs_tool
)