Created
June 4, 2019 11:57
-
-
Save uilianries/485a08f0bcc301ae8382d99c8dda4290 to your computer and use it in GitHub Desktop.
Conan + CMake + Zlib
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
mkdir -p build | |
pushd build | |
conan install .. | |
cmake -DCMAKE_BUILD_TYPE=Release .. | |
cmake --build . | |
bin/hello | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 2.8) | |
project(hello CXX) | |
set(CMAKE_VERBOSE_MAKEFILE ON) | |
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) | |
conan_basic_setup() | |
add_executable(${CMAKE_PROJECT_NAME} hello.cpp) | |
target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[requires] | |
zlib/1.2.11@conan/stable | |
[generators] | |
cmake |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <cstring> | |
#include <iostream> | |
#include <zlib.h> | |
int main() { | |
char buffer_in [32] = {"Conan Package Manager"}; | |
char buffer_out [32] = {0}; | |
z_stream defstream; | |
defstream.zalloc = Z_NULL; | |
defstream.zfree = Z_NULL; | |
defstream.opaque = Z_NULL; | |
defstream.avail_in = (uInt) strlen(buffer_in); | |
defstream.next_in = (Bytef *) buffer_in; | |
defstream.avail_out = (uInt) sizeof(buffer_out); | |
defstream.next_out = (Bytef *) buffer_out; | |
deflateInit(&defstream, Z_BEST_COMPRESSION); | |
deflate(&defstream, Z_FINISH); | |
deflateEnd(&defstream); | |
std::cout << "Compressed size is: " << strlen(buffer_in) << std::endl; | |
std::cout << "Compressed string is: " << buffer_in << std::endl; | |
std::cout << "Compressed size is: " << strlen(buffer_out) << std::endl; | |
std::cout << "Compressed string is: " << buffer_out << std::endl; | |
std::cout << "ZLIB VERSION: " << zlibVersion() << std::endl; | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment