Skip to content

Commit

Permalink
Merge pull request #324 from LLNL/feature/c_lib
Browse files Browse the repository at this point in the history
Remove explicit -fPIC for libmetall_c
  • Loading branch information
KIwabuchi committed Jun 27, 2024
2 parents e748db7 + 4580e12 commit 7e9a3b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ option(JUST_INSTALL_METALL_HEADER "Just install Metall header files (do not buil
option(BUILD_UTILITY "Build utility programs" OFF)
option(BUILD_DOC "Build API documentation" OFF)
option(BUILD_C "Build C examples and libraries" OFF)
option(BUILD_SHARED_LIBS "Generate shared libraries" OFF)
option(BUILD_EXAMPLE "Build the examples" OFF)
option(BUILD_TEST "Build the test" OFF)
option(RUN_LARGE_SCALE_TEST "Run large scale tests" OFF)
Expand Down
16 changes: 14 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@ if (BUILD_C)
return()
endif ()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")

if (BUILD_SHARED_LIBS)
message(STATUS "Building metall_c as a shared library")
else ()
message(STATUS "Building metall_c as a static library")
endif ()
# 'BUILD_SHARED_LIBS' variable is used to determine
# whether to build a shared library or a static library.
add_library(metall_c metall_c.cpp)
get_target_property(PIC_metall_c metall_c POSITION_INDEPENDENT_CODE)
if (PIC_metall_c)
message(STATUS "POSITION_INDEPENDENT_CODE for metall_c : ON")
else ()
message(STATUS "POSITION_INDEPENDENT_CODE for metall_c : OFF")
endif ()

add_library(${PROJECT_NAME}::metall_c ALIAS metall_c)

target_include_directories(metall_c PUBLIC
Expand Down

0 comments on commit 7e9a3b1

Please sign in to comment.