stb.cmake 836 B

1234567891011121314151617181920212223242526272829303132
  1. if(TARGET stb::stb)
  2. return()
  3. endif()
  4. message(STATUS "Third-party: creating target 'stb::stb'")
  5. include(FetchContent)
  6. FetchContent_Declare(
  7. stb
  8. GIT_REPOSITORY https://github.com/nothings/stb.git
  9. GIT_TAG f67165c2bb2af3060ecae7d20d6f731173485ad0
  10. )
  11. FetchContent_MakeAvailable(stb)
  12. # Generate implementation file
  13. file(WRITE "${stb_BINARY_DIR}/stb_image.cpp.in" [[
  14. #define STB_IMAGE_IMPLEMENTATION
  15. #include <stb_image.h>
  16. #define STB_IMAGE_WRITE_IMPLEMENTATION
  17. #include <stb_image_write.h>
  18. ]])
  19. configure_file(${stb_BINARY_DIR}/stb_image.cpp.in ${stb_BINARY_DIR}/stb_image.cpp COPYONLY)
  20. # Define stb library
  21. add_library(stb ${stb_BINARY_DIR}/stb_image.cpp)
  22. add_library(stb::stb ALIAS stb)
  23. target_include_directories(stb PUBLIC "${stb_SOURCE_DIR}")
  24. set_target_properties(stb PROPERTIES FOLDER ThirdParty)