Hello i am trying to build my SFML project using CMake but when i try to use multiple source files, CMake doesn't link the object files
This is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.20)
set(CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
project(PolygonPoints)
find_package(SFML 2.5.1 COMPONENTS graphics window system audio REQUIRED)
file(
    GLOB
    SOURCES
    "src/*.hpp"
    "src/*.cpp"
)
add_executable(PolygonPoints ${SOURCES})
target_link_libraries(PolygonPoints sfml-graphics sfml-window sfml-system sfml-audio)
target_include_directories(PolygonPoints PRIVATE include)
This is my project structure:
PolygonPoints/
    src/
        main.cpp
        point.cpp
    include/
        point.hpp
    build/
        (...)
    CMakeLists.txt
    (...)
This is the error I get:
bayram@milkyway ~/Projects/PolygonPoints/build (main)> cmake .. && make && ./PolygonPoints
-- Found SFML 2.5.1 in /usr/lib64/cmake/SFML
-- Configuring done
-- Generating done
-- Build files have been written to: /home/bayram/Projects/PolygonPoints/build
Consolidate compiler generated dependencies of target PolygonPoints
[ 33%] Linking CXX executable PolygonPoints
/usr/bin/ld: CMakeFiles/PolygonPoints.dir/src/main.cpp.o: in function `main':
main.cpp:(.text+0x173): undefined reference to `Point::Point(sf::Vector2<int>, sf::Vector2<int>)'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/PolygonPoints.dir/build.make:117: PolygonPoints] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/PolygonPoints.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
 
    