aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: b19d98f972a6dbdc5f2964b4b85d8a5326cad132 (plain)
  1. project(stmd)
  2. cmake_minimum_required(VERSION 2.8)
  3. set(PROJECT_NAME "stmd")
  4. set(PROJECT_VERSION_MAJOR 0)
  5. set(PROJECT_VERSION_MINOR 0)
  6. set(PROJECT_VERSION_PATCH 1)
  7. set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH} )
  8. include (CheckIncludeFile)
  9. CHECK_INCLUDE_FILE (stdbool.h HAVE_STDBOOL_H)
  10. #option(${PROJECT_NAME}_WITH_DOCS "generate Documentation" OFF)
  11. #option(${PROJECT_NAME}_WITH_TESTS "enable testing" ON)
  12. option(CMAKE_SUPPRESS_REGENERATION "suppress rules to re-run cmake on changes (warning: no dependency checks!)?" OFF)
  13. if (MSVC)
  14. set(RE2C ${CMAKE_CURRENT_SOURCE_DIR}/re2c)
  15. else(MSVC)
  16. set(RE2C re2c)
  17. endif(MSVC)
  18. if (MSVC)
  19. option(PROJECT_LINK_MSVC_MT "link with /MT instead of /MD (use msvc runtime dlls versus static linked)" ON)
  20. # see http://msdn.microsoft.com/en-us/library/2kzt1wy3%28VS.71%29.aspx
  21. if (PROJECT_LINK_MSVC_MT)
  22. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
  23. set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
  24. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
  25. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
  26. endif (PROJECT_LINK_MSVC_MT)
  27. set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /INCREMENTAL:NO")
  28. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4")
  29. set(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /W4")
  30. set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS UNICODE)
  31. set(CMAKE_FIND_LIBRARY_PREFIXES "")
  32. set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
  33. set(CMAKE_STATIC_LIBRARY_PREFIX "lib")
  34. set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
  35. set(CMAKE_SHARED_LIBRARY_PREFIX "") # lib
  36. set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll") # .so
  37. set(CMAKE_IMPORT_LIBRARY_PREFIX "")
  38. set(CMAKE_IMPORT_LIBRARY_SUFFIX ".lib")
  39. set(CMAKE_EXECUTABLE_SUFFIX ".exe") # .exe
  40. set(CMAKE_LINK_LIBRARY_SUFFIX ".lib")
  41. set(CMAKE_DL_LIBS "")
  42. set(CMAKE_DEBUG_POSTFIX "d")
  43. add_definitions(-DUNICODE -D_UNICODE)
  44. else(MSVC)
  45. list(APPEND CMAKE_CXX_FLAGS "-Wall -Wunused-variable -Wno-long-long")
  46. #-pedantic
  47. list(APPEND CMAKE_C_FLAGS "-Wall -Wunused-variable -Wno-long-long")
  48. endif(MSVC)
  49. # create config.h
  50. configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
  51. ${CMAKE_CURRENT_BINARY_DIR}/config.h)
  52. # set include directories
  53. get_filename_component(CONFIG_INCLUDE ${CMAKE_CURRENT_BINARY_DIR}/config.h PATH)
  54. include_directories(include ${CONFIG_INCLUDE})
  55. install(DIRECTORY include DESTINATION .
  56. COMPONENT devel
  57. FILES_MATCHING PATTERN "*.h"
  58. PATTERN .svn EXCLUDE
  59. )
  60. install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h
  61. DESTINATION include/${PROJECT_NAME}
  62. COMPONENT devel)
  63. add_subdirectory(src)
  64. include(InstallRequiredSystemLibraries)
  65. set(CPACK_GENERATOR TGZ ZIP)
  66. if(WIN32 AND NOT CYGWIN)
  67. set(CPACK_GENERATOR NSIS ${CPACK_GENERATOR})
  68. endif(WIN32 AND NOT CYGWIN)
  69. if(APPLE)
  70. set(CPACK_GENERATOR DragNDrop ${CPACK_GENERATOR})
  71. endif(APPLE)
  72. if (UNIX AND NOT APPLE AND NOT WIN32)
  73. set(CPACK_GENERATOR DEB ${CPACK_GENERATOR})
  74. endif (UNIX AND NOT APPLE AND NOT WIN32)
  75. set(CPACK_SOURCE_PACKAGE_FILE_NAME ${PROJECT_NAME}-src-${PROJECT_VERSION})
  76. set(CPACK_SOURCE_GENERATOR TGZ ZIP)
  77. set(CPACK_PACKAGE_CONTACT http://talk.commonmark.org/)
  78. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_NAME})
  79. set(CPACK_PACKAGE_VENDOR "${PROJECT_NAME} Development Team")
  80. set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
  81. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
  82. set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
  83. set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
  84. set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
  85. set(CPACK_SOURCE_IGNORE_FILES "/docs/html;/autom4te.cache;/build/;/win32/;/.svn/;~$;${CPACK_SOURCE_IGNORE_FILES}")
  86. if(WIN32 AND NOT UNIX)
  87. set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}\\\\${PROJECT_VERSION}")
  88. # There is a bug in NSI that does not handle full unix paths properly. Make
  89. # sure there is at least one set of four (4) backlashes.
  90. # set(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\InstallIcon.bmp")
  91. set(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${PROJECT_NAME}.exe")
  92. set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
  93. set(CPACK_NSIS_HELP_LINK "http://commonmark.org/")
  94. set(CPACK_NSIS_URL_INFO_ABOUT "http://commonmark.org/")
  95. set(CPACK_NSIS_CONTACT "http://talk.commonmark.org/")
  96. set(CPACK_NSIS_MODIFY_PATH ON)
  97. set(CPACK_NSIS_MENU_LINKS "doc/html/index.html;Documentation")
  98. else(WIN32 AND NOT UNIX)
  99. set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME}/${PROJECT_VERSION}")
  100. set(CPACK_STRIP_FILES "bin/${PROJECT_NAME}")
  101. set(CPACK_SOURCE_STRIP_FILES "")
  102. endif(WIN32 AND NOT UNIX)
  103. set(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME};${PROJECT_NAME})
  104. include(CPack)