diff --git a/CMakeLists.txt b/CMakeLists.txt index a85e97a44..c7fbfcfc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -305,7 +305,7 @@ add_library (mongocrypt_static STATIC ${MONGOCRYPT_SOURCES}) # the common case that users are setting -DCMAKE_C_FLAGS='-fPIC' string (FIND "${CMAKE_C_FLAGS}" "-fPIC" FPIC_LOCATION) if (NOT WIN32 AND ENABLE_PIC AND "${FPIC_LOCATION}" EQUAL "-1") - target_compile_options (mongocrypt_static PUBLIC -fPIC) + set_property (TARGET mongocrypt_static PROPERTY POSITION_INDEPENDENT_CODE TRUE) message ("Adding -fPIC to compilation of mongocrypt_static components") endif () target_include_directories ( diff --git a/kms-message/CMakeLists.txt b/kms-message/CMakeLists.txt index ff210d4fc..7313cb107 100644 --- a/kms-message/CMakeLists.txt +++ b/kms-message/CMakeLists.txt @@ -100,7 +100,7 @@ add_library ( string(FIND "${CMAKE_C_FLAGS}" "-fPIC" FPIC_LOCATION) if (NOT WIN32 AND ENABLE_PIC AND "${FPIC_LOCATION}" EQUAL "-1") - target_compile_options (kms_message_static PUBLIC -fPIC) + set_property (TARGET kms_message_static PROPERTY POSITION_INDEPENDENT_CODE TRUE) message ("Adding -fPIC to compilation of kms_message_static components") endif ()