CMakeLists.txt 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. cmake_minimum_required(VERSION 3.16)
  2. project(i2pdtunnelwizard LANGUAGES CXX)
  3. set(HTML_TEMPLATE_FILE "${CMAKE_SOURCE_DIR}/htmldata.cpp")
  4. if(NOT EXISTS "${HTML_TEMPLATE_FILE}")
  5. file(WRITE "${HTML_TEMPLATE_FILE}" "// This file was created automatically\n")
  6. endif()
  7. function(add_html_content html_file const_name)
  8. file(READ "${html_file}" HTML_CONTENT)
  9. string(REPLACE "\n" " " HTML_CONTENT "${HTML_CONTENT}")
  10. string(REGEX REPLACE " + " " " HTML_CONTENT "${HTML_CONTENT}")
  11. string(REGEX REPLACE "^ +| +$" "" HTML_CONTENT "${HTML_CONTENT}")
  12. # Проверка на существование константы
  13. file(READ "${HTML_TEMPLATE_FILE}" TEMPLATE_CONTENT)
  14. if("${TEMPLATE_CONTENT}" MATCHES "${const_name}")
  15. message(STATUS "${const_name} already defined")
  16. else()
  17. file(APPEND "${HTML_TEMPLATE_FILE}" "const char* ${const_name} = R\"(")
  18. file(APPEND "${HTML_TEMPLATE_FILE}" "${HTML_CONTENT}")
  19. file(APPEND "${HTML_TEMPLATE_FILE}" ")\";\n")
  20. endif()
  21. endfunction()
  22. add_html_content("${CMAKE_SOURCE_DIR}/html/main_page.html" "HTML_MAIN_PAGE")
  23. add_html_content("${CMAKE_SOURCE_DIR}/html/config_page.html" "HTML_CONFIG_PAGE")
  24. add_html_content("${CMAKE_SOURCE_DIR}/html/error_page.html" "HTML_ERROR_PAGE")
  25. set(CMAKE_CXX_STANDARD 20)
  26. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  27. add_executable(i2pdtunnelwizard main.cpp
  28. "${HTML_TEMPLATE_FILE}"
  29. htmldata.h
  30. versionnumber.h
  31. tunnelconstructor.h tunnelconstructor.cpp
  32. notepad.h notepad.cpp
  33. tunneltype.h
  34. randomstringgenerator.h randomstringgenerator.cpp
  35. randomstringgenerator.h randomstringgenerator.cpp
  36. memorymanagment.h memorymanagment.cpp
  37. http/crow.h
  38. http/crow/app.h
  39. http/crow/ci_map.h
  40. http/crow/common.h
  41. http/crow/compression.h
  42. http/crow/exceptions.h
  43. http/crow/http_connection.h
  44. http/crow/http_parser_merged.h
  45. http/crow/http_request.h
  46. http/crow/http_response.h
  47. http/crow/http_server.h
  48. http/crow/json.h
  49. http/crow/logging.h
  50. http/crow/middleware.h
  51. http/crow/middleware_context.h
  52. http/crow/mime_types.h
  53. http/crow/multipart.h
  54. http/crow/multipart_view.h
  55. http/crow/mustache.h
  56. http/crow/parser.h
  57. http/crow/query_string.h
  58. http/crow/returnable.h
  59. http/crow/routing.h
  60. http/crow/settings.h
  61. http/crow/socket_adaptors.h
  62. http/crow/task_timer.h
  63. http/crow/utility.h
  64. http/crow/version.h
  65. http/crow/websocket.h
  66. http/crow/middlewares/cookie_parser.h
  67. http/crow/middlewares/cors.h
  68. http/crow/middlewares/session.h
  69. http/crow/middlewares/utf-8.h
  70. http/httpserver.h http/httpserver.cpp
  71. http/languagehandlermiddleware.h http/languagehandlermiddleware.cpp)
  72. include(GNUInstallDirs)
  73. install(TARGETS i2pdtunnelwizard
  74. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  75. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  76. )