Add option to disable/enable PIC/PIE

When attempting to import and compile the project from the TF-A
unit testing project, the linker throws some errors requiring the
code to be position-independent:

  /usr/bin/ld: CMakeFiles/CppUTestExtTests.dir/MockSupport_cTestCFile.c.o:
   relocation R_X86_64_32 against `.rodata.str1.1' can not be used
   when making a PIE object; recompile with -fPIC
  /usr/bin/ld: CMakeFiles/CppUTestExtTests.dir/OrderedTestTest_c.c.o:
   relocation R_X86_64_32 against `.rodata.str1.8' can not be used
   when making a PIE object; recompile with -fPIC

This is due to the fact that newer versions of the C++ compiler produce
position independent code by default, while the C compiler does not, and
therefore this leads to code incompatibility when linking.

This patch adds a flag (POSITION_INDEPENDENT_CODE) to allow the user decide
whether they want to use PIE/PIC in their code or not. Depending on the
value of the option, the project will be set up accordingly.

Signed-off-by: Juan Pablo Conde <juanpablo.conde@arm.com>
Change-Id: If88d0678e19a31558cf6834a0ba10fd82ca46fa8
1 file changed