Skip to content

Commit

Permalink
quickfast: migrate to Conan v2
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Nov 3, 2023
1 parent f0753c9 commit 3813208
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 82 deletions.
41 changes: 17 additions & 24 deletions recipes/quickfast/all/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@
cmake_minimum_required(VERSION 3.13)
project(quickfast CXX)

include(${PROJECT_BINARY_DIR}/../conanbuildinfo.cmake)
conan_basic_setup()
find_package(Boost REQUIRED CONFIG)
find_package(XercesC REQUIRED CONFIG)

file(GLOB SOURCES
source_subfolder/src/Application/*.cpp
source_subfolder/src/Common/*.cpp
source_subfolder/src/Codecs/*.cpp
source_subfolder/src/Communication/*.cpp
source_subfolder/src/Messages/*.cpp
src/src/Application/*.cpp
src/src/Common/*.cpp
src/src/Codecs/*.cpp
src/src/Communication/*.cpp
src/src/Messages/*.cpp
)

file(GLOB HEADERS RELATIVE ${PROJECT_SOURCE_DIR}
source_subfolder/src/Application/*.h
source_subfolder/src/Common/*.h
source_subfolder/src/Codecs/*.h
source_subfolder/src/Communication/*.h
source_subfolder/src/Messages/*.h
src/src/Application/*.h
src/src/Common/*.h
src/src/Codecs/*.h
src/src/Communication/*.h
src/src/Messages/*.h
)

add_library(quickfast ${HEADERS} ${SOURCES})
Expand All @@ -55,21 +55,14 @@ else()
endif()

target_compile_features(quickfast PUBLIC cxx_std_11)
target_include_directories(quickfast PUBLIC src/src)
target_link_libraries(${PROJECT_NAME} Boost::boost XercesC::XercesC)

target_include_directories(quickfast PUBLIC
source_subfolder/src
)

target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})

install(TARGETS quickfast
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
include(GNUInstallDirs)
install(TARGETS quickfast)

foreach (HEADER ${HEADERS})
file(RELATIVE_PATH HEADER_REL ${PROJECT_SOURCE_DIR}/source_subfolder/src ${PROJECT_SOURCE_DIR}/${HEADER})
file(RELATIVE_PATH HEADER_REL ${PROJECT_SOURCE_DIR}/src/src ${PROJECT_SOURCE_DIR}/${HEADER})
get_filename_component(HEADER_DIR ${HEADER_REL} DIRECTORY)
install(FILES ${HEADER} DESTINATION include/quickfast/${HEADER_DIR})
endforeach()
2 changes: 0 additions & 2 deletions recipes/quickfast/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ sources:
patches:
"1.5":
- patch_file: "patches/00001-fix-boost-asio.patch"
base_path: "source_subfolder"
"cci.20170314":
- patch_file: "patches/00002-fix-boost-asio.patch"
base_path: "source_subfolder"
92 changes: 49 additions & 43 deletions recipes/quickfast/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,69 +1,75 @@
from conans import ConanFile, CMake, tools
import os
import shutil
import glob

from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, collect_libs, copy, export_conandata_patches, get

required_conan_version = ">=1.53.0"


class QuickfastConan(ConanFile):
name = "quickfast"
description = "QuickFAST is an Open Source native C++ implementation of the FAST Protocol"
license = "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://objectcomputing.com/"
description = "QuickFAST is an Open Source native C++ implementation of the FAST Protocol"
topics = ("conan", "QuickFAST", "FAST", "FIX", "Fix Adapted for STreaming", "Financial Information Exchange",
"libraries", "cpp")
settings = "os", "compiler", "build_type", "arch"
options = {"fPIC": [True, False],
"shared": [True, False]}
default_options = {"fPIC": True,
"shared": False}
requires = ["boost/1.75.0", "xerces-c/3.2.3"]
generators = "cmake"
exports_sources = "CMakeLists.txt", "patches/**"
_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def _configure_cmake(self):
if not self._cmake:
self._cmake = CMake(self)
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake
topics = ("conan", "QuickFAST", "FAST", "FIX", "Fix Adapted for STreaming", "Financial Information Exchange", "libraries", "cpp")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = glob.glob("quickfast-*")[0]
os.rename(extracted_dir, self._source_subfolder)
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

def export_sources(self):
copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder)
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("boost/1.83.0")
self.requires("xerces-c/3.2.4")

def validate(self):
if self.settings.compiler.cppstd:
tools.check_min_cppstd(self, "11")
check_min_cppstd(self, 11)

def build(self):
patches = self.conan_data["patches"][self.version]
for patch in patches:
tools.patch(**patch)
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.generate()
tc = CMakeDeps(self)
tc.generate()

cmake = self._configure_cmake()
def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure(build_script_folder=self.export_sources_folder)
cmake.build(target="quickfast")

def package(self):
cmake = self._configure_cmake()
cmake = CMake(self)
cmake.install()
self.copy("license.txt", dst="licenses", src=self._source_subfolder)
copy(self, "license.txt",
dst=os.path.join(self.package_folder, "licenses"),
src=self.source_folder)

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libs = collect_libs(self)
self.cpp_info.includedirs.append(os.path.join("include", "quickfast"))

if not self.options.shared:
Expand Down
9 changes: 3 additions & 6 deletions recipes/quickfast/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.15)
project(PackageTest CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(quickfast REQUIRED CONFIG)

add_executable(test ${PROJECT_SOURCE_DIR}/main.cpp)

target_link_libraries(test ${CONAN_LIBS})

target_link_libraries(test PRIVATE quickfast::quickfast)
set_property(TARGET test PROPERTY CXX_STANDARD 11)
22 changes: 15 additions & 7 deletions recipes/quickfast/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

class QuickfastTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test")
self.run(bin_path, env="conanrun")
8 changes: 8 additions & 0 deletions recipes/quickfast/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
18 changes: 18 additions & 0 deletions recipes/quickfast/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import os

from conans import ConanFile, CMake, tools


class QuickfastTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test")
self.run(bin_path, run_environment=True)

0 comments on commit 3813208

Please sign in to comment.