Skip to content

Commit

Permalink
Merge pull request #1 from uilianries/quickfix
Browse files Browse the repository at this point in the history
Simplify quickfix recipe
  • Loading branch information
tarc authored Jun 10, 2020
2 parents b70a923 + f8dd89c commit ea586cc
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 55 deletions.
10 changes: 6 additions & 4 deletions recipes/quickfix/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ sources:
patches:
"1.15.1":
- patch_file: "patches/0001-inc.-required-CMake-version-add-conan-basic-setup-an.patch"
base_path: "quickfix"
base_path: "source_subfolder"
- patch_file: "patches/0002-fix-condition-for-using-tr1-namespace.patch"
base_path: "quickfix"
base_path: "source_subfolder"
- patch_file: "patches/0003-remove-tests-from-compilatin-unit-performance-and-ac.patch"
base_path: "quickfix"
base_path: "source_subfolder"
- patch_file: "patches/0004-Fix-build-for-C-17-replace-throw-.-with-EXCEPT.patch"
base_path: "quickfix"
base_path: "source_subfolder"
- patch_file: "patches/0005-except-copy.patch"
base_path: "source_subfolder"
46 changes: 18 additions & 28 deletions recipes/quickfix/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from conans import ConanFile, CMake, tools
import shutil
import os
import re


class QuickfixConan(ConanFile):
Expand All @@ -16,25 +14,20 @@ class QuickfixConan(ConanFile):
"ssl": [True, False]}
default_options = {"ssl": False, "fPIC": True}
generators = "cmake"
file_pattern = re.compile(r'quickfix-(.*)')
exports_sources = "patches/**"
_cmake = None

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

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

def source(self):
tools.get(**self.conan_data["sources"][self.version])
files = os.listdir()
match_dirs = list(filter(self.file_pattern.search, files))
extracted_dir = match_dirs[0]
os.rename(extracted_dir, self._source_subfolder)

self._patch_sources()

os.makedirs(f"{self._source_subfolder}/include")
shutil.copyfile(f"{self._source_subfolder}/src/C++/Except.h",
f"{self._source_subfolder}/include/Except.h")
os.rename(self.name + "-" + self.version, self._source_subfolder)

def requirements(self):
if self.options.ssl:
Expand All @@ -44,15 +37,25 @@ def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def _configure_cmake(self):
if not self._cmake:
self._cmake = CMake(self)
self._cmake.definitions["HAVE_SSL"] = self.options.ssl
self._cmake.configure(source_folder=self._source_subfolder)
return self._cmake

def build(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)

cmake = self._configure_cmake()
cmake.build(target="quickfix")

def package(self):
cmake = self._configure_cmake()
cmake.install()
self.copy("config.h", dst="include", src=self._source_subfolder)
self.copy("Except.h", dst="include", src=f"{self._source_subfolder}/src/C++")
self.copy("Except.h", dst="include", src=os.path.join(self._source_subfolder, "src", "C++"))
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
tools.rmdir(os.path.join(self.package_folder, "share"))

Expand All @@ -64,16 +67,3 @@ def package_info(self):

if self.settings.os == "Windows":
self.cpp_info.system_libs.extend(["ws2_32"])

def _configure_cmake(self):
cmake = CMake(self)

if self.options.ssl:
cmake.definitions["HAVE_SSL"] = "ON"

cmake.configure(source_folder=self._source_subfolder)
return cmake

def _patch_sources(self):
for patch in self.conan_data["patches"][self.version]:
tools.patch(**patch)
39 changes: 39 additions & 0 deletions recipes/quickfix/all/patches/0005-except-copy.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/include/Except.h b/include/Except.h
new file mode 100644
index 0000000..fded28e
--- /dev/null
+++ b/include/Except.h
@@ -0,0 +1,33 @@
+/* -*- C++ -*- */
+
+/****************************************************************************
+** Copyright (c) 2001-2014
+**
+** This file is part of the QuickFIX FIX Engine
+**
+** This file may be distributed under the terms of the quickfixengine.org
+** license as defined by quickfixengine.org and appearing in the file
+** LICENSE included in the packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.quickfixengine.org/LICENSE for licensing information.
+**
+** Contact ask@quickfixengine.org if any conditions of this licensing are
+** not clear to you.
+**
+****************************************************************************/
+
+#ifndef FIX_EXCEPT_H
+#define FIX_EXCEPT_H
+
+#ifdef __cpp_noexcept_function_type
+#define NOEXCEPT noexcept
+#define EXCEPT(...) noexcept(false)
+#else
+#define NOEXCEPT throw()
+#define EXCEPT(...) throw(__VA_ARGS__)
+#endif
+
+#endif
9 changes: 1 addition & 8 deletions recipes/quickfix/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
cmake_minimum_required(VERSION 2.8.11)
project(PackageTest CXX)

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

add_executable(executor ${PROJECT_SOURCE_DIR}/executor.cpp)

target_link_libraries(executor ${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)
17 changes: 2 additions & 15 deletions recipes/quickfix/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,14 @@

class QuickfixTestConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
options = {"ssl": [True, False], "fPIC": [True, False]}
default_options = "ssl=False", "fPIC=True"
generators = "cmake"

def configure(self):
if self.settings.os == 'Windows':
del self.options.fPIC
else:
self.options["quickfix"].fPIC = self.options.fPIC

self.options["quickfix"].ssl = self.options.ssl

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

def test(self):
if not tools.cross_building(self):
program = "executor"

self.run(f".{os.sep}{program}", run_environment=True,
cwd=f"{self.build_folder}{os.sep}bin")
bin_path = os.path.join("bin", "executor")
self.run(bin_path, run_environment=True)

0 comments on commit ea586cc

Please sign in to comment.