-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake,make-dist: build gperftools if WITH_STATIC_LIBSTDCXX
we could create a mini project to build a shared library, and use try_compile() to test if the found gperftools is compiled with -fPIC. but as we are targeting mostly xenial when enabling WITH_STATIC_LIBSTDCXX, and google-perftools on xenial by default is built without -fPIC. so let's keep it simple. Signed-off-by: Kefu Chai <[email protected]>
- Loading branch information
Showing
4 changed files
with
82 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
if(EXISTS ${CMAKE_SOURCE_DIR}/src/gperftools/configure) | ||
set(gperftools_SOURCE_DIR | ||
SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/gperftools) | ||
else() | ||
set(gperftools_SOURCE_DIR | ||
URL https://github.com/gperftools/gperftools/releases/download/gperftools-2.7/gperftools-2.7.tar.gz | ||
URL_HASH SHA256=1ee8c8699a0eff6b6a203e59b43330536b22bbcbe6448f54c7091e5efb0763c9) | ||
endif() | ||
|
||
set(gperftools_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/gperftools) | ||
include(ExternalProject) | ||
# override the $DESTDIR specified by debian's dh-make, as it sets $DESTDIR | ||
# environment variable globally, which instructs GNU automake to install the | ||
# artifacts to the specified $DESTDIR instead of <INSTALL_DIR>, where the | ||
# headers and libraries are expected. if $DESTDIR is specified, the artifacts | ||
# will be installed into ${DESTDIR}/${prefix}. and the default ${prefix} is | ||
# /user/local, so pass an empty string to "configure" | ||
ExternalProject_Add(gperftools_ext | ||
${gperftools_SOURCE_DIR} | ||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --disable-libunwind --disable-stacktrace-via-backtrace --enable-frame-pointers --prefix= CXXFLAGS=-fPIC | ||
BUILD_COMMAND $(MAKE) | ||
INSTALL_DIR ${gperftools_ROOT_DIR} | ||
INSTALL_COMMAND $(MAKE) install DESTDIR=<INSTALL_DIR>) | ||
|
||
# create the directory so cmake won't complain when looking at the imported | ||
# target | ||
file(MAKE_DIRECTORY ${gperftools_ROOT_DIR}/include) | ||
|
||
foreach(component tcmalloc tcmalloc_minimal profiler) | ||
add_library(gperftools::${component} STATIC IMPORTED) | ||
set_target_properties(gperftools::${component} PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${gperftools_ROOT_DIR}/include | ||
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" | ||
IMPORTED_LOCATION ${gperftools_ROOT_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${component}${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
add_dependencies(gperftools::${component} gperftools_ext) | ||
endforeach() | ||
|
||
find_package(Threads) | ||
foreach(component tcmalloc profiler) | ||
set_target_properties(gperftools::${component} PROPERTIES | ||
INTERFACE_LINK_LIBRARIES "Threads::Threads") | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters