Change-Id: Id7de9f400eed1d638b8bef7b883fcc8a70fad0aa
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fpie -Wall")
-SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -g")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -fpie -fPIE -Wall")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -fPIE")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -g -fPIE")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})