CMakeLists.txt 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Expat CPP sources to be excluded from globbed SRCS_G
  2. # They are added back on the list if POCO_UNBUNDLED is not set
  3. set(EXPAT_CPP "${CMAKE_CURRENT_SOURCE_DIR}/src/xmlparse.cpp")
  4. # Sources
  5. file(GLOB SRCS_G "src/*.cpp")
  6. list(REMOVE_ITEM SRCS_G ${EXPAT_CPP})
  7. POCO_SOURCES_AUTO(SRCS ${SRCS_G})
  8. # Headers
  9. file(GLOB_RECURSE HDRS_G "include/*.h")
  10. POCO_HEADERS_AUTO(SRCS ${HDRS_G})
  11. # Version Resource
  12. if(MSVC AND BUILD_SHARED_LIBS)
  13. source_group("Resources" FILES ${PROJECT_SOURCE_DIR}/DLLVersion.rc)
  14. list(APPEND SRCS ${PROJECT_SOURCE_DIR}/DLLVersion.rc)
  15. endif()
  16. # If POCO_UNBUNDLED is enabled we try to find the required packages
  17. # The configuration will fail if the packages are not found
  18. if(POCO_UNBUNDLED)
  19. find_package(EXPAT REQUIRED)
  20. else()
  21. POCO_SOURCES(SRCS expat
  22. src/xmlparse.cpp
  23. src/xmlrole.c
  24. src/xmltok.c
  25. src/xmltok_impl.c
  26. src/xmltok_ns.c
  27. )
  28. endif(POCO_UNBUNDLED)
  29. add_library(XML ${SRCS})
  30. add_library(Poco::XML ALIAS XML)
  31. set_target_properties(XML
  32. PROPERTIES
  33. VERSION ${SHARED_LIBRARY_VERSION} SOVERSION ${SHARED_LIBRARY_VERSION}
  34. OUTPUT_NAME PocoXML
  35. DEFINE_SYMBOL XML_EXPORTS
  36. )
  37. target_link_libraries(XML PUBLIC Poco::Foundation)
  38. target_include_directories(XML
  39. PUBLIC
  40. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  41. $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
  42. PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src
  43. )
  44. if(POCO_UNBUNDLED)
  45. target_link_libraries(XML PUBLIC EXPAT::EXPAT)
  46. target_compile_definitions(XML PUBLIC POCO_UNBUNDLED)
  47. else()
  48. if(WIN32)
  49. #TODO: Is XML_STATIC only required with Windows? What does it do?
  50. target_compile_definitions(XML PUBLIC XML_STATIC)
  51. endif()
  52. target_compile_definitions(XML
  53. PUBLIC XML_DTD XML_GE
  54. PRIVATE XML_NS HAVE_EXPAT_CONFIG_H)
  55. endif()
  56. POCO_INSTALL(XML)
  57. POCO_GENERATE_PACKAGE(XML)
  58. if(ENABLE_SAMPLES)
  59. add_subdirectory(samples)
  60. endif()
  61. if(ENABLE_TESTS)
  62. add_subdirectory(testsuite)
  63. endif()