CMakeLists.txt 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Taken from https://github.com/Microsoft/vcpkg/blob/2ad118a2532e99a78c41dffa1b9648e7eca20a95/ports/sdl2-ttf/CMakeLists.txt
  2. cmake_minimum_required(VERSION 3.0)
  3. project(SDL2_TTF C)
  4. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/mk/cmake)
  5. option(SDL2TTF_INSTALL "Install target for SDL2_ttf." ON)
  6. find_path(SDL_INCLUDE_DIR SDL2/SDL.h)
  7. find_library(SDL_LIBRARY NAMES SDL2d SDL2)
  8. find_package(Freetype REQUIRED)
  9. add_library(SDL2_ttf SDL_ttf.c version.rc)
  10. set_target_properties(SDL2_ttf PROPERTIES DEFINE_SYMBOL SDL2_EXPORTS)
  11. target_include_directories(SDL2_ttf PRIVATE ${SDL_INCLUDE_DIR}/SDL2 ${FREETYPE_INCLUDE_DIR_ft2build} ${PROJECT_SOURCE_DIR})
  12. target_include_directories(SDL2_ttf PUBLIC $<INSTALL_INTERFACE:include/SDL2>)
  13. if(WITH_RAQM)
  14. find_package(RAQM REQUIRED)
  15. add_definitions(-DHAVE_RAQM=1)
  16. target_include_directories(SDL2_ttf PRIVATE ${RAQM_INCLUDE_DIR})
  17. target_link_libraries(SDL2_ttf PUBLIC ${RAQM_LIBRARY})
  18. endif()
  19. target_link_libraries(SDL2_ttf PRIVATE ${SDL_LIBRARY} ${FREETYPE_LIBRARY})
  20. if(SDL2TTF_INSTALL)
  21. include(GNUInstallDirs)
  22. install(TARGETS SDL2_ttf
  23. EXPORT sdl2_ttf-targets
  24. RUNTIME DESTINATION bin
  25. ARCHIVE DESTINATION lib
  26. LIBRARY DESTINATION lib)
  27. if(NOT DEFINED SDL_TTF_SKIP_HEADERS)
  28. install(FILES SDL_ttf.h DESTINATION include/SDL2)
  29. endif()
  30. # CMake integration
  31. configure_file(sdl2_ttf-config.cmake.in
  32. "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/sdl2_ttf-config.cmake" @ONLY)
  33. install(FILES
  34. "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/sdl2_ttf-config.cmake"
  35. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SDL2_ttf/")
  36. export(TARGETS SDL2_ttf
  37. FILE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/sdl2_ttf-targets.cmake")
  38. export(PACKAGE SDL2_ttf)
  39. install(EXPORT sdl2_ttf-targets
  40. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SDL2_ttf/")
  41. endif()
  42. message(STATUS "Link-time dependencies:")
  43. message(STATUS " " ${SDL_LIBRARY})
  44. message(STATUS " " ${FREETYPE_LIBRARY})