From e2a0a4f0ba76d53c63e4c701e08aab938f49dbed Mon Sep 17 00:00:00 2001 From: Libin Lu Date: Thu, 5 Sep 2024 11:59:42 -0400 Subject: [PATCH] add fpic option for static lib --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index afd3be3f4..8fb36ac53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,7 @@ option(FINUFFT_USE_OPENMP "Whether to use OpenMP for parallelization. If disable option(FINUFFT_USE_CPU "Whether to build the ordinary FINUFFT library (libfinufft)." ON) option(FINUFFT_USE_CUDA "Whether to build CUDA accelerated FINUFFT library (libcufinufft). This is completely independent of the main FINUFFT library" OFF) option(FINUFFT_STATIC_LINKING "If ON builds the static finufft library, if OFF build a shared finufft library." ON) +option(FINUFFT_STATIC_LINKING_PIC "Whether to build the FINUFFT static lib with -fPIC flag" OFF) option(FINUFFT_BUILD_DEVEL "Whether to build development executables" OFF) option(FINUFFT_BUILD_EXAMPLES "Whether to build the FINUFFT examples" OFF) option(FINUFFT_BUILD_TESTS "Whether to build the FINUFFT tests" OFF) @@ -242,6 +243,9 @@ function(set_finufft_options target) endif() target_link_libraries(${target} PRIVATE xsimd) target_link_libraries(${target} PRIVATE ${FINUFFT_FFTLIBS}) + if(FINUFFT_STATIC_LINKING AND FINUFFT_STATIC_LINKING_PIC) + set_property(TARGET ${target} PROPERTY POSITION_INDEPENDENT_CODE ON) + endif() endfunction() if(FINUFFT_USE_CPU)