Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Static linking with CMake on Windows  (Read 4256 times)

0 Members and 1 Guest are viewing this topic.

Philosoph228

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Static linking with CMake on Windows
« on: July 10, 2017, 08:09:53 pm »
Hi, I want to use dependent libraries like freetype or jpeg, which are already supplied in lib directory. How can I do it correctly with FindSFML.cmake?

My current CMakeLists.txt is:
cmake_minimum_required(VERSION 2.6)

add_executable(main main.cpp)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules" ${CMAKE_MODULE_PATH})

set(SFML_STATIC_LIBRARIES TRUE)
find_package(SFML 2 COMPONENTS system graphics window)
if(SFML_FOUND)
  include_directories(${SFML_INCLUDE_DIR})
  target_link_libraries(main winmm opengl32 freetype jpeg gdi32 ${SFML_LIBRARIES})
endif()
(click to show/hide)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Static linking with CMake on Windows
« Reply #1 on: July 10, 2017, 08:28:58 pm »
You need to use the correct linking order.

With CMake this is pretty easy to do.

target_link_libraries(main ${SFML_LIBRARIES} ${SFML_DEPEDENCIES})
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything