aboutsummaryrefslogtreecommitdiff
path: root/src/CMakeLists.txt
blob: 401ff086ba28df3b251add08d9e347fa98653d10 (plain)
  1. cmake_minimum_required(VERSION 2.8)
  2. set(LIBRARY "cmark-shared")
  3. set(HEADERS
  4. cmark.h
  5. buffer.h
  6. chunk.h
  7. references.h
  8. debug.h
  9. utf8.h
  10. scanners.h
  11. inlines.h
  12. html/html_unescape.h
  13. html/houdini.h
  14. )
  15. set(LIBRARY_SOURCES
  16. blocks.c
  17. inlines.c
  18. print.c
  19. scanners.c
  20. scanners.re
  21. utf8.c
  22. buffer.c
  23. references.c
  24. html/html.c
  25. html/html_unescape.gperf
  26. html/houdini_href_e.c
  27. html/houdini_html_e.c
  28. html/houdini_html_u.c
  29. ${HEADERS}
  30. )
  31. set(PROGRAM "cmark")
  32. set(PROGRAM_SOURCES
  33. ${LIBRARY_SOURCES}
  34. main.c
  35. )
  36. include_directories(. html)
  37. if (MSVC)
  38. set(RE2C ${CMAKE_CURRENT_SOURCE_DIR}/re2c)
  39. file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} DOS_CURRENT_SOURCE_DIR)
  40. add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/scanners.c
  41. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re
  42. COMMAND ${RE2C} --case-insensitive -b -i ${DOS_CURRENT_SOURCE_DIR}\\scanners.re >${DOS_CURRENT_SOURCE_DIR}\\scanners.c)
  43. else(MSVC)
  44. set(RE2C re2c)
  45. add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/scanners.c
  46. DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re
  47. COMMAND ${RE2C} --case-insensitive -b -i ${CMAKE_CURRENT_SOURCE_DIR}/scanners.re >${CMAKE_CURRENT_SOURCE_DIR}/scanners.c)
  48. endif(MSVC)
  49. add_executable(${PROGRAM} ${PROGRAM_SOURCES})
  50. add_library(${LIBRARY} SHARED ${LIBRARY_SOURCES})
  51. set_target_properties(${LIBRARY}
  52. PROPERTIES OUTPUT_NAME "cmark")
  53. set_property(TARGET ${LIBRARY}
  54. APPEND PROPERTY MACOSX_RPATH true)
  55. if (MSVC)
  56. set_property(TARGET ${PROGRAM}
  57. APPEND PROPERTY LINK_FLAGS /INCREMENTAL:NO)
  58. endif(MSVC)
  59. install(TARGETS ${PROGRAM} ${LIBRARY}
  60. RUNTIME DESTINATION bin
  61. LIBRARY DESTINATION lib
  62. )
  63. install(DIRECTORY ./
  64. DESTINATION include/${PROJECT_NAME}
  65. FILES_MATCHING PATTERN "*.h")
  66. if(UNIX)
  67. INSTALL(FILES ../man/man1/cmark.1 DESTINATION share/man/man1)
  68. endif(UNIX)
  69. include (CheckIncludeFile)
  70. CHECK_INCLUDE_FILE (stdbool.h HAVE_STDBOOL_H)
  71. # Always compile with warnings
  72. if(MSVC)
  73. # Force to always compile with W4
  74. if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
  75. string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
  76. else()
  77. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
  78. endif()
  79. elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  80. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99")
  81. endif()