Hello,
I am able to compile my SFML project on mac and windows with cmake but I'm having a lot of trouble on windows.
On mac I just follow the instructions on this page:
https://www.sfml-dev.org/tutorials/2.5/start-osx.php#installing-sfml and then run:
cmake -S . -B build
cmake --build build -- -j
And everything goes smoothly.
On windows I run
λ cmake -DSFML_DIR="C:/Users/souren/Documents/SFML-2.5.1/lib/cmake/SFML" -DBOOST_ROOT="C:\Program Files\boost_1_55_0"-S . -B build
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The CXX compiler identification is MSVC 19.24.28316.0
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found SFML 2.5.1 in C:/Users/souren/Documents/SFML-2.5.1/lib/cmake/SFML
-- Found Boost: C:/Program Files/boost_1_55_0 (found suitable version "1.55.0", minimum required is "1.55")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/souren/Documents/code/ungroup_game/build
cmake --build build
And I get a ton of "fatal error C1083: Cannot open include file: 'SFML/Network.hpp'" errors.
Why can't my files include SFML? Did I do something wrong when linking?
CMakeLists.txtcmake_minimum_required(VERSION 3.11..14)
# set the project name, version and language:w
project(Ungroup VERSION 1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# find sfml
find_package(SFML 2.5 COMPONENTS audio graphics window system REQUIRED)
# find boost
find_package(Boost 1.55 COMPONENTS REQUIRED)
add_subdirectory(src)
add_subdirectory(extern/catch)
add_subdirectory(extern/cxxopts)
add_subdirectory(tests)
src/client/CMakeLists.txttarget_link_libraries(ug-client PRIVATE client-lib common-lib cxxopts)
You can see the code in more detail here:
https://github.com/SourenP/ungroup_game/tree/c7614a15f1ca38b7a09ce2e24e86d843e68ea6f2Additional Details:
- I have a 64bit machine running windows 10
- I'm using the sfml download "GCC 7.3.0 MinGW (SEH) - 64-bit"