CMakeLists.txt 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # tinygettext - A gettext replacement that works directly on .po files
  2. # Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>,
  3. # 2020 Ingo Ruhnke <grumbel@gmail.com>
  4. #
  5. # This software is provided 'as-is', without any express or implied
  6. # warranty. In no event will the authors be held liable for any damages
  7. # arising from the use of this software.
  8. #
  9. # Permission is granted to anyone to use this software for any purpose,
  10. # including commercial applications, and to alter it and redistribute it
  11. # freely, subject to the following restrictions:
  12. #
  13. # 1. The origin of this software must not be misrepresented; you must not
  14. # claim that you wrote the original software. If you use this software
  15. # in a product, an acknowledgement in the product documentation would be
  16. # appreciated but is not required.
  17. # 2. Altered source versions must be plainly marked as such, and must not be
  18. # misrepresented as being the original software.
  19. # 3. This notice may not be removed or altered from any source distribution.
  20. cmake_minimum_required(VERSION 3.0)
  21. project(tinygettext VERSION "0.2.0")
  22. file(GLOB TINYGETTEXT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp)
  23. file(GLOB TINYGETTEXT_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/tinygettext/*.hpp)
  24. add_library(tinygettext STATIC ${TINYGETTEXT_SOURCES})
  25. set_target_properties(tinygettext PROPERTIES
  26. CXX_STANDARD 17
  27. CXX_STANDARD_REQUIRED ON
  28. CXX_EXTENSIONS OFF
  29. PUBLIC_HEADER "${TINYGETTEXT_HEADERS}")
  30. target_include_directories(tinygettext PUBLIC
  31. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  32. $<INSTALL_INTERFACE:include>)
  33. target_compile_definitions(tinygettext PRIVATE VERSION=${TINYGETTEXT_VERSION})
  34. if(WIN32)
  35. set(TGT_SDL_DEFAULT ON)
  36. else()
  37. set(TGT_SDL_DEFAULT OFF)
  38. endif()
  39. option(TINYGETTEXT_WITH_SDL "Use SDL's iconv implementation with tinygettext. Ideal for Windows" ${TGT_SDL_DEFAULT})
  40. if(TINYGETTEXT_WITH_SDL)
  41. # If your CMake configuration is failing here, that's because
  42. # the variables SDL2_LIBRARY and SDL2_INCLUDE_DIRS must be defined.
  43. # You can use find_package or pkgconfig before adding this submodule
  44. # to fix this issue.
  45. target_compile_definitions(tinygettext PUBLIC TINYGETTEXT_WITH_SDL)
  46. target_link_libraries(tinygettext PUBLIC ${SDL2_LIBRARY})
  47. target_include_directories(tinygettext PUBLIC ${SDL2_INCLUDE_DIRS})
  48. else()
  49. find_package(Iconv REQUIRED)
  50. target_link_libraries(tinygettext PUBLIC Iconv::Iconv)
  51. endif()
  52. if(WIN32)
  53. target_compile_definitions(tinygettext PRIVATE _CRT_SECURE_NO_WARNINGS)
  54. endif()
  55. configure_file(tinygettext.pc.in tinygettext.pc @ONLY)
  56. install(TARGETS tinygettext
  57. EXPORT tinygettext-targets
  58. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  59. PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
  60. install(FILES ${tinygettext_BINARY_DIR}/tinygettext.pc
  61. DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
  62. # EOF #