MacOS: CMake unable to link C++ library with ObjC++ library

Basically this question here - objective c - MacOS: CMake unable to link C++ library with ObjC++ library - Stack Overflow

I have created a minimalistic C++ library that I want to use in my Xcode project. It has this directory structure -

library/
 
    - CMakeLists.txt
    - build/    // build files will reside here 
    - iOS.cmake // toolchain file
    - core/
        - CMakeLists.txt
        - squareroot.h
        - squareroot.cpp
    - platform/
        - CMakeLists.txt
        - squrerootwrapper.h
        - squarerootwrapper.mm

Project link - GitHub - devojoyti/CMakeLibrary

Inside build/ I am doing -

  • cmake ../ -G Xcode -D CMAKE_TOOLCHAIN_FILE=../iOS.cmake -D IOS_PLATFORM=SIMULATOR
  • xcodebuild -target install -configuration Debug

Basically, what is happening, is that I am building two libraries, one inside core/ which calculates the squareroot of a number, another in platform/ which is a ObjC wrapper on the C++ squareroot computation library. I am linking the core/ library inside platform/ library.

Problem:

Problem is, I am unable to link the library generated inside core/ , with that of generated inside platform/ . The code builds just fine, and the library (and the corresponding .h header file) is generated.
However, if I try to use it in my Xcode, it says this:

Clearly, the core/ library functions are not accessible inside platform/

I have also tried using find_library(CORE NAMES core_lib PATHS ${CMAKE_SOURCE_DIR}/core) but it returns me -
CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: CORE linked by target "pim_ios" in directory /Users/****/Work/library/platform

So it is not able to find the library aswell.

Platform specifications:

  • MacOS Big Sur, 11.6.5, 2.3 Ghz i9
  • CMake - 3.22.2
  • Xcode - 13.2.1