Skip to content

introduce NO_STATIC_LIBASAN option #780

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

Merged
merged 2 commits into from
Jul 6, 2024
Merged
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
3 changes: 1 addition & 2 deletions pcm.spec
Original file line number Diff line number Diff line change
@@ -19,7 +19,6 @@ BuildRequires: libopenssl-devel
%else
BuildRequires: openssl-devel
BuildRequires: libasan
BuildRequires: libasan-static
%endif


@@ -33,7 +32,7 @@ Intel(r) Performance Counter Monitor (Intel(r) PCM) is an application programmin
%build
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/ -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
cmake -DNO_STATIC_LIBASAN=1 -DCMAKE_INSTALL_PREFIX=/usr/ -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
make -j

%install
15 changes: 13 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -46,12 +46,23 @@ if(UNIX) # LINUX, FREE_BSD, APPLE
$<$<CONFIG:MinSizeRel>:PCM_SILENT>
$<$<CONFIG:RelWithDebInfo>:PCM_SILENT>
)

if(NO_STATIC_LIBASAN)
set(PCM_DYNAMIC_ASAN "asan")
set(PCM_STATIC_ASAN "")
else()
set(PCM_DYNAMIC_ASAN "")
set(PCM_STATIC_ASAN "-static-libasan")
message(STATUS "Using static libasan")
message(STATUS "To use dynamic libasan, use -DNO_STATIC_LIBASAN=1 option")
endif()

if(APPLE)
add_subdirectory(MacMSRDriver)
include_directories("${CMAKE_SOURCE_DIR}/src/MacMSRDriver") # target_include_directories doesn't work
target_link_libraries(PCM_SHARED PRIVATE PCM_STATIC_SILENT PcmMsr Threads::Threads)
else()
target_link_libraries(PCM_SHARED PRIVATE PCM_STATIC_SILENT Threads::Threads)
target_link_libraries(PCM_SHARED PRIVATE PCM_STATIC_SILENT Threads::Threads "${PCM_DYNAMIC_ASAN}")
endif()
set_target_properties(PCM_SHARED PROPERTIES OUTPUT_NAME pcm)
endif()
@@ -148,7 +159,7 @@ foreach(PROJECT_NAME ${PROJECT_NAMES})
endif(MSVC)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static-libasan")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${PCM_STATIC_ASAN}")
endif()

# specific file for pcm-raw project