Using CMake to build the IMGUI Demo program

CMake newbie here. Learning how to use CMake to compile the Dear Imgui demo program. The Library libimgui.a seems to compile correctly without errors by running make in its own directory. But the imgui_demo program does not compile correctly because the libimgui.a is not being seen.

Any pointers are appreciated.

This is the CMakeLists.txt in the project directory (imgui-demo):

# 
#  CMakeLists for building imgui_demo
# 

# Required Statement -- Always the first statement
cmake_minimum_required(VERSION 3.22.1)

# Set the Name of the name of the Project, becomes the value of PROJECT_NAME variable
project(imgui_demo)

# list of Source files that will be compiled into Object files
# The locations of these files are specified with the -S and -B options
#    in the command line:
#    cmake -S (where the sources are) -B (where the object files will be placed)
#    cmake -S . -B ./build/       (example)
add_executable(${PROJECT_NAME}.out imgui_demo.cpp)

# Add path to subdirectory where CMakeLists.txt resides for IMGUI
add_subdirectory(/home/jorge/code-new/imgui-demo/external/imgui/)

target_include_directories(${PROJECT_NAME}.out
    PRIVATE /home/jorge/code-new/include/imgui
    )

# Add the subdirectory path in which a Library is located
#   path can be relative or absolute
target_link_directories(${PROJECT_NAME}.out BEFORE
    PUBLIC /home/jorge/code-new/imgui-demo/external/imgui/
    )

# find_library(name CreateNewWindow path /home/jorge/code-new/include/imgui REQUIRED)

# Specify the Libraries to be linked with the Project (these are Library file names)
target_link_libraries(${PROJECT_NAME}.out imgui)

This is the CMakeLists.txt file for build the library in a subdirectory (external/imgui).

cmake_minimum_required(VERSION 3.22.1)

# CMake file for compiling the imgui library
project(imgui)

# Add THIS Directory in the top level CMakeLists.txt file using
#    add_subdirectory(/home/jorge/code-new/imgui-demo/external/imgui/)

# Add the library that is built on this subdirectory.
add_library(imgui SHARED imgui.cpp imgui.h imgui_internal.h)

# target_include_directories(${PROJECT_NAME}.out PRIVATE Adder)
target_include_directories(imgui PRIVATE /home/jorge/code-new/include/imgui)

your imgui library is declared as SHARED (ie, imgui.so) but you say your actual libimgui file is .a. So if you change it to a STATIC library, does that fix it?