Compiling a project with ROOT as a dependency adds -fPIC to CMAKE_CXX_FLAGS

Hi,
adding ROOT as a dependency using the following lines:
list(APPEND CMAKE_PREFIX_PATH $ENV{ROOTSYS})
find_package(ROOT REQUIRED COMPONENTS RIO Net TMVA)
include(${ROOT_USE_FILE})

Adds -fPIC to all compilation targets

it comes from this line:
set(ROOT_CXX_FLAGS " -pipe -m64 -fsigned-char -fPIC -pthread -std=c++11")

in ROOTConfig.cmake

That means that targets that doesn’t require -fPIC are compiled with it

I agree. I will create an issue for that. The option -fPIC should not be in the default compilation flags inherited by dependent projects.

Done: ROOT-9212.

1 Like