configure SFML for clion (windows)

前端 未结 3 544
-上瘾入骨i
-上瘾入骨i 2021-01-03 09:31

i am setting up a work environment for a school project on my windows computer. We are going to make a basic game using c++ and CLion. To make a game i need to use the SFML

3条回答
  •  旧时难觅i
    2021-01-03 10:16

    I have successfully configured SFML with CLion on Ubuntu 16.04 and I think it will be same for Window user also.

    My project name is SFML_TEST so change every occurrence of SFML_TEST with your project name.

    1. Create a new Clion C++ Project.
    2. Navigate to /path/to/CLionProjects/[Project_Name]/CMakeLists.txt
    3. After the following statement

      add_executable(SFML_TEST ${SOURCE_FILES})
      

      Add following lines of code

      set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
      find_package(SFML REQUIRED system window graphics network audio)
      if (SFML_FOUND)
      include_directories(${SFML_INCLUDE_DIR})
      target_link_libraries(SFML_TEST ${SFML_LIBRARIES})
      endif()
      
    4. Create a new directory /path/to/CLionProjects/[project_name]/cmake_modules/FindSFML.cmake

    5. In FindSFML.cmake file paste the following line of code from the given file https://github.com/SFML/SFML/blob/master/cmake/Modules/FindSFML.cmake
    6. Done!!!.. Happy Coding

提交回复
热议问题