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