Compilation Error during Linkage with CMake

I tried to incorporate pytorch C++ extension to my existing project, but I encountered a linkage error. I have been able to replicated it using a small example
utils.hpp

#pragma once

#include <string>

namespace example {
enum EnumExample : uint8_t { TEST1, TEST2 };

class Utils {
public:
  static std::string getString(EnumExample);
};
} // namespace example

utils.cpp

#include "utils.hpp"

namespace example {
std::string Utils::getString(EnumExample example) {
  if (example == TEST1)
    return "TEST1";
  else if (example == TEST2)
    return "TEST2";
}
} // namespace example                                                                                                             

main.cpp

#include <iostream>
#include <memory>
#include <torch/script.h>

#include "utils.hpp"

int main(int argc, const char *argv[]) {
  if (argc != 2) {
    std::cerr << "usage: example-app <path-to-exported-script-module>\n";
    return -1;
  }

  torch::jit::script::Module module;
  try {
    // Deserialize the ScriptModule from a file using torch::jit::load().                                                          
    module = torch::jit::load(argv[1]);
  } catch (const c10::Error &e) {
    std::cerr << "error loading the model\n";
    return -1;
  }
  std::cout << "Model " << argv[1] << " loaded fine\n";

  // Create a vector of inputs.                                                                                                    
  std::vector<torch::jit::IValue> inputs;
  inputs.push_back(torch::randn({1, 1, 64, 101}));

  // Execute the model and turn its output into a tensor.                                                                          
  at::Tensor output = module.forward(inputs).toTensor();
  std::cout << output << "\n";
  int y_hat = output.argmax(1).item().toInt();
  std::cout << "Predicted class: " << y_hat << "\n";

  std::cout << example::Utils::getString(example::TEST1);
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(example-app)

find_package(Torch REQUIRED)

add_library(example_lib
  utils.cpp)

add_executable(example-app main.cpp)
target_link_libraries(example-app
  PRIVATE ${TORCH_LIBRARIES})

The compilation error is as follows:

CMakeFiles/example-app.dir/main.cpp.o: In function `main':
main.cpp:(.text+0x549): undefined reference to `example::Utils::getString[abi:cxx11](example::EnumExample)'
collect2: error: ld returned 1 exit status
CMakeFiles/example-app.dir/build.make:87: recipe for target 'example-app' failed
make[2]: *** [example-app] Error 1
CMakeFiles/Makefile2:77: recipe for target 'CMakeFiles/example-app.dir/all' failed
make[1]: *** [CMakeFiles/example-app.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

If I removed the last cout line from main.cpp, the compilation would work