Replace -fPIC with -fpic
<p>When using Qt CMake automatically adds the <code>-fPIC</code> flag to compile options. I want to use <code>-fpic</code>, so I went through all Cmake variables and replaced <code>-fPIC</code> with <code>-fpic</code>.</p>

<pre><code>cmake_minimum_required(VERSION 3.5)
project(sss)

find_package(Qt5 REQUIRED COMPONENTS Core Sql)

get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
        if (NOT "${${_variableName}}" STREQUAL "")
                string(REPLACE "-fPIC" "-fpic" ${_variableName} ${${_variableName}})
                string(REPLACE "-fPIE" "-fpie" ${_variableName} ${${_variableName}})
        endif()
        #message(STATUS "${_variableName}=${${_variableName}}")
endforeach()

set(CMAKE_CXX_FLAGS "-fpie")
set(CMAKE_EXE_LINKER_FLAGS "-fpie -pie")

add_executable(sss main.cpp)

target_link_libraries(sss Qt5::Core Qt5::Sql)
</code></pre>

<p><code>main.cpp</code> contains</p>

<pre><code>#include &lt;QSqlDatabase&gt;

int main(){
        QSqlDatabase::addDatabase("QPSQL");
}
</code></pre>

<p>Unfortunately CMake still adds the <code>-fPIC</code> flag, althoguh the listed variables does not contain it:</p>

<pre><code>Building CXX object CMakeFiles/sss.dir/main.cpp.o
/usr/bin/c++   -DQT_CORE_LIB -DQT_NO_DEBUG -DQT_SQL_LIB -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -isystem /usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -isystem /usr/include/x86_64-linux-gnu/qt5/QtSql  -fPIC -o CMakeFiles/sss.dir/main.cpp.o -c src/main.cpp
</code></pre>

<p>How can I replace <code>-fPIC</code> with <code>-fpic</code>?</p>