diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt
index e1f9540e9e20c9eabdb98841aafe42caa13d1052..4ae759ad2dfe39bac999f7ec0b37fa055ff57eee 100644
--- a/coreapi/CMakeLists.txt
+++ b/coreapi/CMakeLists.txt
@@ -150,8 +150,8 @@ if(ENABLE_JAVA_WRAPPER)
 endif()
 
 if(BUILD_SHARED_LIBS)
-	target_compile_options(linphone-coreapi PRIVATE "-fPIC")
-endif ()
+	set_target_properties(linphone-coreapi PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
+endif()
 
 
 add_subdirectory(help)