2 Commits 827ee23ac1 ... e9cb767f6c

Autor SHA1 Mensaje Fecha
  DarkMorford e9cb767f6c Add compile/link test code hace 5 años
  DarkMorford fb17a2524e Declare library for downstream builds hace 5 años
Se han modificado 4 ficheros con 65 adiciones y 3 borrados
  1. 2 3
      conanfile.py
  2. 17 0
      test_package/CMakeLists.txt
  3. 24 0
      test_package/conanfile.py
  4. 22 0
      test_package/example.cpp

+ 2 - 3
conanfile.py

@@ -50,10 +50,9 @@ class LibOggConan(ConanFile):
         cmake.build()
 
     def package(self):
-        self.copy("COPYING", src=self.subfolder, dst="licenses",
-                  ignore_case=True, keep_path=False)
+        self.copy("COPYING", src=self.subfolder, dst="licenses", ignore_case=True, keep_path=False)
         cmake = self._configure_cmake()
         cmake.install()
 
     def package_info(self):
-        self.cpp_info.libs = ["hello"]
+        self.cpp_info.libs = ["ogg"]

+ 17 - 0
test_package/CMakeLists.txt

@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.1.2)
+project(PackageTest CXX)
+
+include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
+conan_basic_setup()
+
+if(${CMAKE_EXPORT_NO_PACKAGE_REGISTRY})
+endif()
+
+add_executable(example example.cpp)
+target_link_libraries(example ${CONAN_LIBS})
+
+# CTest is a testing tool that can be used to test your project.
+# enable_testing()
+# add_test(NAME example
+#          WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
+#          COMMAND example)

+ 24 - 0
test_package/conanfile.py

@@ -0,0 +1,24 @@
+from conans import ConanFile, CMake, tools
+import os
+
+
+class LibOggTestConan(ConanFile):
+    settings = "os", "compiler", "build_type", "arch"
+    generators = "cmake"
+
+    def build(self):
+        cmake = CMake(self)
+        # Current dir is "test_package/build/<build_id>" and CMakeLists.txt is
+        # in "test_package"
+        cmake.configure()
+        cmake.build()
+
+    def imports(self):
+        self.copy("*.dll", dst="bin", src="bin")
+        self.copy("*.dylib*", dst="bin", src="lib")
+        self.copy('*.so*', dst='bin', src='lib')
+
+    def test(self):
+        if not tools.cross_building(self.settings):
+            os.chdir("bin")
+            self.run(f".{os.sep}example")

+ 22 - 0
test_package/example.cpp

@@ -0,0 +1,22 @@
+#include <ogg/ogg.h>
+
+#define CONAN_OGGCHECK(x) if ((x) != 0) return x
+
+int main() {
+    int ogg_success;
+    ogg_stream_state stream;
+
+    ogg_success = ogg_stream_init(&stream, 1);
+    CONAN_OGGCHECK(ogg_success);
+
+    ogg_success = ogg_stream_check(&stream);
+    CONAN_OGGCHECK(ogg_success);
+
+    ogg_success = ogg_stream_reset(&stream);
+    CONAN_OGGCHECK(ogg_success);
+
+    ogg_success = ogg_stream_clear(&stream);
+    CONAN_OGGCHECK(ogg_success);
+
+    return 0;
+}