Переглянути джерело

#712 Add new package flag info

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Uilian Ries 6 роки тому
батько
коміт
3b6923b486
4 змінених файлів з 28 додано та 3 видалено
  1. 6 1
      CMakeLists.txt
  2. 2 0
      conan/test_package/CMakeLists.txt
  3. 1 0
      conan/test_package/conanfile.py
  4. 19 2
      conanfile.py

+ 6 - 1
CMakeLists.txt

@@ -384,7 +384,12 @@ if (CIVETWEB_ENABLE_CXX)
   add_cxx_compiler_flag(-pedantic-errors)
   add_cxx_compiler_flag(-fvisibility=hidden)
   add_cxx_compiler_flag(-fstack-protector-strong RELEASE)
-  add_cxx_compiler_flag(-flto RELEASE)
+
+  if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR \
+      "${BUILD_SHARED_LIBS}" STREQUAL "SHARED" OR \
+      ${CMAKE_CXX_COMPILER_VERSION} GREATER 5)
+    add_cxx_compiler_flag(-flto RELEASE)
+  endif()
   if (${CIVETWEB_ENABLE_ASAN})
   add_cxx_compiler_flag(-fsanitize=undefined DEBUG)
   add_cxx_compiler_flag(-fsanitize=address DEBUG)

+ 2 - 0
conan/test_package/CMakeLists.txt

@@ -1,6 +1,8 @@
 cmake_minimum_required(VERSION 2.8.11)
 project(test_package CXX)
 
+set(CMAKE_VERBOSE_MAKEFILE ON)
+
 include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
 conan_basic_setup()
 

+ 1 - 0
conan/test_package/conanfile.py

@@ -25,3 +25,4 @@ class TestPackageConan(ConanFile):
             response = requests.get("http://localhost:8080/example")
             assert response.ok
             process.kill()
+            print("Finish Conan test package - SUCCESS!")

+ 19 - 2
conanfile.py

@@ -19,6 +19,7 @@ class civetwebConan(ConanFile):
         "fPIC"              : [True, False],
         "enable_ssl"        : [True, False],
         "enable_websockets" : [True, False],
+        "enable_ipv6"       : [True, False],
         "enable_cxx"        : [True, False]
     }
     default_options = {
@@ -26,9 +27,9 @@ class civetwebConan(ConanFile):
         "fPIC"              : True,
         "enable_ssl"        : True,
         "enable_websockets" : True,
+        "enable_ipv6"       : True,
         "enable_cxx"        : True
     }
-    requires = "OpenSSL/1.0.2q@conan/stable"
 
     def config_options(self):
         if self.settings.os == 'Windows':
@@ -38,10 +39,16 @@ class civetwebConan(ConanFile):
         if not self.options.enable_cxx:
             del self.settings.compiler.libcxx
 
+    def requirements(self):
+        if self.options.enable_ssl:
+            self.requires("OpenSSL/1.0.2q@conan/stable")
+
     def _configure_cmake(self):
         cmake = CMake(self)
+        cmake.verbose = True
         cmake.definitions["CIVETWEB_ENABLE_SSL"] = self.options.enable_ssl
         cmake.definitions["CIVETWEB_ENABLE_WEBSOCKETS"] = self.options.enable_websockets
+        cmake.definitions["CIVETWEB_ENABLE_IPV6"] = self.options.enable_ipv6
         cmake.definitions["CIVETWEB_ENABLE_CXX"] = self.options.enable_cxx
         cmake.definitions["CIVETWEB_BUILD_TESTING"] = False
         cmake.definitions["CIVETWEB_ENABLE_ASAN"] = False
@@ -65,8 +72,18 @@ class civetwebConan(ConanFile):
     def package_info(self):
         self.cpp_info.libs = tools.collect_libs(self)
         if self.settings.os == "Linux":
-            self.cpp_info.libs.append("pthread")
+            self.cpp_info.libs.extend(["dl", "rt", "pthread"])
             if self.options.enable_cxx:
                 self.cpp_info.libs.append("m")
+        elif self.settings.os == "Macos":
+            self.cpp_info.exelinkflags.append("-framework Cocoa")
+            self.cpp_info.sharedlinkflags = self.cpp_info.exelinkflags
+            self.cpp_info.defines.append("USE_COCOA")
         elif self.settings.os == "Windows":
             self.cpp_info.libs.append("Ws2_32")
+        if self.options.enable_websockets:
+            self.cpp_info.defines.append("USE_WEBSOCKET")
+        if self.options.enable_ipv6:
+            self.cpp_info.defines.append("USE_IPV6")
+        if not self.options.enable_ssl:
+            self.cpp_info.defines.append("NO_SSL")