CMakeLists.txt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. cmake_minimum_required(VERSION 3.0)
  2. project(EXPAT)
  3. if (BUILD_SHARED_LIBS AND MSVC)
  4. set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
  5. endif()
  6. add_library(expat
  7. xmlparse.c
  8. xmlrole.c
  9. xmltok.c
  10. )
  11. target_include_directories(expat PRIVATE ${PROJECT_SOURCE_DIR})
  12. include(GNUInstallDirs)
  13. install(
  14. FILES
  15. ${PROJECT_SOURCE_DIR}/expat.h
  16. ${PROJECT_SOURCE_DIR}/expat_config.h
  17. ${PROJECT_SOURCE_DIR}/expat_external.h
  18. DESTINATION
  19. ${CMAKE_INSTALL_INCLUDEDIR}
  20. )
  21. add_library(EXPAT INTERFACE)
  22. target_link_libraries(EXPAT INTERFACE expat)
  23. include(CMakePackageConfigHelpers)
  24. write_basic_package_version_file(
  25. "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
  26. VERSION 1.95
  27. COMPATIBILITY AnyNewerVersion
  28. )
  29. install(TARGETS expat EXPAT
  30. EXPORT ${PROJECT_NAME}Targets
  31. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  32. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  33. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  34. INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  35. )
  36. export(EXPORT ${PROJECT_NAME}Targets
  37. FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
  38. NAMESPACE ${PROJECT_NAME}:: )
  39. set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
  40. install(EXPORT ${PROJECT_NAME}Targets
  41. FILE
  42. "${PROJECT_NAME}Targets.cmake"
  43. NAMESPACE
  44. ${PROJECT_NAME}::
  45. DESTINATION
  46. ${ConfigPackageLocation}
  47. )
  48. configure_file(config.cmake.in ${PROJECT_NAME}Config.cmake @ONLY)
  49. install(
  50. FILES
  51. "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
  52. "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
  53. DESTINATION
  54. ${ConfigPackageLocation}
  55. )