2017-09-22 6 views
0

일반적인 구현으로 사용하여 빌드 할 때 jemalloc 라이브러리를 내 응용 프로그램에 연결하려고합니다. https://github.com/jemalloc/jemalloc/wiki/Getting-Started에 연결 플래그를 따르면 사용은 다음과 같습니다cmake를 사용하여 jemalloc 공유 라이브러리를 링크하는 방법

그래서
-L`jemalloc-config --libdir` -Wl,-rpath,`jemalloc-config --libdir` -ljemalloc `jemalloc-config --libs` 

나는 한 다음 CMakeLists.txt :

: 나는 make을 수행 할 때 나는 오류 다음 얻을

cmake_minimum_required(VERSION 2.8.12.2) 
project(widget) 
include_directories(include) 
file(GLOB SOURCES "src/*.cpp") 
add_executable(widget ${SOURCES}) 
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L`jemalloc-config --libdir` -Wl,-rpath,`jemalloc-config --libdir` -ljemalloc `jemalloc-config --libs`") 

그러나

Linking CXX executable widget 
c++: error: `jemalloc-config: No such file or directory 
c++: error: unrecognized command line option ‘--libdir`’ 
c++: error: unrecognized command line option ‘--libdir`’ 
c++: error: unrecognized command line option ‘--libs`’ 
make[2]: *** [widget] Error 1 
make[1]: *** [CMakeFiles/widget.dir/all] Error 2 

답변

1

execute_process() 명령은 친구입니다. 이것을 사용하여 jemalloc-config 실행 파일을 실행 한 다음 출력을 CMake 변수에 넣습니다.