Error:Could NOT find SFML (missing: SFML_GRAPHICS_LIBRARY SFML_WINDOW_LIBRARY SFML_SYSTEM_LIBRARY)
cmake_minimum_required(VERSION 3.2)
project(SFMLTest)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(SFMLTest ${SOURCE_FILES})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/SFML-2.3.2/cmake/Modules/")
find_package(SFML REQUIRED graphics window system)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(SFMLTest ${SFML_LIBRARIES})
endif(SFML_FOUND)
Yes, it will help. Also, using the REQUIRED keyword will trigger a fatal error if the library is not found, so it is totally useless to test SFML_FOUND after that.
Error:Could NOT find SFML (missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY SFML_GRAPHICS_LIBRARY SFML_NETWORK_LIBRARY SFML_AUDIO_LIBRARY)
cmake_minimum_required(VERSION 3.2)
project(SFMLDemo3)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(SOURCE_FILES main.cpp)
add_executable(SFMLDemo3 ${SOURCE_FILES})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/SFML-2.3.2/cmake/Modules/")
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH} ${CMAKE_SOURCE_DIR}/SFML-2.3.2/lib")
set(SFML_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/SFML-2.3.2/include/SFML")
find_package(SFML COMPONENTS system window graphics network audio REQUIRED)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(SFMLDemo3 ${SFML_LIBRARIES})
endif(SFML_FOUND)
The SFML folder is on my DemoProject. So im pretty sure I have the correct directory.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/SFML-2.3.2/cmake/Modules/")
set(SFML_LIBRARIES "${CMAKE_SOURCE_DIR}/SFML-2.3.2/lib")
set(SFML_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/SFML-2.3.2/include")
MESSAGE(${SOURCE_FILES})
find_package(SFML COMPONENTS system window graphics network audio REQUIRED)
if (SFML_FOUND)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(SFMLDemo3 ${SFML_LIBRARIES})
endif(SFML_FOUND)
(missing: SFML_SYSTEM_LIBRARY SFML_WINDOW_LIBRARY
SFML_GRAPHICS_LIBRARY SFML_NETWORK_LIBRARY SFML_AUDIO_LIBRARY)
CMakeFiles\SFMLDemo3.dir/objects.a(main.cpp.obj): In function `main':
ClionProjects/SFMLDemo3/main.cpp:8: undefined reference to `_imp___ZN2sf6StringC1EPKcRKSt6locale'
ClionProjects/SFMLDemo3/main.cpp:8: undefined reference to `_imp___ZN2sf9VideoModeC1Ejjj'
ClionProjects/SFMLDemo3/main.cpp:8: undefined reference to `_imp___ZN2sf12RenderWindowC1ENS_9VideoModeERKNS_6StringEjRKNS_15ContextSettingsE'
ClionProjects/SFMLDemo3/main.cpp:17: undefined reference to `_imp___ZN2sf6Window5closeEv'
ClionProjects/SFMLDemo3/main.cpp:13: undefined reference to `_imp___ZN2sf6Window9pollEventERNS_5EventE'
ClionProjects/SFMLDemo3/main.cpp:21: undefined reference to `_imp___ZN2sf5ColorC1Ehhhh'
ClionProjects/SFMLDemo3/main.cpp:21: undefined reference to `_imp___ZN2sf12RenderTarget5clearERKNS_5ColorE'
ClionProjects/SFMLDemo3/main.cpp:22: undefined reference to `_imp___ZN2sf6Window7displayEv'
ClionProjects/SFMLDemo3/main.cpp:10: undefined reference to `_imp___ZNK2sf6Window6isOpenEv'
ClionProjects/SFMLDemo3/main.cpp:25: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
ClionProjects/SFMLDemo3/main.cpp:25: undefined reference to `_imp___ZN2sf12RenderWindowD1Ev'
set(SOURCE_FILES main.cpp)
add_executable(SFMLDemo3 ${SOURCE_FILES})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/SFML-2.3.2/cmake/Modules/")
set(SFML_LIBRARIES "${CMAKE_SOURCE_DIR}/SFML-2.3.2/lib")
set(SFML_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/SFML-2.3.2/include")
MESSAGE(${SFML_INCLUDE_DIR} " hahahaha")
find_package(SFML COMPONENTS system window graphics network audio)
include_directories(${SFML_INCLUDE_DIR})
target_link_libraries(SFMLDemo3 ${SFML_LIBRARIES})