summaryrefslogtreecommitdiffstats
path: root/src/civetweb/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/civetweb/cmake')
-rw-r--r--src/civetweb/cmake/AddCCompilerFlag.cmake38
-rw-r--r--src/civetweb/cmake/AddCXXCompilerFlag.cmake38
-rw-r--r--src/civetweb/cmake/DetermineTargetArchitecture.cmake47
-rw-r--r--src/civetweb/cmake/FindLibDl.cmake46
-rw-r--r--src/civetweb/cmake/FindLibM.cmake47
-rw-r--r--src/civetweb/cmake/FindLibRt.cmake46
-rw-r--r--src/civetweb/cmake/FindLibSubunit.cmake46
-rw-r--r--src/civetweb/cmake/FindWinSock.cmake102
-rw-r--r--src/civetweb/cmake/check/c82fe8888aacfe784476112edd3878256d2e30bc.patch31
-rw-r--r--src/civetweb/cmake/check/patch.cmake12
10 files changed, 453 insertions, 0 deletions
diff --git a/src/civetweb/cmake/AddCCompilerFlag.cmake b/src/civetweb/cmake/AddCCompilerFlag.cmake
new file mode 100644
index 000000000..f5550fa74
--- /dev/null
+++ b/src/civetweb/cmake/AddCCompilerFlag.cmake
@@ -0,0 +1,38 @@
+# - Adds a compiler flag if it is supported by the compiler
+#
+# This function checks that the supplied compiler flag is supported and then
+# adds it to the corresponding compiler flags
+#
+# add_c_compiler_flag(<FLAG> [<VARIANT>])
+#
+# - Example
+#
+# include(AddCCompilerFlag)
+# add_c_compiler_flag(-Wall)
+# add_c_compiler_flag(-no-strict-aliasing RELEASE)
+# Requires CMake 2.6+
+
+if(__add_c_compiler_flag)
+ return()
+endif()
+set(__add_c_compiler_flag INCLUDED)
+
+include(CheckCCompilerFlag)
+
+function(add_c_compiler_flag FLAG)
+ string(TOUPPER "HAVE_C_FLAG_${FLAG}" SANITIZED_FLAG)
+ string(REPLACE "+" "X" SANITIZED_FLAG ${SANITIZED_FLAG})
+ string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
+ string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
+ set(CMAKE_REQUIRED_FLAGS "${FLAG}")
+ check_c_compiler_flag("" ${SANITIZED_FLAG})
+ if(${SANITIZED_FLAG})
+ set(VARIANT ${ARGV1})
+ if(ARGV1)
+ string(REGEX REPLACE "[^A-Za-z_0-9]" "_" VARIANT "${VARIANT}")
+ string(TOUPPER "_${VARIANT}" VARIANT)
+ endif()
+ set(CMAKE_C_FLAGS${VARIANT} "${CMAKE_C_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE)
+ endif()
+endfunction()
+
diff --git a/src/civetweb/cmake/AddCXXCompilerFlag.cmake b/src/civetweb/cmake/AddCXXCompilerFlag.cmake
new file mode 100644
index 000000000..5e58c6de4
--- /dev/null
+++ b/src/civetweb/cmake/AddCXXCompilerFlag.cmake
@@ -0,0 +1,38 @@
+# - Adds a compiler flag if it is supported by the compiler
+#
+# This function checks that the supplied compiler flag is supported and then
+# adds it to the corresponding compiler flags
+#
+# add_cxx_compiler_flag(<FLAG> [<VARIANT>])
+#
+# - Example
+#
+# include(AddCXXCompilerFlag)
+# add_cxx_compiler_flag(-Wall)
+# add_cxx_compiler_flag(-no-strict-aliasing RELEASE)
+# Requires CMake 2.6+
+
+if(__add_cxx_compiler_flag)
+ return()
+endif()
+set(__add_cxx_compiler_flag INCLUDED)
+
+include(CheckCXXCompilerFlag)
+
+function(add_cxx_compiler_flag FLAG)
+ string(TOUPPER "HAVE_CXX_FLAG_${FLAG}" SANITIZED_FLAG)
+ string(REPLACE "+" "X" SANITIZED_FLAG ${SANITIZED_FLAG})
+ string(REGEX REPLACE "[^A-Za-z_0-9]" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
+ string(REGEX REPLACE "_+" "_" SANITIZED_FLAG ${SANITIZED_FLAG})
+ set(CMAKE_REQUIRED_FLAGS "${FLAG}")
+ check_cxx_compiler_flag("" ${SANITIZED_FLAG})
+ if(${SANITIZED_FLAG})
+ set(VARIANT ${ARGV1})
+ if(ARGV1)
+ string(REGEX REPLACE "[^A-Za-z_0-9]" "_" VARIANT "${VARIANT}")
+ string(TOUPPER "_${VARIANT}" VARIANT)
+ endif()
+ set(CMAKE_CXX_FLAGS${VARIANT} "${CMAKE_CXX_FLAGS${VARIANT}} ${FLAG}" PARENT_SCOPE)
+ endif()
+endfunction()
+
diff --git a/src/civetweb/cmake/DetermineTargetArchitecture.cmake b/src/civetweb/cmake/DetermineTargetArchitecture.cmake
new file mode 100644
index 000000000..7d18213f7
--- /dev/null
+++ b/src/civetweb/cmake/DetermineTargetArchitecture.cmake
@@ -0,0 +1,47 @@
+# - Determines the target architecture of the compilation
+#
+# This function checks the architecture that will be built by the compiler
+# and sets a variable to the architecture
+#
+# determine_target_architecture(<OUTPUT_VAR>)
+#
+# - Example
+#
+# include(DetermineTargetArchitecture)
+# determine_target_architecture(PROJECT_NAME_ARCHITECTURE)
+
+if(__determine_target_architecture)
+ return()
+endif()
+set(__determine_target_architecture INCLUDED)
+
+function(determine_target_architecture FLAG)
+ if (MSVC)
+ if("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "X86")
+ set(ARCH "i686")
+ elseif("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "x64")
+ set(ARCH "x86_64")
+ elseif("${MSVC_C_ARCHITECTURE_ID}" STREQUAL "ARM")
+ set(ARCH "arm")
+ else()
+ message(FATAL_ERROR "Failed to determine the MSVC target architecture: ${MSVC_C_ARCHITECTURE_ID}")
+ endif()
+ else()
+ execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -dumpmachine
+ RESULT_VARIABLE RESULT
+ OUTPUT_VARIABLE ARCH
+ ERROR_QUIET
+ )
+ if (RESULT)
+ message(FATAL_ERROR "Failed to determine target architecture triplet: ${RESULT}")
+ endif()
+ string(REGEX MATCH "([^-]+).*" ARCH_MATCH ${ARCH})
+ if (NOT CMAKE_MATCH_1 OR NOT ARCH_MATCH)
+ message(FATAL_ERROR "Failed to match the target architecture triplet: ${ARCH}")
+ endif()
+ set(ARCH ${CMAKE_MATCH_1})
+ endif()
+ message(STATUS "Target architecture - ${ARCH}")
+ set(FLAG ${ARCH} PARENT_SCOPE)
+endfunction()
diff --git a/src/civetweb/cmake/FindLibDl.cmake b/src/civetweb/cmake/FindLibDl.cmake
new file mode 100644
index 000000000..c018d9239
--- /dev/null
+++ b/src/civetweb/cmake/FindLibDl.cmake
@@ -0,0 +1,46 @@
+#.rst:
+# FindLibDl
+# --------
+#
+# Find the native realtime includes and library.
+#
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines :prop_tgt:`IMPORTED` target ``LIBDL::LIBDL``, if
+# LIBDL has been found.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the following variables:
+#
+# ::
+#
+# LIBDL_INCLUDE_DIRS - where to find dlfcn.h, etc.
+# LIBDL_LIBRARIES - List of libraries when using libdl.
+# LIBDL_FOUND - True if dynamic linking library found.
+#
+# Hints
+# ^^^^^
+#
+# A user may set ``LIBDL_ROOT`` to a library installation root to tell this
+# module where to look.
+
+find_path(LIBDL_INCLUDE_DIRS
+ NAMES dlfcn.h
+ PATHS ${LIBDL_ROOT}/include/
+)
+find_library(LIBDL_LIBRARIES dl)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LibDl DEFAULT_MSG LIBDL_LIBRARIES LIBDL_INCLUDE_DIRS)
+mark_as_advanced(LIBDL_INCLUDE_DIRS LIBDL_LIBRARIES)
+
+if(LIBDL_FOUND)
+ if(NOT TARGET LIBDL::LIBDL)
+ add_library(LIBDL::LIBDL UNKNOWN IMPORTED)
+ set_target_properties(LIBDL::LIBDL PROPERTIES
+ IMPORTED_LOCATION "${LIBDL_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBDL_INCLUDE_DIRS}")
+ endif()
+endif()
diff --git a/src/civetweb/cmake/FindLibM.cmake b/src/civetweb/cmake/FindLibM.cmake
new file mode 100644
index 000000000..9f42aa493
--- /dev/null
+++ b/src/civetweb/cmake/FindLibM.cmake
@@ -0,0 +1,47 @@
+#.rst:
+# FindLibM
+# --------
+#
+# Find the native realtime includes and library.
+#
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines :prop_tgt:`IMPORTED` target ``LIBM::LIBM``, if
+# LIBM has been found.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the following variables:
+#
+# ::
+#
+# LIBM_INCLUDE_DIRS - where to find math.h, etc.
+# LIBM_LIBRARIES - List of libraries when using libm.
+# LIBM_FOUND - True if math library found.
+#
+# Hints
+# ^^^^^
+#
+# A user may set ``LIBM_ROOT`` to a math library installation root to tell this
+# module where to look.
+
+find_path(LIBM_INCLUDE_DIRS
+ NAMES math.h
+ PATHS /usr/include /usr/local/include /usr/local/bic/include
+ NO_DEFAULT_PATH
+)
+find_library(LIBM_LIBRARIES m)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LibM DEFAULT_MSG LIBM_LIBRARIES LIBM_INCLUDE_DIRS)
+mark_as_advanced(LIBM_INCLUDE_DIRS LIBM_LIBRARIES)
+
+if(LIBM_FOUND)
+ if(NOT TARGET LIBM::LIBM)
+ add_library(LIBM::LIBM UNKNOWN IMPORTED)
+ set_target_properties(LIBM::LIBM PROPERTIES
+ IMPORTED_LOCATION "${LIBM_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBM_INCLUDE_DIRS}")
+ endif()
+endif()
diff --git a/src/civetweb/cmake/FindLibRt.cmake b/src/civetweb/cmake/FindLibRt.cmake
new file mode 100644
index 000000000..c496edf86
--- /dev/null
+++ b/src/civetweb/cmake/FindLibRt.cmake
@@ -0,0 +1,46 @@
+#.rst:
+# FindLibRt
+# --------
+#
+# Find the native realtime includes and library.
+#
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines :prop_tgt:`IMPORTED` target ``LIBRT::LIBRT``, if
+# LIBRT has been found.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the following variables:
+#
+# ::
+#
+# LIBRT_INCLUDE_DIRS - where to find time.h, etc.
+# LIBRT_LIBRARIES - List of libraries when using librt.
+# LIBRT_FOUND - True if realtime library found.
+#
+# Hints
+# ^^^^^
+#
+# A user may set ``LIBRT_ROOT`` to a realtime installation root to tell this
+# module where to look.
+
+find_path(LIBRT_INCLUDE_DIRS
+ NAMES time.h
+ PATHS ${LIBRT_ROOT}/include/
+)
+find_library(LIBRT_LIBRARIES rt)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LibRt DEFAULT_MSG LIBRT_LIBRARIES LIBRT_INCLUDE_DIRS)
+mark_as_advanced(LIBRT_INCLUDE_DIRS LIBRT_LIBRARIES)
+
+if(LIBRT_FOUND)
+ if(NOT TARGET LIBRT::LIBRT)
+ add_library(LIBRT::LIBRT UNKNOWN IMPORTED)
+ set_target_properties(LIBRT::LIBRT PROPERTIES
+ IMPORTED_LOCATION "${LIBRT_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBRT_INCLUDE_DIRS}")
+ endif()
+endif()
diff --git a/src/civetweb/cmake/FindLibSubunit.cmake b/src/civetweb/cmake/FindLibSubunit.cmake
new file mode 100644
index 000000000..b45344fbe
--- /dev/null
+++ b/src/civetweb/cmake/FindLibSubunit.cmake
@@ -0,0 +1,46 @@
+#.rst:
+# FindLibSubunit
+# --------
+#
+# Find the native realtime includes and library.
+#
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines :prop_tgt:`IMPORTED` target ``LIBSUBUNIT::LIBSUBUNIT``, if
+# LIBSUBUNIT has been found.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the following variables:
+#
+# ::
+#
+# LIBSUBUNIT_INCLUDE_DIRS - where to find subunit/child.h
+# LIBSUBUNIT_LIBRARIES - List of libraries when using libsubunit.
+# LIBSUBUNIT_FOUND - True if subunit library found.
+#
+# Hints
+# ^^^^^
+#
+# A user may set ``LIBSUBUNIT_ROOT`` to a subunit library installation root to tell this
+# module where to look.
+
+find_path(LIBSUBUNIT_INCLUDE_DIRS
+ NAMES subunit/child.h
+ PATHS ${LIBSUBUNIT_ROOT}/include/
+)
+find_library(LIBSUBUNIT_LIBRARIES subunit)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LibSubunit DEFAULT_MSG LIBSUBUNIT_LIBRARIES LIBSUBUNIT_INCLUDE_DIRS)
+mark_as_advanced(LIBSUBUNIT_INCLUDE_DIRS LIBSUBUNIT_LIBRARIES)
+
+if(LIBSUBUNIT_FOUND)
+ if(NOT TARGET LIBSUBUNIT::LIBSUBUNIT)
+ add_library(LIBSUBUNIT::LIBSUBUNIT UNKNOWN IMPORTED)
+ set_target_properties(LIBSUBUNIT::LIBSUBUNIT PROPERTIES
+ IMPORTED_LOCATION "${LIBSUBUNIT_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBSUBUNIT_INCLUDE_DIRS}")
+ endif()
+endif()
diff --git a/src/civetweb/cmake/FindWinSock.cmake b/src/civetweb/cmake/FindWinSock.cmake
new file mode 100644
index 000000000..0bf355dec
--- /dev/null
+++ b/src/civetweb/cmake/FindWinSock.cmake
@@ -0,0 +1,102 @@
+#.rst:
+# FindWinSock
+# --------
+#
+# Find the native realtime includes and library.
+#
+# IMPORTED Targets
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines :prop_tgt:`IMPORTED` target ``WINSOCK::WINSOCK``, if
+# WINSOCK has been found.
+#
+# Result Variables
+# ^^^^^^^^^^^^^^^^
+#
+# This module defines the following variables:
+#
+# ::
+#
+# WINSOCK_INCLUDE_DIRS - where to find winsock.h, etc.
+# WINSOCK_LIBRARIES - List of libraries when using librt.
+# WINSOCK_FOUND - True if realtime library found.
+#
+# Hints
+# ^^^^^
+#
+# A user may set ``WINSOCK_ROOT`` to a realtime installation root to tell this
+# module where to look.
+
+macro(REMOVE_DUPLICATE_PATHS LIST_VAR)
+ set(WINSOCK_LIST "")
+ foreach(PATH IN LISTS ${LIST_VAR})
+ get_filename_component(PATH "${PATH}" REALPATH)
+ list(APPEND WINSOCK_LIST "${PATH}")
+ endforeach(PATH)
+ set(${LIST_VAR} ${WINSOCK_LIST})
+ list(REMOVE_DUPLICATES ${LIST_VAR})
+endmacro(REMOVE_DUPLICATE_PATHS)
+
+set(WINSOCK_INCLUDE_PATHS "${WINSOCK_ROOT}/include/")
+if(MINGW)
+ execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -xc -E -v -
+ RESULT_VARIABLE RESULT
+ INPUT_FILE nul
+ ERROR_VARIABLE ERR
+ OUTPUT_QUIET
+ )
+ if (NOT RESULT)
+ string(FIND "${ERR}" "#include <...> search starts here:" START)
+ string(FIND "${ERR}" "End of search list." END)
+ if (NOT ${START} EQUAL -1 AND NOT ${END} EQUAL -1)
+ math(EXPR START "${START} + 36")
+ math(EXPR END "${END} - 1")
+ math(EXPR LENGTH "${END} - ${START}")
+ string(SUBSTRING "${ERR}" ${START} ${LENGTH} WINSOCK_INCLUDE_PATHS)
+ string(REPLACE "\n " ";" WINSOCK_INCLUDE_PATHS "${WINSOCK_INCLUDE_PATHS}")
+ list(REVERSE WINSOCK_INCLUDE_PATHS)
+ endif()
+ endif()
+endif()
+remove_duplicate_paths(WINSOCK_INCLUDE_PATHS)
+
+set(WINSOCK_LIBRARY_PATHS "${WINSOCK_ROOT}/lib/")
+if(MINGW)
+ execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -print-search-dirs
+ RESULT_VARIABLE RESULT
+ OUTPUT_VARIABLE OUT
+ ERROR_QUIET
+ )
+ if (NOT RESULT)
+ string(REGEX MATCH "libraries: =([^\r\n]*)" OUT "${OUT}")
+ list(APPEND WINSOCK_LIBRARY_PATHS "${CMAKE_MATCH_1}")
+ endif()
+endif()
+if (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "AMD64" AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4)
+ list(APPEND WINSOCK_LIBRARY_PATHS "C:/Windows/SysWOW64")
+endif()
+list(APPEND WINSOCK_LIBRARY_PATHS "C:/Windows/System32")
+remove_duplicate_paths(WINSOCK_LIBRARY_PATHS)
+
+find_path(WINSOCK_INCLUDE_DIRS
+ NAMES winsock2.h
+ PATHS ${WINSOCK_INCLUDE_PATHS}
+)
+find_library(WINSOCK_LIBRARIES ws2_32
+ PATHS ${WINSOCK_LIBRARY_PATHS}
+ NO_DEFAULT_PATH
+)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(WinSock DEFAULT_MSG WINSOCK_LIBRARIES WINSOCK_INCLUDE_DIRS)
+mark_as_advanced(WINSOCK_INCLUDE_DIRS WINSOCK_LIBRARIES)
+
+if(WINSOCK_FOUND)
+ if(NOT TARGET WINSOCK::WINSOCK)
+ add_library(WINSOCK::WINSOCK UNKNOWN IMPORTED)
+ set_target_properties(WINSOCK::WINSOCK PROPERTIES
+ IMPORTED_LOCATION "${WINSOCK_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${WINSOCK_INCLUDE_DIRS}")
+ endif()
+endif()
diff --git a/src/civetweb/cmake/check/c82fe8888aacfe784476112edd3878256d2e30bc.patch b/src/civetweb/cmake/check/c82fe8888aacfe784476112edd3878256d2e30bc.patch
new file mode 100644
index 000000000..e16ea1f5f
--- /dev/null
+++ b/src/civetweb/cmake/check/c82fe8888aacfe784476112edd3878256d2e30bc.patch
@@ -0,0 +1,31 @@
+From c82fe8888aacfe784476112edd3878256d2e30bc Mon Sep 17 00:00:00 2001
+From: Joshua Boyd <jdboyd@Joshua-Boyds-Mac-mini.local>
+Date: Wed, 23 Mar 2016 17:54:41 -0400
+Subject: [PATCH] Detect missing itimerspec on OSX.
+
+Set define to compiler accordingly.
+
+This fixes cmake on osx support.
+---
+ CMakeLists.txt | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e271e31..1d413e8 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -193,6 +193,14 @@ if(NOT HAVE_SYS_TIME_H)
+ endif(MSVC)
+ endif(NOT HAVE_SYS_TIME_H)
+
++# OSX has sys/time.h, but it still lacks itimerspec
++if(HAVE_SYS_TIME_H)
++ check_struct_member("struct itimerspec" it_value "sys/time.h" HAVE_STRUCT_ITIMERSPEC_IT_VALUE)
++ if(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE)
++ add_definitions(-DSTRUCT_ITIMERSPEC_DEFINITION_MISSING=1)
++ set(STRUCT_ITIMERSPEC_DEFINITION_MISSING 1)
++ endif(NOT HAVE_STRUCT_ITIMERSPEC_IT_VALUE)
++endif(HAVE_SYS_TIME_H)
+
+ ###############################################################################
+ # Check for integer types
diff --git a/src/civetweb/cmake/check/patch.cmake b/src/civetweb/cmake/check/patch.cmake
new file mode 100644
index 000000000..472d392b5
--- /dev/null
+++ b/src/civetweb/cmake/check/patch.cmake
@@ -0,0 +1,12 @@
+message(STATUS "Patching check ${VERSION} ${SOURCE_DIR}")
+
+# Patch checks for MinGW
+# https://sourceforge.net/p/check/patches/53/
+set(CMAKE_LISTS_LOCATION "${SOURCE_DIR}/CMakeLists.txt")
+file(READ ${CMAKE_LISTS_LOCATION} CMAKE_LISTS)
+string(REGEX REPLACE
+ "(check_type_size\\((clock|clockid|timer)_t [A-Z_]+\\)[\r\n]+[^\r\n]+[\r\n]+[^\r\n]+[\r\n]+endif\\(NOT HAVE[A-Z_]+\\))"
+ "set(CMAKE_EXTRA_INCLUDE_FILES time.h)\n\\1\nunset(CMAKE_EXTRA_INCLUDE_FILES)"
+ CMAKE_LISTS "${CMAKE_LISTS}")
+file(WRITE ${CMAKE_LISTS_LOCATION} "${CMAKE_LISTS}")
+message(STATUS "Patched ${CMAKE_LISTS_LOCATION}")