Hi, I'm starting to try SFML, it works fine when I manually build(or use the SDK), and add it to the "Additional Library". But now I'd like to build a project with cmake and I want a "one click" solution to get it built.
Here is my folder:
root
--SFML(the src code from github)
--Myapp
----main.cpp
----main.h
----CMakeLists.txt
--CMakeLists.txt
In main.cpp and main.h is just a "Hello world" code of SFML, so we dont talk about it.
In "root/CMakeLists.txt":
cmake_minimum_required (VERSION 3.8)
project ("test")
add_subdirectory ("SFML")
add_subdirectory ("Myapp")
In "root/Myapp/CMakeLists.txt":
cmake_minimum_required (VERSION 3.8)
find_package(SFML 2.5 COMPONENTS graphics audio REQUIRED)
add_executable (myapp "main.cpp" "main.h")
target_link_libraries(myapp sfml-graphics sfml-audio)
Just like the wiki, but I got an error in VS 2017:
Requested SFML configuration (Shared) was not foundI found that in "SFMLConfig.cmake" there is
set(targets_config_file "${CMAKE_CURRENT_LIST_DIR}/SFML${config_name}Targets.cmake")
And I cant find the "SFML${config_name}Targets.cmake" in the "CMAKE_CURRENT_LIST_DIR", so it break.
I also tried in ubuntu using
mkdir build
cd build
cmake ..
I got these:
By not providing "FindSFML.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "SFML", but
CMake did not find one.
Could not find a package configuration file provided by "SFML" (requested
version 2.5) with any of the following names:
SFMLConfig.cmake
sfml-config.cmake
Add the installation prefix of "SFML" to CMAKE_PREFIX_PATH or set
"SFML_DIR" to a directory containing one of the above files. If "SFML"
provides a separate development package or SDK, be sure it has been
installed.
Now I dont want to install the SDK manually everytime, how can i use just "cmake .." and it will build SFML and then build myapp linked with it? Any suggestions?