I have this struct of files:

And i am trying to create executable file, but i have problem in road to this, when i am creating makefile.
I created libsort by cmake like this:
cmake_minimum_required(VERSION 3.22)
project(sort)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/deploy)
set(SOURCE_FILES src/sort.cpp)
set(HEADERS_FILES include/sort.h)
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${HEADERS_FILES})
target_include_directories(${PROJECT_NAME} PUBLIC include)
And by this i created libsort.so in deploy folder.
Now i want to create executable file, so i am trying to run cmake from main folder and i am getting in return:
-- The C compiler identification is GNU 11.3.0
-- The CXX compiler identification is GNU 11.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:5 (find_library):
Could not find LIB_FILE using the following names: sort
CMakeLists in folder app:
cmake_minimum_required(VERSION 3.22)
project(my_app)
find_library(LIB_FILE sort HINTS ${CMAKE_BINARY_DIR}/lib/build/deploy REQUIRED)
add_executable(my_app main.cpp)
target_link_libraries(${PROJECT_NAME} ${LIB_FILE})
I tried with HINTS, without and many possibilities with find_library().
Anyone have idea how to do this properly?
>Solution :
find_library() usage is incorrect here, it is used for looking for libraries, but not for sources. Use add_subdirectory():
cmake_minimum_required(VERSION 3.22)
project(my_app)
add_subdirectory(lib sort)
add_executable(my_app main.cpp)
target_link_libraries(${PROJECT_NAME} sort)