ソースを参照

Build library with CMake

DarkMorford 5 年 前
コミット
c3e49bd69f
2 ファイル変更19 行追加7 行削除
  1. 11 0
      CMakeLists.txt
  2. 8 7
      conanfile.py

+ 11 - 0
CMakeLists.txt

@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 3.1.2)
+project(conan_cmake_wrapper)
+
+message(STATUS "Conan.io CMake Wrapper")
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+if(${CMAKE_EXPORT_NO_PACKAGE_REGISTRY})
+endif()
+
+add_subdirectory(${CONAN_SOURCE_LOCATION})

+ 8 - 7
conanfile.py

@@ -13,6 +13,7 @@ class LibOggConan(ConanFile):
                    "free for anyone to use.")
     homepage = "https://www.xiph.org/ogg/"
     topics = ("xiph.org", "media", "container")
+    exports_sources = ["CMakeLists.txt"]
     settings = "os", "compiler", "build_type", "arch"
     options = {"shared": [True, False]}
     default_options = {"shared": False}
@@ -29,15 +30,15 @@ class LibOggConan(ConanFile):
         del self.settings.compiler.cppstd
         del self.settings.compiler.libcxx
 
-    def build(self):
+    def _configure_cmake(self):
         cmake = CMake(self)
-        cmake.configure(source_folder="hello")
-        cmake.build()
+        cmake.definitions["CONAN_SOURCE_LOCATION"] = self.subfolder
+        cmake.configure()
+        return cmake
 
-        # Explicit way:
-        # self.run('cmake %s/hello %s'
-        #          % (self.source_folder, cmake.command_line))
-        # self.run("cmake --build . %s" % cmake.build_config)
+    def build(self):
+        cmake = self._configure_cmake()
+        cmake.build()
 
     def package(self):
         self.copy("*.h", dst="include", src="hello")