CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. include(mk/cmake/TinyCMMC.cmake)
  22. project(tinygettext VERSION "0.2.0")
  23. file(GLOB TINYGETTEXT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp)
  24. file(GLOB TINYGETTEXT_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} include/tinygettext/*.hpp)
  25. add_library(tinygettext STATIC ${TINYGETTEXT_SOURCES})
  26. set_target_properties(tinygettext PROPERTIES
  27. CXX_STANDARD 17
  28. CXX_STANDARD_REQUIRED ON
  29. CXX_EXTENSIONS OFF
  30. PUBLIC_HEADER "${TINYGETTEXT_HEADERS}")
  31. target_include_directories(tinygettext PUBLIC
  32. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  33. $<INSTALL_INTERFACE:include>)
  34. target_compile_options(tinygettext PRIVATE ${TINYCMMC_WARNINGS_CXX_FLAGS})
  35. target_compile_definitions(tinygettext PRIVATE VERSION=${TINYGETTEXT_VERSION})
  36. if(TINYGETTEXT_WITH_SDL)
  37. find_package(PkgConfig REQUIRED)
  38. pkg_search_module(SDL2 REQUIRED sdl2 IMPORTED_TARGET)
  39. target_compile_definitions(tinygettext PUBLIC TINYGETTEXT_WITH_SDL)
  40. target_link_libraries(tinygettext PUBLIC PkgConfig::SDL2)
  41. else()
  42. find_package(Iconv REQUIRED)
  43. target_link_libraries(tinygettext PUBLIC Iconv::Iconv)
  44. endif()
  45. if(WIN32)
  46. target_compile_definitions(tinygettext PRIVATE _CRT_SECURE_NO_WARNINGS)
  47. endif()
  48. configure_file(tinygettext.pc.in tinygettext.pc @ONLY)
  49. install(TARGETS tinygettext
  50. EXPORT tinygettext-targets
  51. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  52. PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})
  53. install(FILES ${tinygettext_BINARY_DIR}/tinygettext.pc
  54. DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
  55. # CMake integration
  56. tinycmmc_export_and_install_library(tinygettext)
  57. if(BUILD_TESTS)
  58. foreach(TEST tinygettext_test po_parser_test)
  59. add_executable(${TEST} test/${TEST}.cpp)
  60. set_target_properties(${TEST} PROPERTIES
  61. CXX_STANDARD 17
  62. CXX_STANDARD_REQUIRED ON
  63. CXX_EXTENSIONS OFF)
  64. target_compile_options(${TEST} PRIVATE ${TINYCMMC_WARNINGS_CXX_FLAGS})
  65. if(WIN32)
  66. target_compile_definitions(${TEST} PRIVATE _CRT_SECURE_NO_WARNINGS)
  67. endif()
  68. target_link_libraries(${TEST} PRIVATE tinygettext)
  69. endforeach(TEST)
  70. endif()
  71. # EOF #