I have been working on a relatively large project using SFML in Windows (Visual Studio) for a couple years, and I now potential developers who are using linux machines, and I want to make my project cross platform. I am using very few or no windows dependencies, but it seems like migrating the project over to Cmake is the best/only way to make the project cross platform.
I have been working on migrating the project and everything seems set up correctly, but I am getting an error saying "Cannot open include file: 'SFML\Graphics.hpp': No such file or directory", I assume this is an issue with linking the library through CMake, but I cannot figure out what I am doing wrong.
Here is my CMakeLists.txt:
# CMakeList.txt : CMake project for GameEngine2020, include source and define
# project specific logic here.
#
# set minimum version required for CMake
cmake_minimum_required (VERSION 3.8)
set(PROJECT_NAME "GameEngine2020")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
project(${PROJECT_NAME})
## If you want to link SFML statically
#set(SFML_STATIC_LIBRARIES TRUE)
## In most cases better set in the CMake cache
set(SFML_DIR "${CMAKE_CURRENT_LIST_DIR}/SFML/lib/cmake/SFML")
#file(GLOB ALL_REQUIRED_DLL "${CMAKE_CURRENT_LIST_DR}/SFML/bin/*.dll")
#file(COPY ${ALL_REQUIRED_DLL} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
set(SOURCE_FILES
ActionState.h
...
...(all the program files)...
...
TileSet.h
)
find_package(SFML 2.5 COMPONENTS graphics audio main network system window REQUIRED)
add_executable(${PROJECT_NAME} GameEngine2020.cpp GameEngine2020.h)
target_link_libraries(${PROJECT_NAME} sfml-graphics-d sfml-audio-d sfml-system-d sfml-window-d)
The rest of the code is on github here, but I think the issue is something within the CMakeLists.txt:
https://github.com/InterdimensionalCat/2020GameEngine.gitEDIT: Solved, I was using ${CMAKE_CURRENT_LIST_DIR} when I should have been using ${PROJECT_SOURCE_DIR} not sure how I made that mistake