CMakeLists.txt 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #
  2. # Copyright (c) 2008-2020 the Urho3D project.
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. #
  22. # Define target name
  23. set (TARGET_NAME Civetweb)
  24. # Define preprocessor macros
  25. # Always disable Common Gateway Interface
  26. add_definitions(-DNO_CGI -DNO_FILES -DNO_CACHING)
  27. # Allow debug output to console
  28. # add_definitions(-DDEBUG)
  29. if (WIN32)
  30. include (CheckStructHasMember)
  31. check_struct_has_member (struct\ timespec tv_sec time.h HAVE_STRUCT_TIMESPEC_TV_SEC)
  32. if (HAVE_STRUCT_TIMESPEC_TV_SEC)
  33. include (CheckSymbolExists)
  34. check_symbol_exists (_TIMESPEC_DEFINED time.h HAVE__TIMESPEC_DEFINED)
  35. if (NOT HAVE__TIMESPEC_DEFINED)
  36. add_definitions (-D_TIMESPEC_DEFINED)
  37. endif ()
  38. endif ()
  39. elseif (APPLE AND (NOT IOS OR IPHONEOS_DEPLOYMENT_TARGET STREQUAL "" OR NOT IPHONEOS_DEPLOYMENT_TARGET VERSION_LESS 10.0)) # We cheat a little bit here with a hard-coded check because iOS 10.3 SDK when targeting 9.3 has strong symbol for iPhoneOS archs but weak symbol for iPhoneSimulator archs
  40. include (CheckLibraryExists)
  41. check_library_exists (c clock_gettime "" FOUND_CLOCK_GETTIME_IN_C)
  42. if (FOUND_CLOCK_GETTIME_IN_C)
  43. add_definitions (-DHAVE_CLOCK_GETTIME)
  44. endif ()
  45. endif ()
  46. if (NOT URHO3D_SSL)
  47. add_definitions(-DNO_SSL)
  48. elseif (NOT URHO3D_SSL_DYNAMIC)
  49. add_definitions(-DNO_SSL_DL)
  50. endif ()
  51. # Define source files
  52. define_source_files (GLOB_CPP_PATTERNS src/*.c GLOB_H_PATTERNS include/*.h)
  53. # Define include directory
  54. set (INCLUDE_DIRS include)
  55. # Setup target
  56. setup_library ()
  57. # Link OpenSSL libraries
  58. if (URHO3D_SSL)
  59. if (URHO3D_SSL_DYNAMIC)
  60. # Unix systems can define the dynamic library names to load
  61. if (UNIX AND NOT DARWIN)
  62. add_definitions(-DCRYPTO_LIB="libcrypto.so")
  63. add_definitions(-DSSL_LIB="libssl.so")
  64. endif ()
  65. find_library(LIBDL_LIBRARIES dl)
  66. include(FindPackageHandleStandardArgs)
  67. find_package_handle_standard_args(LibDl DEFAULT_MSG LIBDL_LIBRARIES LIBDL_INCLUDE_DIRS)
  68. mark_as_advanced(LIBDL_INCLUDE_DIRS LIBDL_LIBRARIES)
  69. find_path(LIBDL_INCLUDE_DIRS
  70. NAMES dlfcn.h
  71. PATHS ${LIBDL_ROOT}/include/
  72. )
  73. if (LIBDL_FOUND)
  74. if (NOT TARGET LIBDL::LIBDL)
  75. add_library(LIBDL::LIBDL UNKNOWN IMPORTED)
  76. set_target_properties(LIBDL::LIBDL PROPERTIES
  77. IMPORTED_LOCATION "${LIBDL_LIBRARIES}"
  78. INTERFACE_INCLUDE_DIRECTORIES "${LIBDL_INCLUDE_DIRS}"
  79. )
  80. endif ()
  81. endif ()
  82. if (LIBDL_FOUND)
  83. target_link_libraries(Civetweb -ldl)
  84. endif ()
  85. else ()
  86. if (APPLE)
  87. set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
  88. endif ()
  89. find_package(OpenSSL REQUIRED)
  90. include_directories(${OPENSSL_INCLUDE_DIR})
  91. message(STATUS "OpenSSL include directory: ${OPENSSL_INCLUDE_DIR}")
  92. add_definitions(-DOPENSSL_API_1_1)
  93. endif ()
  94. endif ()
  95. # Install headers for building the Urho3D library
  96. install_header_files (DIRECTORY include/ DESTINATION ${DEST_INCLUDE_DIR}/ThirdParty/Civetweb FILES_MATCHING PATTERN *.h BUILD_TREE_ONLY) # Note: the trailing slash is significant