Can't link pytorch library to existing codebase

I’m attempting to link PyTorch to an existing fairly sophisticated tool’s code base. I need to be able to call the model based on some data that the tool generate. I’m doing this inside of the code and not externally calling a python script in an attempt to be more efficiency since I don’t want to have to incur the costs of loading the model every time I want to call it. I also need to do this with a static PyTorch library. When I attempt to build, the build makes it until the final linking phase, and it give me the following error:

/usr/bin/ld: -f may not be used without -shared

The only flag I can see with -f is -fPIC. Without adding torch’s libraries and include directories, it build’s fine and this flag still occurs. This leads me to believe there is something going wrong with PyTorch. Here is the CMakeLists.txt File I’m using to build the library which includes pytorch. I link against this library.

add_library(prediction gat.cpp)

target_include_directories(prediction 
    PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
    PRIVATE ${TORCH_INCLUDE_DIRS}
)

target_link_libraries(prediction "${TORCH_LIBRARIES}")

set_property(TARGET prediction PROPERTY CXX_STANDARD 14)

I unfortunately could not get this working with static libraries, but dynamic libraries loaded fine. I set the CMake option of shared to true.