From 419d327b12750987b34d2b93143767318a7d799f Mon Sep 17 00:00:00 2001 From: Anatoly Kalin Date: Mon, 7 Apr 2025 19:26:49 +0300 Subject: [PATCH 01/12] Refactor utilities and add GCC warning suppressions Converted lambdas to `inline` where applicable for better optimization. Added macros to suppress specific GCC warnings across multiple files to ensure cleaner builds. Minor improvements in code organization and header inclusions. --- .../dxfeed_graal_cpp_api/internal/Conf.hpp | 2 ++ .../internal/JavaObjectHandle.hpp | 1 + .../internal/PrecompiledHeaders.hpp | 3 +++ src/internal/utils/CmdArgsUtils.cpp | 21 +++++++++-------- src/internal/utils/EnumUtils.cpp | 7 ++++-- src/internal/utils/StringUtils.cpp | 23 ++++++------------- 6 files changed, 30 insertions(+), 27 deletions(-) diff --git a/include/dxfeed_graal_cpp_api/internal/Conf.hpp b/include/dxfeed_graal_cpp_api/internal/Conf.hpp index 82758b86..bfe83e65 100644 --- a/include/dxfeed_graal_cpp_api/internal/Conf.hpp +++ b/include/dxfeed_graal_cpp_api/internal/Conf.hpp @@ -30,11 +30,13 @@ # ifndef DXFCXX_DISABLE_GCC_WARNINGS_PUSH # define DXFCXX_DISABLE_GCC_WARNINGS_PUSH(...) \ DXFCXX_DO_PRAGMA(GCC diagnostic push) DXFCXX_DO_PRAGMA(GCC diagnostic ignored __VA_ARGS__) +# define DXFCXX_DISABLE_GCC_WARNINGS(...) DXFCXX_DO_PRAGMA(GCC diagnostic ignored __VA_ARGS__) # define DXFCXX_DISABLE_GCC_WARNINGS_POP() DXFCXX_DO_PRAGMA(GCC diagnostic pop) # endif #else # ifndef DXFCXX_DISABLE_GCC_WARNINGS_PUSH # define DXFCXX_DISABLE_GCC_WARNINGS_PUSH(warnings) +# define DXFCXX_DISABLE_GCC_WARNINGS(warnings) # define DXFCXX_DISABLE_GCC_WARNINGS_POP() # endif #endif diff --git a/include/dxfeed_graal_cpp_api/internal/JavaObjectHandle.hpp b/include/dxfeed_graal_cpp_api/internal/JavaObjectHandle.hpp index ff836148..ba0aae2f 100644 --- a/include/dxfeed_graal_cpp_api/internal/JavaObjectHandle.hpp +++ b/include/dxfeed_graal_cpp_api/internal/JavaObjectHandle.hpp @@ -8,6 +8,7 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) #include "utils/StringUtils.hpp" +#include "utils/debug/Debug.hpp" #include #include diff --git a/include/dxfeed_graal_cpp_api/internal/PrecompiledHeaders.hpp b/include/dxfeed_graal_cpp_api/internal/PrecompiledHeaders.hpp index 14f127ee..48a99d2e 100644 --- a/include/dxfeed_graal_cpp_api/internal/PrecompiledHeaders.hpp +++ b/include/dxfeed_graal_cpp_api/internal/PrecompiledHeaders.hpp @@ -43,9 +43,12 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251 4996) #include +DXFCXX_DISABLE_GCC_WARNINGS_PUSH("-Wunused-variable") +DXFCXX_DISABLE_GCC_WARNINGS("-Wmaybe-uninitialized") DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4702) #include DXFCXX_DISABLE_MSC_WARNINGS_POP() +DXFCXX_DISABLE_GCC_WARNINGS_POP() #include "Common.hpp" #include "Handler.hpp" diff --git a/src/internal/utils/CmdArgsUtils.cpp b/src/internal/utils/CmdArgsUtils.cpp index bde706b9..fa0710dd 100644 --- a/src/internal/utils/CmdArgsUtils.cpp +++ b/src/internal/utils/CmdArgsUtils.cpp @@ -26,6 +26,8 @@ DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4996) #include #include +DXFCXX_DISABLE_GCC_WARNINGS_PUSH("-Wunused-variable") +DXFCXX_DISABLE_GCC_WARNINGS("-Wmaybe-uninitialized") DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4702) #include DXFCXX_DISABLE_MSC_WARNINGS_POP() @@ -36,8 +38,8 @@ DXFCXX_DISABLE_MSC_WARNINGS_POP() DXFCPP_BEGIN_NAMESPACE -auto getUtcOffset() { - const std::time_t epochPlus11H = 60 * 60 * 11; +inline auto getUtcOffset() { + constexpr std::time_t epochPlus11H = 60 * 60 * 11; const int localTime = localtime(&epochPlus11H)->tm_hour * 60 + localtime(&epochPlus11H)->tm_min; const int gmTime = gmtime(&epochPlus11H)->tm_hour * 60 + gmtime(&epochPlus11H)->tm_min; const int tzDiff = localTime - gmTime; @@ -45,15 +47,15 @@ auto getUtcOffset() { return tzDiff * 60 * 1000; } -decltype(ranges::views::filter([](const auto &s) { +inline auto filterNonEmpty = ranges::views::filter([](const auto &s) { return !s.empty(); -})) filterNonEmpty{}; +}); -decltype(ranges::views::transform([](auto &&s) { +inline auto transformToString = ranges::views::transform([](auto &&s) { return s | ranges::to(); -})) transformToString{}; +}); -auto splitAndTrim = [](auto &&symbols, char sep = ',') noexcept { +inline auto splitAndTrim = [](auto &&symbols, char sep = ',') noexcept { decltype(ranges::views::transform([](const std::string &s) { return trimStr(s); })) trim{}; @@ -61,7 +63,7 @@ auto splitAndTrim = [](auto &&symbols, char sep = ',') noexcept { return symbols | ranges::views::split(sep) | filterNonEmpty | transformToString | trim; }; -auto toUpper = [](auto &&s) { +inline auto toUpper = [](auto &&s) { auto locale = std::locale{}; return s | ranges::views::transform([&locale](auto c) { @@ -270,4 +272,5 @@ std::unordered_set CmdArgsUtils::parseEventSources(const std DXFCPP_END_NAMESPACE -DXFCXX_DISABLE_MSC_WARNINGS_POP() \ No newline at end of file +DXFCXX_DISABLE_MSC_WARNINGS_POP() +DXFCXX_DISABLE_GCC_WARNINGS_POP() \ No newline at end of file diff --git a/src/internal/utils/EnumUtils.cpp b/src/internal/utils/EnumUtils.cpp index f9ba912c..c11616d9 100644 --- a/src/internal/utils/EnumUtils.cpp +++ b/src/internal/utils/EnumUtils.cpp @@ -18,9 +18,10 @@ #include #include +DXFCXX_DISABLE_GCC_WARNINGS_PUSH("-Wunused-variable") +DXFCXX_DISABLE_GCC_WARNINGS("-Wmaybe-uninitialized") DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4702) #include -DXFCXX_DISABLE_MSC_WARNINGS_POP() using namespace std::literals; @@ -53,4 +54,6 @@ std::string getMarketEventTypeEnumClassNamesList(std::string separator) noexcept } // namespace enum_utils -DXFCPP_END_NAMESPACE \ No newline at end of file +DXFCPP_END_NAMESPACE +DXFCXX_DISABLE_MSC_WARNINGS_POP() +DXFCXX_DISABLE_GCC_WARNINGS_POP() \ No newline at end of file diff --git a/src/internal/utils/StringUtils.cpp b/src/internal/utils/StringUtils.cpp index 93f6ed83..de9bf14d 100644 --- a/src/internal/utils/StringUtils.cpp +++ b/src/internal/utils/StringUtils.cpp @@ -17,9 +17,10 @@ #include #include +DXFCXX_DISABLE_GCC_WARNINGS_PUSH("-Wunused-variable") +DXFCXX_DISABLE_GCC_WARNINGS("-Wmaybe-uninitialized") DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4702) #include -DXFCXX_DISABLE_MSC_WARNINGS_POP() DXFCPP_BEGIN_NAMESPACE @@ -221,21 +222,9 @@ std::string trimStr(const std::string &s) noexcept { ranges::views::drop_while(trimPredicate) | ranges::views::reverse | ranges::to(); }; -// inline decltype(ranges::views::filter([](const auto &s) { -// return !s.empty(); -// })) filterNonEmpty{}; - -inline decltype(ranges::views::transform([](auto &&s) { +inline auto transformToString = ranges::views::transform([](auto &&s) { return s | ranges::to(); -})) transformToString{}; - -// inline decltype(ranges::views::transform([](const std::string &s) { -// return trimStr(s); -// })) trim{}; - -// inline auto splitAndTrim = [](const std::string &s, char sep = ',') noexcept { -// return s | ranges::views::split(sep) | transformToString | trim; -// }; +}); inline auto split = [](const std::string &s, char sep = ',') noexcept { return s | ranges::views::split(sep) | transformToString; @@ -253,4 +242,6 @@ bool toBool(const std::string &s) noexcept { return iEquals(s, "true") || iEquals(s, "yes") || iEquals(s, "y") || iEquals(s, "on"); } -DXFCPP_END_NAMESPACE \ No newline at end of file +DXFCPP_END_NAMESPACE +DXFCXX_DISABLE_MSC_WARNINGS_POP() +DXFCXX_DISABLE_GCC_WARNINGS_POP() \ No newline at end of file From efe25a79b7df1fb45e830c018207beefec995bab Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Wed, 9 Apr 2025 17:36:33 +0300 Subject: [PATCH 02/12] =?UTF-8?q?[MDAPI-246][=D0=A1++]=20Build=20a=20proje?= =?UTF-8?q?ct=20with=20statically=20linked=20runtime=20libraries.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced `DXFCPP_EXPORT` annotations with comments in specific structs to control export behavior more flexibly. Added `DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS` option in CMake for dynamic linking of unit tests, enhancing configurability. --- CMakeLists.txt | 1 + include/dxfeed_graal_c_api/api.h | 109 +++++++++++------- .../dxfeed_graal_cpp_api/internal/Conf.hpp | 38 +++--- .../model/IndexedTxModel.hpp | 4 +- .../model/MarketDepthModel.hpp | 4 +- .../model/MarketDepthModelListener.hpp | 2 +- .../model/TimeSeriesTxModel.hpp | 4 +- .../model/TxModelListener.hpp | 4 +- tests/CMakeLists.txt | 18 ++- 9 files changed, 112 insertions(+), 72 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f47a677a..0defc06e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,6 +51,7 @@ if (NOT DEFINED DXFCXX_IS_ROOT_PROJECT) endif () option(DXFCXX_BUILD_UNIT_TESTS "Build tests" ${DXFCXX_IS_ROOT_PROJECT}) +option(DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS "Dynamically link unit tests" ON) option(DXFCXX_BUILD_SAMPLES "Build samples" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_BUILD_TOOLS "Build tools" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_BUILD_DOC "Build documentation" ${DXFCXX_IS_ROOT_PROJECT}) diff --git a/include/dxfeed_graal_c_api/api.h b/include/dxfeed_graal_c_api/api.h index 212dea5f..ebbdf025 100644 --- a/include/dxfeed_graal_c_api/api.h +++ b/include/dxfeed_graal_c_api/api.h @@ -16,6 +16,28 @@ extern "C" { #define DXFC_OUT +#ifndef DXFCPP_EXPORT +# if defined(DXFCPP_USE_DLLS) && defined(_MSC_VER) +# if defined(LIBDXFCPP_EXPORTS) +# define DXFCPP_EXPORT __declspec(dllexport) +# define DXFCPP_EXPORT_TEMPLATE_DECLARE +# define DXFCPP_EXPORT_TEMPLATE_DEFINE __declspec(dllexport) +# else +# define DXFCPP_EXPORT __declspec(dllimport) +# define DXFCPP_EXPORT_TEMPLATE_DECLARE +# define DXFCPP_EXPORT_TEMPLATE_DEFINE __declspec(dllimport) +# endif // defined(LIBDXFCPP_EXPORTS) +# elif defined(DXFCPP_USE_DLLS) && defined(LIBDXFCPP_EXPORTS) +# define DXFCPP_EXPORT __attribute__((visibility("default"))) +# define DXFCPP_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default"))) +# define DXFCPP_EXPORT_TEMPLATE_DEFINE +# else +# define DXFCPP_EXPORT +# define DXFCPP_EXPORT_TEMPLATE_DECLARE +# define DXFCPP_EXPORT_TEMPLATE_DEFINE +# endif +#endif + /** * @file * @brief dxFeed Native C API enums, structs and functions declarations @@ -45,7 +67,7 @@ typedef enum dxfc_error_code_t { * @param value The value of the system property (UTF-8 string). * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value); +DXFCPP_EXPORT dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value); /** * Gets the system property indicated by the specified key. @@ -59,7 +81,7 @@ dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value); * @param buffer_size The buffer's size. * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_system_get_property(const char *key, DXFC_OUT char *buffer, size_t buffer_size); +DXFCPP_EXPORT dxfc_error_code_t dxfc_system_get_property(const char *key, DXFC_OUT char *buffer, size_t buffer_size); /** * Represents the role of endpoint that was specified during its @ref dxfc_dxendpoint_create() "creation". @@ -201,7 +223,7 @@ typedef void *dxfc_dxpublisher_t; * @param[out] builder The created endpoint's builder. * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder); /** * Sets role for the created dxFeed endpoint. @@ -211,7 +233,8 @@ dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t * @param role The endpoint's role * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_builder_with_role(dxfc_dxendpoint_builder_t builder, dxfc_dxendpoint_role_t role); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_role(dxfc_dxendpoint_builder_t builder, + dxfc_dxendpoint_role_t role); /** * Changes name that is used to distinguish multiple endpoints @@ -221,7 +244,7 @@ dxfc_error_code_t dxfc_dxendpoint_builder_with_role(dxfc_dxendpoint_builder_t bu * @param name The endpoint's name * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t builder, const char *name); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t builder, const char *name); /** * Sets the specified property. Unsupported properties are ignored. @@ -231,8 +254,8 @@ dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t bu * @param value The endpoint's property value * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_builder_with_property(dxfc_dxendpoint_builder_t builder, const char *key, - const char *value); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_property(dxfc_dxendpoint_builder_t builder, + const char *key, const char *value); /** * Sets all supported properties from the provided properties object. @@ -242,8 +265,9 @@ dxfc_error_code_t dxfc_dxendpoint_builder_with_property(dxfc_dxendpoint_builder_ * @param size The size of the endpoint's properties * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_builder_with_properties(dxfc_dxendpoint_builder_t builder, - const dxfc_dxendpoint_property_t **properties, size_t size); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_properties(dxfc_dxendpoint_builder_t builder, + const dxfc_dxendpoint_property_t **properties, + size_t size); /** * Checks if a property is supported @@ -253,8 +277,8 @@ dxfc_error_code_t dxfc_dxendpoint_builder_with_properties(dxfc_dxendpoint_builde * @param[out] supports `1` if the corresponding property key is supported. * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_builder_supports_property(dxfc_dxendpoint_builder_t builder, const char *key, - DXFC_OUT int *supports); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_supports_property(dxfc_dxendpoint_builder_t builder, + const char *key, DXFC_OUT int *supports); /** * Builds the new dxFeed endpoint instance. @@ -264,8 +288,8 @@ dxfc_error_code_t dxfc_dxendpoint_builder_supports_property(dxfc_dxendpoint_buil * @param[out] endpoint The created endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builder, void *user_data, - DXFC_OUT dxfc_dxendpoint_t *endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builder, void *user_data, + DXFC_OUT dxfc_dxendpoint_t *endpoint); /** * Removes a builder from the registry. @@ -273,7 +297,7 @@ dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builde * @param builder The endpoint's builder * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder); /** * Returns a default application-wide singleton instance of dxFeed endpoint with a @ref DXFC_DXENDPOINT_ROLE_FEED "FEED" @@ -292,7 +316,7 @@ dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder * @param[out] endpoint The created endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint); /** * Returns a default application-wide singleton instance of DXEndpoint for a specific role. @@ -315,8 +339,8 @@ dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dx * @param[out] endpoint The created endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, void *user_data, - DXFC_OUT dxfc_dxendpoint_t *endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, void *user_data, + DXFC_OUT dxfc_dxendpoint_t *endpoint); /** * Creates an endpoint with @ref DXFC_DXENDPOINT_ROLE_FEED "FEED" role. @@ -334,7 +358,7 @@ dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, voi * @param[out] endpoint The created endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint); /** * Creates an endpoint with a specified role. @@ -353,8 +377,8 @@ dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoi * @param[out] endpoint The created endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *user_data, - DXFC_OUT dxfc_dxendpoint_t *endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *user_data, + DXFC_OUT dxfc_dxendpoint_t *endpoint); /** * Closes this endpoint. All network connection are terminated as with dxfc_dxendpoint_disconnect() function and no @@ -366,7 +390,7 @@ dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *use * @param endpoint The dxFeed endpoint to close * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint); /** * Closes this endpoint and wait until all pending data processing tasks are completed. @@ -380,7 +404,7 @@ dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint); * @param endpoint The dxFeed endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_close_and_await_termination(dxfc_dxendpoint_t endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close_and_await_termination(dxfc_dxendpoint_t endpoint); /** * Returns the role of this endpoint. @@ -389,18 +413,19 @@ dxfc_error_code_t dxfc_dxendpoint_close_and_await_termination(dxfc_dxendpoint_t * @param[out] role The role of this endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_get_role(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_role_t *role); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_role(dxfc_dxendpoint_t endpoint, + DXFC_OUT dxfc_dxendpoint_role_t *role); /** - * Changes user name for this endpoint. + * Changes username for this endpoint. * This function shall be called before @ref dxfc_dxendpoint_connect() "connect" together * with @ref dxfc_dxendpoint_password() "password" to configure service access credentials. * * @param endpoint The dxFeed endpoint - * @param user The user name + * @param user The username * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user); /** * Changes password for this endpoint. @@ -411,7 +436,7 @@ dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *u * @param password The user password * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password); /** * Connects to the specified remote address. Previously established connections are closed if @@ -442,7 +467,7 @@ dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const cha * @param address The data source address * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char *address); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char *address); /** * Terminates all established network connections and initiates connecting again with the same address. @@ -461,7 +486,7 @@ dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char * @param endpoint The dxFeed endpoint to reconnect * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_reconnect(dxfc_dxendpoint_t endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_reconnect(dxfc_dxendpoint_t endpoint); /** * Terminates all remote network connections. @@ -475,7 +500,7 @@ dxfc_error_code_t dxfc_dxendpoint_reconnect(dxfc_dxendpoint_t endpoint); * @param endpoint The dxFeed endpoint to disconnect * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint); /** * Terminates all remote network connections and clears stored data. @@ -489,7 +514,7 @@ dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint); * @param endpoint The dxFeed endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_disconnect_and_clear(dxfc_dxendpoint_t endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect_and_clear(dxfc_dxendpoint_t endpoint); /** * Waits until this endpoint stops processing data (becomes quiescent). @@ -499,7 +524,7 @@ dxfc_error_code_t dxfc_dxendpoint_disconnect_and_clear(dxfc_dxendpoint_t endpoin * @param endpoint The dxFeed endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_await_processed(dxfc_dxendpoint_t endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_processed(dxfc_dxendpoint_t endpoint); /** * Waits while this endpoint @ref dxfc_dxendpoint_get_state() "state" becomes @ref DXFC_DXENDPOINT_STATE_NOT_CONNECTED @@ -514,7 +539,7 @@ dxfc_error_code_t dxfc_dxendpoint_await_processed(dxfc_dxendpoint_t endpoint); * @param endpoint The dxFeed endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_await_not_connected(dxfc_dxendpoint_t endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_not_connected(dxfc_dxendpoint_t endpoint); /** * Returns the state of this endpoint. @@ -523,7 +548,8 @@ dxfc_error_code_t dxfc_dxendpoint_await_not_connected(dxfc_dxendpoint_t endpoint * @param[out] state The state of this endpoint * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_get_state(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_state_t *state); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_state(dxfc_dxendpoint_t endpoint, + DXFC_OUT dxfc_dxendpoint_state_t *state); /** * Adds listener that is notified about changes in @ref dxfc_dxendpoint_get_state() "state" property. @@ -534,8 +560,8 @@ dxfc_error_code_t dxfc_dxendpoint_get_state(dxfc_dxendpoint_t endpoint, DXFC_OUT * @param listener The listener to add * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, - dxfc_dxendpoint_state_change_listener listener); +DXFCPP_EXPORT dxfc_error_code_t +dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener); /** * Removes listener that is notified about changes in @ref dxfc_dxendpoint_get_state() "state" property. @@ -545,8 +571,8 @@ dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t en * @param listener The listener to remove * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_remove_state_change_listener(dxfc_dxendpoint_t endpoint, - dxfc_dxendpoint_state_change_listener listener); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_remove_state_change_listener( + dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener); /** * @@ -554,7 +580,7 @@ dxfc_error_code_t dxfc_dxendpoint_remove_state_change_listener(dxfc_dxendpoint_t * @param[out] feed * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed); /** * @@ -562,14 +588,15 @@ dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT * @param[out] publisher * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, + DXFC_OUT dxfc_dxpublisher_t *publisher); /** * Removes the dxFeed endpoint from the registry. * @param endpoint The dxFeed endpoint to remove * @return DXFC_EC_SUCCESS - if the operation was successful; otherwise - DXFC_EC_ERROR. */ -dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint); +DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint); #ifdef __cplusplus } diff --git a/include/dxfeed_graal_cpp_api/internal/Conf.hpp b/include/dxfeed_graal_cpp_api/internal/Conf.hpp index bfe83e65..0b65ff5e 100644 --- a/include/dxfeed_graal_cpp_api/internal/Conf.hpp +++ b/include/dxfeed_graal_cpp_api/internal/Conf.hpp @@ -41,28 +41,26 @@ # endif #endif -#ifdef DXFCPP_EXPORT -# error DXFCPP_EXPORT was previously defined -#endif - -#if defined(DXFCPP_USE_DLLS) && defined(_MSC_VER) -# if defined(LIBDXFCPP_EXPORTS) -# define DXFCPP_EXPORT __declspec(dllexport) -# define DXFCPP_EXPORT_TEMPLATE_DECLARE -# define DXFCPP_EXPORT_TEMPLATE_DEFINE __declspec(dllexport) +#ifndef DXFCPP_EXPORT +# if defined(DXFCPP_USE_DLLS) && defined(_MSC_VER) +# if defined(LIBDXFCPP_EXPORTS) +# define DXFCPP_EXPORT __declspec(dllexport) +# define DXFCPP_EXPORT_TEMPLATE_DECLARE +# define DXFCPP_EXPORT_TEMPLATE_DEFINE __declspec(dllexport) +# else +# define DXFCPP_EXPORT __declspec(dllimport) +# define DXFCPP_EXPORT_TEMPLATE_DECLARE +# define DXFCPP_EXPORT_TEMPLATE_DEFINE __declspec(dllimport) +# endif // defined(LIBDXFCPP_EXPORTS) +# elif defined(DXFCPP_USE_DLLS) && defined(LIBDXFCPP_EXPORTS) +# define DXFCPP_EXPORT __attribute__((visibility("default"))) +# define DXFCPP_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default"))) +# define DXFCPP_EXPORT_TEMPLATE_DEFINE # else -# define DXFCPP_EXPORT __declspec(dllimport) +# define DXFCPP_EXPORT # define DXFCPP_EXPORT_TEMPLATE_DECLARE -# define DXFCPP_EXPORT_TEMPLATE_DEFINE __declspec(dllimport) -# endif // defined(LIBDXFCPP_EXPORTS) -#elif defined(DXFCPP_USE_DLLS) && defined(LIBDXFCPP_EXPORTS) -# define DXFCPP_EXPORT __attribute__((visibility("default"))) -# define DXFCPP_EXPORT_TEMPLATE_DECLARE __attribute__((visibility("default"))) -# define DXFCPP_EXPORT_TEMPLATE_DEFINE -#else -# define DXFCPP_EXPORT -# define DXFCPP_EXPORT_TEMPLATE_DECLARE -# define DXFCPP_EXPORT_TEMPLATE_DEFINE +# define DXFCPP_EXPORT_TEMPLATE_DEFINE +# endif #endif #ifndef DXFCPP_BEGIN_NAMESPACE diff --git a/include/dxfeed_graal_cpp_api/model/IndexedTxModel.hpp b/include/dxfeed_graal_cpp_api/model/IndexedTxModel.hpp index 23d24c21..ec50397a 100644 --- a/include/dxfeed_graal_cpp_api/model/IndexedTxModel.hpp +++ b/include/dxfeed_graal_cpp_api/model/IndexedTxModel.hpp @@ -132,12 +132,12 @@ struct DXFCPP_EXPORT IndexedTxModelImpl { * @tparam E The type of event (derived from IndexedEvent) */ template E> -struct DXFCPP_EXPORT IndexedTxModel final : IndexedTxModelImpl, RequireMakeShared> { +struct /* DXFCPP_EXPORT */ IndexedTxModel final : IndexedTxModelImpl, RequireMakeShared> { /** * A builder class for creating an instance of IndexedTxModel. */ - struct DXFCPP_EXPORT Builder final : IndexedTxModelImpl::Builder, RequireMakeShared { + struct /* DXFCPP_EXPORT */ Builder final : IndexedTxModelImpl::Builder, RequireMakeShared { private: JavaObjectHandle handle_; std::shared_ptr listener_; diff --git a/include/dxfeed_graal_cpp_api/model/MarketDepthModel.hpp b/include/dxfeed_graal_cpp_api/model/MarketDepthModel.hpp index 452deebe..0dee78c3 100644 --- a/include/dxfeed_graal_cpp_api/model/MarketDepthModel.hpp +++ b/include/dxfeed_graal_cpp_api/model/MarketDepthModel.hpp @@ -114,9 +114,9 @@ struct SymbolWrapper; * * @tparam O The type of order derived from OrderBase. */ -template O> struct DXFCPP_EXPORT MarketDepthModel final : RequireMakeShared> { +template O> struct /* DXFCPP_EXPORT */ MarketDepthModel final : RequireMakeShared> { - struct DXFCPP_EXPORT Builder final : RequireMakeShared { + struct /* DXFCPP_EXPORT */ Builder final : RequireMakeShared { friend struct MarketDepthModel; private: diff --git a/include/dxfeed_graal_cpp_api/model/MarketDepthModelListener.hpp b/include/dxfeed_graal_cpp_api/model/MarketDepthModelListener.hpp index c4b1ddbc..86f5e101 100644 --- a/include/dxfeed_graal_cpp_api/model/MarketDepthModelListener.hpp +++ b/include/dxfeed_graal_cpp_api/model/MarketDepthModelListener.hpp @@ -26,7 +26,7 @@ DXFCPP_BEGIN_NAMESPACE * @tparam O The type of order derived from OrderBase. */ template O> -struct DXFCPP_EXPORT MarketDepthModelListener final : RequireMakeShared> { +struct /* DXFCPP_EXPORT */ MarketDepthModelListener final : RequireMakeShared> { /** * The listener's callback (and handler) signature. */ diff --git a/include/dxfeed_graal_cpp_api/model/TimeSeriesTxModel.hpp b/include/dxfeed_graal_cpp_api/model/TimeSeriesTxModel.hpp index d52eb09e..00216f3d 100644 --- a/include/dxfeed_graal_cpp_api/model/TimeSeriesTxModel.hpp +++ b/include/dxfeed_graal_cpp_api/model/TimeSeriesTxModel.hpp @@ -135,10 +135,10 @@ struct DXFCPP_EXPORT TimeSeriesTxModelImpl { * @tparam E The type of event (derived from TimeSeriesEvent) */ template E> -struct DXFCPP_EXPORT TimeSeriesTxModel final : TimeSeriesTxModelImpl, RequireMakeShared> { +struct /* DXFCPP_EXPORT */ TimeSeriesTxModel final : TimeSeriesTxModelImpl, RequireMakeShared> { /// A builder class for creating an instance of TimeSeriesTxModel. - struct DXFCPP_EXPORT Builder final : TimeSeriesTxModelImpl::Builder, RequireMakeShared { + struct /* DXFCPP_EXPORT */ Builder final : TimeSeriesTxModelImpl::Builder, RequireMakeShared { private: JavaObjectHandle handle_; std::shared_ptr listener_; diff --git a/include/dxfeed_graal_cpp_api/model/TxModelListener.hpp b/include/dxfeed_graal_cpp_api/model/TxModelListener.hpp index b6f7441f..c03f9115 100644 --- a/include/dxfeed_graal_cpp_api/model/TxModelListener.hpp +++ b/include/dxfeed_graal_cpp_api/model/TxModelListener.hpp @@ -68,7 +68,7 @@ struct DXFCPP_EXPORT TxModelListenerCommon : virtual SharedEntity { * The listener for receiving indexed events with the specified type from the IndexedTxModel. */ template E> -struct DXFCPP_EXPORT IndexedTxModelListener final : TxModelListenerCommon, +struct /* DXFCPP_EXPORT */ IndexedTxModelListener final : TxModelListenerCommon, RequireMakeShared> { IndexedTxModelListener(RequireMakeShared>::LockExternalConstructionTag) {}; @@ -142,7 +142,7 @@ struct DXFCPP_EXPORT IndexedTxModelListener final : TxModelListenerCommon, * The listener for receiving time series events with the specified type from the TimeSeriesTxModel. */ template E> -struct DXFCPP_EXPORT TimeSeriesTxModelListener final : TxModelListenerCommon, +struct /* DXFCPP_EXPORT */ TimeSeriesTxModelListener final : TxModelListenerCommon, RequireMakeShared> { TimeSeriesTxModelListener(RequireMakeShared>::LockExternalConstructionTag) {}; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8dbcf219..bbe51d4f 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -47,7 +47,14 @@ foreach (DXFC_TEST_SOURCE ${DXFC_TEST_SOURCES}) add_executable(${DXFC_TEST_BASENAME} ${DXFC_TEST_SOURCE} main.cpp) target_include_directories(${DXFC_TEST_BASENAME} PRIVATE ${DXFC_TEST_INCLUDE_DIRS}) - target_link_libraries(${DXFC_TEST_BASENAME} PRIVATE dxfcxx::static fmt::fmt-header-only) + + if (DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS) + target_link_libraries(${DXFC_TEST_BASENAME} PRIVATE dxfcxx fmt::fmt-header-only) + target_compile_definitions(${DXFC_TEST_BASENAME} PRIVATE DXFCPP_USE_DLLS) + else () + target_link_libraries(${DXFC_TEST_BASENAME} PRIVATE dxfcxx::static fmt::fmt-header-only) + endif () + if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${DXFC_TEST_BASENAME}) @@ -68,5 +75,12 @@ foreach (DXFC_TEST_SOURCE ${DXFC_TEST_SOURCES}) add_test(NAME ${DXFC_TEST_BASENAME} COMMAND ${DXFC_TEST_BASENAME}) add_custom_command(TARGET ${DXFC_TEST_BASENAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - $ $) + $ + $) + + if (DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS) + add_custom_command(TARGET ${DXFC_TEST_BASENAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) + endif () endforeach () From 470e6c99b14b755d03826b05620a676c62c65843 Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Wed, 9 Apr 2025 20:04:32 +0300 Subject: [PATCH 03/12] Disable dynamic linking for unit tests and remove unused test code. Commented out an unused include in MarketDepthModelTest.cpp, set DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS to OFF in CMakeLists.txt, and removed a failing test case from DataIntegrityTest. These changes clean up the codebase and align the build configuration with testing requirements. --- CMakeLists.txt | 2 +- tests/api/DataIntegrityTest.cpp | 18 ------------------ tests/model/MarketDepthModelTest.cpp | 2 +- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0defc06e..af9db97d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,7 +51,7 @@ if (NOT DEFINED DXFCXX_IS_ROOT_PROJECT) endif () option(DXFCXX_BUILD_UNIT_TESTS "Build tests" ${DXFCXX_IS_ROOT_PROJECT}) -option(DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS "Dynamically link unit tests" ON) +option(DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS "Dynamically link unit tests" OFF) option(DXFCXX_BUILD_SAMPLES "Build samples" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_BUILD_TOOLS "Build tools" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_BUILD_DOC "Build documentation" ${DXFCXX_IS_ROOT_PROJECT}) diff --git a/tests/api/DataIntegrityTest.cpp b/tests/api/DataIntegrityTest.cpp index b010b09d..9a60094f 100644 --- a/tests/api/DataIntegrityTest.cpp +++ b/tests/api/DataIntegrityTest.cpp @@ -85,24 +85,6 @@ struct DataIntegrityRemoteTestFixture { } }; -TEST_CASE_FIXTURE(DataIntegrityTestFixture, "Test Message" * doctest::should_fail()) { - auto sub = feed->createSubscription(Message::TYPE); - auto message = std::make_shared("TEST", "Attachment2"); - - sub->addEventListener([message = message](const std::vector> &messages) { - for (auto &&m : messages) { - fmt::println("{}", m->toString()); - - REQUIRE(message->getAttachment() == m->getAttachment()); - } - }); - - sub->addSymbols("TEST"); - pub->publishEvents(message); - - std::this_thread::sleep_for(2s); -} - TEST_CASE_FIXTURE(DataIntegrityTestFixture, "dxFeed :: Test attach & detach sub") { std::mutex ioMutex{}; diff --git a/tests/model/MarketDepthModelTest.cpp b/tests/model/MarketDepthModelTest.cpp index bdf9885f..046a4157 100644 --- a/tests/model/MarketDepthModelTest.cpp +++ b/tests/model/MarketDepthModelTest.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2025 Devexperts LLC. // SPDX-License-Identifier: MPL-2.0 -#include "dxfeed_graal_cpp_api/model/MarketDepthModel.hpp" +// #include "dxfeed_graal_cpp_api/model/MarketDepthModel.hpp" #include #include From 2c28349a65a0835eca4573c1f15dd3157331d7af Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Wed, 9 Apr 2025 20:59:19 +0300 Subject: [PATCH 04/12] Add dynamic linking support for C++ samples Introduced conditional dynamic linking for C++ samples based on the DXFCXX_DYNAMICALLY_LINK_SAMPLES flag. Updated CMakeLists.txt files and added logic to handle runtime dependencies and properly configure installation setups. --- CMakeLists.txt | 2 + .../dxfeed_graal_cpp_api/promise/Promise.hpp | 10 ++-- samples/cpp/API/AuthSample/CMakeLists.txt | 23 +++++++- samples/cpp/API/ConnectSample/CMakeLists.txt | 23 +++++++- .../API/PrintQuoteEventsSample/CMakeLists.txt | 23 +++++++- .../API/PublishProfilesSample/CMakeLists.txt | 23 +++++++- .../API/QuoteAndTradeSample/CMakeLists.txt | 23 +++++++- .../cpp/API/ReconnectSample/CMakeLists.txt | 23 +++++++- .../API/RequestProfileSample/CMakeLists.txt | 23 +++++++- .../FetchDailyCandlesSample/CMakeLists.txt | 23 +++++++- .../LastEventConsoleSample/CMakeLists.txt | 23 +++++++- .../File/ConvertTapeFileSample/CMakeLists.txt | 54 ++++++++----------- .../cpp/File/FileParserSample/CMakeLists.txt | 23 +++++++- .../File/WriteTapeFileSample/CMakeLists.txt | 23 +++++++- samples/cpp/IPF/IpfLiveSample/CMakeLists.txt | 23 +++++++- samples/cpp/IPF/IpfSample/CMakeLists.txt | 23 +++++++- .../cpp/IPF/OptionChainSample/CMakeLists.txt | 23 +++++++- .../IncOrderSnapshotSample/CMakeLists.txt | 23 +++++++- .../MarketDepthModelSample/CMakeLists.txt | 23 +++++++- .../MultipleMarketDepthSample/CMakeLists.txt | 23 +++++++- .../Model/PriceLevelBookSample/CMakeLists.txt | 23 +++++++- .../OnDemand/OnDemandSample/CMakeLists.txt | 29 ++++++++-- .../Schedule/ScheduleSample/CMakeLists.txt | 31 +++++++++-- 23 files changed, 476 insertions(+), 64 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index af9db97d..0e0ea51a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,9 @@ endif () option(DXFCXX_BUILD_UNIT_TESTS "Build tests" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS "Dynamically link unit tests" OFF) option(DXFCXX_BUILD_SAMPLES "Build samples" ${DXFCXX_IS_ROOT_PROJECT}) +option(DXFCXX_DYNAMICALLY_LINK_SAMPLES "Dynamically link samples" ON) option(DXFCXX_BUILD_TOOLS "Build tools" ${DXFCXX_IS_ROOT_PROJECT}) +option(DXFCXX_DYNAMICALLY_LINK_TOOLS "Dynamically link tools" OFF) option(DXFCXX_BUILD_DOC "Build documentation" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_INSTALL "Prepare install" ON) option(DXFCXX_INSTALL_LIB "Prepare install the libraries" ON) diff --git a/include/dxfeed_graal_cpp_api/promise/Promise.hpp b/include/dxfeed_graal_cpp_api/promise/Promise.hpp index aa1e1fa7..07e984f0 100644 --- a/include/dxfeed_graal_cpp_api/promise/Promise.hpp +++ b/include/dxfeed_graal_cpp_api/promise/Promise.hpp @@ -19,7 +19,7 @@ struct EventType; struct JavaException; struct Promises; -struct PromiseImpl { +struct DXFCPP_EXPORT PromiseImpl { protected: std::atomic handle = nullptr; @@ -37,7 +37,7 @@ struct PromiseImpl { void cancel() const; }; -struct VoidPromiseImpl : PromiseImpl { +struct DXFCPP_EXPORT VoidPromiseImpl : PromiseImpl { std::atomic handle = nullptr; std::atomic own = true; @@ -46,7 +46,7 @@ struct VoidPromiseImpl : PromiseImpl { void getResult() const; }; -struct EventPromiseImpl : PromiseImpl { +struct DXFCPP_EXPORT EventPromiseImpl : PromiseImpl { std::atomic handle = nullptr; std::atomic own = true; @@ -55,7 +55,7 @@ struct EventPromiseImpl : PromiseImpl { std::shared_ptr getResult() const; }; -struct EventsPromiseImpl : PromiseImpl { +struct DXFCPP_EXPORT EventsPromiseImpl : PromiseImpl { std::atomic handle = nullptr; std::atomic own = true; @@ -406,7 +406,7 @@ struct Promise> : CommonPromiseMixin handle = nullptr; explicit PromiseListImpl(void *handle); diff --git a/samples/cpp/API/AuthSample/CMakeLists.txt b/samples/cpp/API/AuthSample/CMakeLists.txt index 943d40bd..bf84c414 100644 --- a/samples/cpp/API/AuthSample/CMakeLists.txt +++ b/samples/cpp/API/AuthSample/CMakeLists.txt @@ -35,20 +35,41 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/API/ConnectSample/CMakeLists.txt b/samples/cpp/API/ConnectSample/CMakeLists.txt index 68a4fcf4..10ea7acc 100644 --- a/samples/cpp/API/ConnectSample/CMakeLists.txt +++ b/samples/cpp/API/ConnectSample/CMakeLists.txt @@ -37,20 +37,41 @@ add_executable(${PROJECT_NAME} src/main.cpp) target_include_directories(${PROJECT_NAME} PRIVATE ../../../../third_party/range-v3-0.12/include) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt b/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt index 7424ac45..c674e2e5 100644 --- a/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt +++ b/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt @@ -35,22 +35,43 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/dxfeed.properties $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/API/${PROJECT_NAME}) install(FILES "dxfeed.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/API/${PROJECT_NAME}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/API/${PROJECT_NAME}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/API/${PROJECT_NAME}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/API/PublishProfilesSample/CMakeLists.txt b/samples/cpp/API/PublishProfilesSample/CMakeLists.txt index 75febd4c..3864a2e4 100644 --- a/samples/cpp/API/PublishProfilesSample/CMakeLists.txt +++ b/samples/cpp/API/PublishProfilesSample/CMakeLists.txt @@ -35,20 +35,41 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt b/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt index 1e3217c5..74009889 100644 --- a/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt +++ b/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt @@ -35,22 +35,43 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/dxfeed.properties $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/API/${PROJECT_NAME}) install(FILES "dxfeed.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/API/${PROJECT_NAME}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/API/${PROJECT_NAME}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/API/${PROJECT_NAME}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/API/ReconnectSample/CMakeLists.txt b/samples/cpp/API/ReconnectSample/CMakeLists.txt index 57e64253..2fc044c1 100644 --- a/samples/cpp/API/ReconnectSample/CMakeLists.txt +++ b/samples/cpp/API/ReconnectSample/CMakeLists.txt @@ -35,20 +35,41 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/API/RequestProfileSample/CMakeLists.txt b/samples/cpp/API/RequestProfileSample/CMakeLists.txt index b89aea50..af9f20e8 100644 --- a/samples/cpp/API/RequestProfileSample/CMakeLists.txt +++ b/samples/cpp/API/RequestProfileSample/CMakeLists.txt @@ -35,20 +35,41 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt b/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt index bf1e3672..79f1ab8e 100644 --- a/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt +++ b/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt @@ -35,22 +35,43 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/dxfeed.properties $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/Candle/${PROJECT_NAME}) install(FILES "dxfeed.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/Candle/${PROJECT_NAME}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/Candle/${PROJECT_NAME}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/Candle/${PROJECT_NAME}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt b/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt index 3331d921..9b738fd3 100644 --- a/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt +++ b/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt @@ -35,22 +35,43 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/dxfeed.properties $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/Console/${PROJECT_NAME}) install(FILES "dxfeed.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/Console/${PROJECT_NAME}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/Console/${PROJECT_NAME}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/Console/${PROJECT_NAME}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt b/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt index 6b9c11be..8cde41ae 100644 --- a/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt +++ b/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt @@ -35,53 +35,43 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -#if (DXFCXX_ENABLE_VS_ASAN) -# target_compile_options(${PROJECT_NAME} PRIVATE "/fsanitize=address") -# target_link_options(${PROJECT_NAME} PRIVATE "/fsanitize=address") -# -# target_compile_definitions(${PROJECT_NAME} -# PUBLIC -# $<$: -# _DISABLE_VECTOR_ANNOTATION -# _DISABLE_STRING_ANNOTATION -# > -# ) -#endif () - -#if (DXFCXX_ENABLE_ASAN_UBSAN) -# target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) -# target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) -# add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different -# $ -# ${CMAKE_CURRENT_SOURCE_DIR}/ConvertTapeFile.in -# $ -# $) -# target_compile_options(${PROJECT_NAME} PRIVATE "-fsanitize=address" "-fsanitize=undefined") -# target_link_options(${PROJECT_NAME} PRIVATE "-fsanitize=address" "-fsanitize=undefined") -#else () -# target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) -# add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different -# $ -# ${CMAKE_CURRENT_SOURCE_DIR}/ConvertTapeFile.in -# $) -#endif () - -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/ConvertTapeFile.in $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/File/${PROJECT_NAME}) install(FILES "ConvertTapeFile.in" DESTINATION ${CMAKE_INSTALL_BINDIR}/File/${PROJECT_NAME}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/File/${PROJECT_NAME}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/File/${PROJECT_NAME}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/File/FileParserSample/CMakeLists.txt b/samples/cpp/File/FileParserSample/CMakeLists.txt index 12bef47f..99d6fa82 100644 --- a/samples/cpp/File/FileParserSample/CMakeLists.txt +++ b/samples/cpp/File/FileParserSample/CMakeLists.txt @@ -35,20 +35,41 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt b/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt index c42be3e1..839a3d45 100644 --- a/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt +++ b/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt @@ -35,20 +35,41 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt b/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt index bd2ffbae..3a309b14 100644 --- a/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt +++ b/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt @@ -35,20 +35,41 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/IPF/IpfSample/CMakeLists.txt b/samples/cpp/IPF/IpfSample/CMakeLists.txt index b31287ef..b467dd21 100644 --- a/samples/cpp/IPF/IpfSample/CMakeLists.txt +++ b/samples/cpp/IPF/IpfSample/CMakeLists.txt @@ -35,22 +35,43 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/dxfeed.properties $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/IPF/${PROJECT_NAME}) install(FILES "dxfeed.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/IPF/${PROJECT_NAME}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/IPF/${PROJECT_NAME}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/IPF/${PROJECT_NAME}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/IPF/OptionChainSample/CMakeLists.txt b/samples/cpp/IPF/OptionChainSample/CMakeLists.txt index defa5bda..eda95c5a 100644 --- a/samples/cpp/IPF/OptionChainSample/CMakeLists.txt +++ b/samples/cpp/IPF/OptionChainSample/CMakeLists.txt @@ -35,22 +35,43 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/dxfeed.properties $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/IPF/${PROJECT_NAME}) install(FILES "dxfeed.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/IPF/${PROJECT_NAME}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/IPF/${PROJECT_NAME}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/IPF/${PROJECT_NAME}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt b/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt index f11dbc8d..649fb1ba 100644 --- a/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt +++ b/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt @@ -37,20 +37,41 @@ add_executable(${PROJECT_NAME} src/main.cpp) target_include_directories(${PROJECT_NAME} PRIVATE ../../../../third_party/range-v3-0.12/include) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt b/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt index f69cf79b..1d6c3278 100644 --- a/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt +++ b/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt @@ -37,20 +37,41 @@ add_executable(${PROJECT_NAME} src/main.cpp) target_include_directories(${PROJECT_NAME} PRIVATE ../../../../third_party/range-v3-0.12/include) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static portals::portals fmt::fmt-header-only) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx portals::portals fmt::fmt-header-only) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static portals::portals fmt::fmt-header-only) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt b/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt index a1f19f3d..b2d16c50 100644 --- a/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt +++ b/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt @@ -35,20 +35,41 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt b/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt index 43e76deb..4af25e66 100644 --- a/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt +++ b/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt @@ -35,20 +35,41 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt b/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt index 050d17bc..70199a0e 100644 --- a/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt +++ b/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt @@ -35,22 +35,43 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/dxfeed.properties $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) - install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}) - install(FILES "dxfeed.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}) + install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/OnDemand/${PROJECT_NAME}) + install(FILES "dxfeed.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/OnDemand/${PROJECT_NAME}) if (WIN32) - install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/OnDemand/${PROJECT_NAME}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/OnDemand/${PROJECT_NAME}) + endif () endif () endif () \ No newline at end of file diff --git a/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt b/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt index cb10beca..224ff215 100644 --- a/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt +++ b/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt @@ -35,24 +35,45 @@ endif () add_executable(${PROJECT_NAME} src/main.cpp) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ ${CMAKE_CURRENT_SOURCE_DIR}/schedule.properties ${CMAKE_CURRENT_SOURCE_DIR}/sample.ipf.zip $) +if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () + if (DXFCXX_INSTALL AND DXFCXX_INSTALL_SAMPLES) - install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}) - install(FILES "schedule.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}) - install(FILES "sample.ipf.zip" DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}) + install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}/Schedule/${PROJECT_NAME}) + install(FILES "schedule.properties" DESTINATION ${CMAKE_INSTALL_BINDIR}/Schedule/${PROJECT_NAME}) + install(FILES "sample.ipf.zip" DESTINATION ${CMAKE_INSTALL_BINDIR}/Schedule/${PROJECT_NAME}) if (WIN32) - install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/${PROJECT_NAME}) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/Schedule/${PROJECT_NAME}) + + if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}/Schedule/${PROJECT_NAME}) + endif () endif () endif () \ No newline at end of file From 01e356efb1249ff598433b0e0db5f89849f7ff72 Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Wed, 9 Apr 2025 21:25:01 +0300 Subject: [PATCH 05/12] Adjust dynamic linking configurations and export symbols Updated CMake options to toggle dynamic linking for tools and samples. Added `DXFCPP_EXPORT` to required functions for proper symbol exports. Revised build scripts to handle dynamic linking dependencies and post-build installation. --- CMakeLists.txt | 4 +-- .../isolated/internal/IsolatedTools.hpp | 6 ++-- tools/Tools/CMakeLists.txt | 28 ++++++++++++++----- tools/Tools/src/Tools.hpp | 1 + 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e0ea51a..3d812ae8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,9 +53,9 @@ endif () option(DXFCXX_BUILD_UNIT_TESTS "Build tests" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS "Dynamically link unit tests" OFF) option(DXFCXX_BUILD_SAMPLES "Build samples" ${DXFCXX_IS_ROOT_PROJECT}) -option(DXFCXX_DYNAMICALLY_LINK_SAMPLES "Dynamically link samples" ON) +option(DXFCXX_DYNAMICALLY_LINK_SAMPLES "Dynamically link samples" OFF) option(DXFCXX_BUILD_TOOLS "Build tools" ${DXFCXX_IS_ROOT_PROJECT}) -option(DXFCXX_DYNAMICALLY_LINK_TOOLS "Dynamically link tools" OFF) +option(DXFCXX_DYNAMICALLY_LINK_TOOLS "Dynamically link tools" ON) option(DXFCXX_BUILD_DOC "Build documentation" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_INSTALL "Prepare install" ON) option(DXFCXX_INSTALL_LIB "Prepare install the libraries" ON) diff --git a/include/dxfeed_graal_cpp_api/isolated/internal/IsolatedTools.hpp b/include/dxfeed_graal_cpp_api/isolated/internal/IsolatedTools.hpp index b3fa16db..a8811e94 100644 --- a/include/dxfeed_graal_cpp_api/isolated/internal/IsolatedTools.hpp +++ b/include/dxfeed_graal_cpp_api/isolated/internal/IsolatedTools.hpp @@ -23,9 +23,9 @@ namespace isolated::internal::IsolatedTools { * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -std::unordered_set /* dxfg_string_list* */ parseSymbols(std::string_view symbolList); +DXFCPP_EXPORT std::unordered_set /* dxfg_string_list* */ parseSymbols(std::string_view symbolList); -std::vector /* dxfg_string_list* */ parseSymbolsAndSaveOrder(std::string_view symbolList); +DXFCPP_EXPORT std::vector /* dxfg_string_list* */ parseSymbolsAndSaveOrder(std::string_view symbolList); /** * Calls the Graal SDK function `dxfg_Tools_main` in isolation. @@ -34,7 +34,7 @@ std::vector /* dxfg_string_list* */ parseSymbolsAndSaveOrder(std::s * @throws JavaException if something happened with the dxFeed API backend. * @throws GraalException if something happened with the GraalVM. */ -void /* int32_t */ runTool(/* dxfg_string_list* */ const std::vector &args); +DXFCPP_EXPORT void /* int32_t */ runTool(/* dxfg_string_list* */ const std::vector &args); } // namespace isolated::internal::IsolatedTools diff --git a/tools/Tools/CMakeLists.txt b/tools/Tools/CMakeLists.txt index 6f7f7fb6..d0f8d209 100644 --- a/tools/Tools/CMakeLists.txt +++ b/tools/Tools/CMakeLists.txt @@ -41,27 +41,41 @@ add_executable(${PROJECT_NAME} target_include_directories(${PROJECT_NAME} PRIVATE ../../third_party/range-v3-0.12/include) -target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static process::process console::console fmt::fmt-header-only) +if (DXFCXX_DYNAMICALLY_LINK_TOOLS) + target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx process::process console::console fmt::fmt-header-only) +else () + target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static process::process console::console fmt::fmt-header-only) +endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${PROJECT_NAME}) endif () +if (DXFCXX_ENABLE_ASAN) + LinkAsan(${PROJECT_NAME}) +elseif (DXFCXX_ENABLE_UBSAN) + LinkUbsan(${PROJECT_NAME}) +endif () + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different $ $) -#target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx process::process console::console fmt::fmt-header-only) -#target_compile_definitions(${PROJECT_NAME} PRIVATE DXFCPP_USE_DLLS) -#add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different -# $ -# $ -# $) +if (DXFCXX_DYNAMICALLY_LINK_TOOLS) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $) +endif () if (DXFCXX_INSTALL AND DXFCXX_INSTALL_TOOLS) install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) if (WIN32) install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + + if (DXFCXX_DYNAMICALLY_LINK_TOOLS) + install(FILES $ DESTINATION ${CMAKE_INSTALL_BINDIR}) + endif () endif () endif () \ No newline at end of file diff --git a/tools/Tools/src/Tools.hpp b/tools/Tools/src/Tools.hpp index 484ead20..89c88ad4 100644 --- a/tools/Tools/src/Tools.hpp +++ b/tools/Tools/src/Tools.hpp @@ -12,6 +12,7 @@ #include "LatencyTest/LatencyTestTool.hpp" #include "PerfTest/PerfTestTool.hpp" #include "PerfTest2/PerfTest2Tool.hpp" +#include "Qds/QdsTool.hpp" #include #include From a1523fe99e790f3d29c2e96eb351503c78cf48d8 Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Thu, 10 Apr 2025 13:29:07 +0300 Subject: [PATCH 06/12] Enable static runtime linking for MSVC builds Introduced support for the `DXFCXX_LINK_STATIC_RUNTIME` option to enable static runtime linking (`/MT` or `/MTd`) for MSVC. This applies to both the main library and associated samples or tools when this option is enabled. --- CMakeLists.txt | 22 +++++++++++++++++-- samples/cpp/API/AuthSample/CMakeLists.txt | 8 +++++++ samples/cpp/API/ConnectSample/CMakeLists.txt | 8 +++++++ .../API/PrintQuoteEventsSample/CMakeLists.txt | 8 +++++++ .../API/PublishProfilesSample/CMakeLists.txt | 8 +++++++ .../API/QuoteAndTradeSample/CMakeLists.txt | 8 +++++++ .../cpp/API/ReconnectSample/CMakeLists.txt | 8 +++++++ .../API/RequestProfileSample/CMakeLists.txt | 8 +++++++ .../FetchDailyCandlesSample/CMakeLists.txt | 8 +++++++ .../LastEventConsoleSample/CMakeLists.txt | 8 +++++++ .../File/ConvertTapeFileSample/CMakeLists.txt | 8 +++++++ .../cpp/File/FileParserSample/CMakeLists.txt | 8 +++++++ .../File/WriteTapeFileSample/CMakeLists.txt | 8 +++++++ samples/cpp/IPF/IpfLiveSample/CMakeLists.txt | 8 +++++++ samples/cpp/IPF/IpfSample/CMakeLists.txt | 8 +++++++ .../cpp/IPF/OptionChainSample/CMakeLists.txt | 8 +++++++ .../IncOrderSnapshotSample/CMakeLists.txt | 8 +++++++ .../MarketDepthModelSample/CMakeLists.txt | 8 +++++++ .../MultipleMarketDepthSample/CMakeLists.txt | 8 +++++++ .../Model/PriceLevelBookSample/CMakeLists.txt | 8 +++++++ .../OnDemand/OnDemandSample/CMakeLists.txt | 8 +++++++ .../Schedule/ScheduleSample/CMakeLists.txt | 8 +++++++ tests/CMakeLists.txt | 9 +++++++- tools/Tools/CMakeLists.txt | 8 +++++++ 24 files changed, 204 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d812ae8..2e3b2758 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,13 +55,16 @@ option(DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS "Dynamically link unit tests" OFF) option(DXFCXX_BUILD_SAMPLES "Build samples" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_DYNAMICALLY_LINK_SAMPLES "Dynamically link samples" OFF) option(DXFCXX_BUILD_TOOLS "Build tools" ${DXFCXX_IS_ROOT_PROJECT}) -option(DXFCXX_DYNAMICALLY_LINK_TOOLS "Dynamically link tools" ON) +option(DXFCXX_DYNAMICALLY_LINK_TOOLS "Dynamically link tools" OFF) option(DXFCXX_BUILD_DOC "Build documentation" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_INSTALL "Prepare install" ON) option(DXFCXX_INSTALL_LIB "Prepare install the libraries" ON) option(DXFCXX_INSTALL_SAMPLES "Prepare install the samples" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_INSTALL_TOOLS "Prepare install the tools" ${DXFCXX_IS_ROOT_PROJECT}) +option(DXFCXX_LINK_STATIC_RUNTIME "Compile and link with -MT/-MTd or equivalent flag(s) to use a multi-threaded statically-linked runtime library. Visual Studio only." OFF) +option(DXFCXX_NODEFAULTLIB_LIBCMT "Ignore libcmt/libcmtd. Use if DXFCXX_LINK_STATIC_RUNTIME == ON." OFF) + option(DXFCXX_ENABLE_METRICS "Enable metrics collection" OFF) option(DXFCXX_USE_DXFEED_GRAAL_NATIVE_SDK_JFROG "" ON) @@ -453,7 +456,22 @@ add_library(dxfcxx ALIAS ${PROJECT_NAME}) add_library(dxfcxx::static ALIAS ${PROJECT_NAME}_static) add_library(dxfcxx::graal ALIAS DxFeedGraalNativeSdk) -set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set_target_properties(${PROJECT_NAME} PROPERTIES CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME}_static PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + + if (DXFCXX_NODEFAULTLIB_LIBCMT) + target_link_options(${PROJECT_NAME}_static PRIVATE + "/NODEFAULTLIB:LIBCMT" + "/NODEFAULTLIB:LIBCMTD" + ) + endif () + endif () +endif () + target_include_directories(${PROJECT_NAME} PUBLIC include) target_include_directories(${PROJECT_NAME} PRIVATE third_party/range-v3-${RANGE_VERSION}/include) target_compile_definitions(${PROJECT_NAME} PRIVATE diff --git a/samples/cpp/API/AuthSample/CMakeLists.txt b/samples/cpp/API/AuthSample/CMakeLists.txt index bf84c414..b0f7d4ee 100644 --- a/samples/cpp/API/AuthSample/CMakeLists.txt +++ b/samples/cpp/API/AuthSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/API/ConnectSample/CMakeLists.txt b/samples/cpp/API/ConnectSample/CMakeLists.txt index 10ea7acc..997c028b 100644 --- a/samples/cpp/API/ConnectSample/CMakeLists.txt +++ b/samples/cpp/API/ConnectSample/CMakeLists.txt @@ -42,6 +42,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt b/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt index c674e2e5..0c689c9e 100644 --- a/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt +++ b/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/API/PublishProfilesSample/CMakeLists.txt b/samples/cpp/API/PublishProfilesSample/CMakeLists.txt index 3864a2e4..94331994 100644 --- a/samples/cpp/API/PublishProfilesSample/CMakeLists.txt +++ b/samples/cpp/API/PublishProfilesSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt b/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt index 74009889..5d6d1506 100644 --- a/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt +++ b/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/API/ReconnectSample/CMakeLists.txt b/samples/cpp/API/ReconnectSample/CMakeLists.txt index 2fc044c1..0ce1a11d 100644 --- a/samples/cpp/API/ReconnectSample/CMakeLists.txt +++ b/samples/cpp/API/ReconnectSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/API/RequestProfileSample/CMakeLists.txt b/samples/cpp/API/RequestProfileSample/CMakeLists.txt index af9f20e8..50705df3 100644 --- a/samples/cpp/API/RequestProfileSample/CMakeLists.txt +++ b/samples/cpp/API/RequestProfileSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt b/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt index 79f1ab8e..1dc0d70f 100644 --- a/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt +++ b/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt b/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt index 9b738fd3..cffdb6be 100644 --- a/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt +++ b/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt b/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt index 8cde41ae..21c13b8d 100644 --- a/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt +++ b/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/File/FileParserSample/CMakeLists.txt b/samples/cpp/File/FileParserSample/CMakeLists.txt index 99d6fa82..646f34c6 100644 --- a/samples/cpp/File/FileParserSample/CMakeLists.txt +++ b/samples/cpp/File/FileParserSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt b/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt index 839a3d45..5aa1204f 100644 --- a/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt +++ b/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt b/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt index 3a309b14..49f76278 100644 --- a/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt +++ b/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/IPF/IpfSample/CMakeLists.txt b/samples/cpp/IPF/IpfSample/CMakeLists.txt index b467dd21..b1a31e72 100644 --- a/samples/cpp/IPF/IpfSample/CMakeLists.txt +++ b/samples/cpp/IPF/IpfSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/IPF/OptionChainSample/CMakeLists.txt b/samples/cpp/IPF/OptionChainSample/CMakeLists.txt index eda95c5a..5f88c17f 100644 --- a/samples/cpp/IPF/OptionChainSample/CMakeLists.txt +++ b/samples/cpp/IPF/OptionChainSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt b/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt index 649fb1ba..d83f7324 100644 --- a/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt +++ b/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt @@ -42,6 +42,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt b/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt index 1d6c3278..0009280b 100644 --- a/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt +++ b/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt @@ -42,6 +42,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx portals::portals fmt::fmt-header-only) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static portals::portals fmt::fmt-header-only) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt b/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt index b2d16c50..1f1311d9 100644 --- a/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt +++ b/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt b/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt index 4af25e66..11a1f0f3 100644 --- a/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt +++ b/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx fmt::fmt-header-only) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static fmt::fmt-header-only) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt b/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt index 70199a0e..33280802 100644 --- a/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt +++ b/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt b/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt index 224ff215..aec0b72f 100644 --- a/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt +++ b/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt @@ -40,6 +40,14 @@ if (DXFCXX_DYNAMICALLY_LINK_SAMPLES) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bbe51d4f..bce04330 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -53,8 +53,15 @@ foreach (DXFC_TEST_SOURCE ${DXFC_TEST_SOURCES}) target_compile_definitions(${DXFC_TEST_BASENAME} PRIVATE DXFCPP_USE_DLLS) else () target_link_libraries(${DXFC_TEST_BASENAME} PRIVATE dxfcxx::static fmt::fmt-header-only) - endif () + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${DXFC_TEST_BASENAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () + endif () if (DXFCXX_FEATURE_STACKTRACE) LinkStacktrace(${DXFC_TEST_BASENAME}) diff --git a/tools/Tools/CMakeLists.txt b/tools/Tools/CMakeLists.txt index d0f8d209..a435fa66 100644 --- a/tools/Tools/CMakeLists.txt +++ b/tools/Tools/CMakeLists.txt @@ -46,6 +46,14 @@ if (DXFCXX_DYNAMICALLY_LINK_TOOLS) target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx process::process console::console fmt::fmt-header-only) else () target_link_libraries(${PROJECT_NAME} PRIVATE dxfcxx::static process::process console::console fmt::fmt-header-only) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")) + if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(${PROJECT_NAME} PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + endif () + endif () endif () if (DXFCXX_FEATURE_STACKTRACE) From 143f8b9008063a08295f84f47a88e69684fbef27 Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Thu, 10 Apr 2025 13:51:04 +0300 Subject: [PATCH 07/12] Update the ReleaseNotes.md --- ReleaseNotes.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index a2f8076d..5d30a9ad 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,10 +1,27 @@ -## v4.1.0 +* **\[MDAPI-249]\[C++]** Transitive dependencies are hidden. +* Fixed a segfault related to linking features: added a default constructor for `ApiContext`. +* **\[MDAPI-246]\[ะก++]** Added an ability to build the project with statically linked runtime libraries with Visual + Studio. +* Fixed dynamic linking under Windows. These classes and functions are affected: + * `PromiseImpl`, `VoidPromiseImpl`, `EventPromiseImpl`, `EventsPromiseImpl`, `PromiseListImpl` + * `isolated::internal::IsolatedTools::parseSymbols`, `isolated::internal::IsolatedTools::parseSymbolsAndSaveOrder`, + `isolated::internal::IsolatedTools::runTool` + * All C-API functions. +* Added the ability to enable dynamic linking of tests using the CMake parameter `DXFCXX_DYNAMICALLY_LINK_UNIT_TESTS` +* Added the ability to enable dynamic linking of samples using the CMake parameter `DXFCXX_DYNAMICALLY_LINK_SAMPLES` +* Added the ability to enable dynamic linking of tools using the CMake parameter `DXFCXX_DYNAMICALLY_LINK_TOOLS` +* Added the ability to statically link Windows runtime libraries (for Visual Studio) using the + `DXFCXX_LINK_STATIC_RUNTIME` parameter +* Added the ability to ignore the libcmt/libcmtd library when statically linking Windows runtime libraries using the + `DXFCXX_NODEFAULTLIB_LIBCMT` parameter (works only when the `DXFCXX_LINK_STATIC_RUNTIME` parameter is enabled) + +## v4.1.0 * **\[MDAPI-35]\[C++]** Added RequestProfileSample example * **\[MDAPI-30]\[C++]** Added LastEventsConsoleSample sample * **\[MDAPI-27]\[C++]** Implemented OptionChain - * Added `OptionChain` class. - * Added `OptionSeries` class. + * Added `OptionChain` class. + * Added `OptionSeries` class. * Added `OptionChainsBuilder` class. * Added `OptionChainSample` example. * **\[MDAPI-77]\[C++]** Added support for retrieving indexed events from feed From 6a05e834b17fba5728e03eab722ef82df3754d92 Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Thu, 10 Apr 2025 14:13:10 +0300 Subject: [PATCH 08/12] Add separate build and CMake steps for Windows MT builds Introduce dedicated steps in the GitHub Actions workflow for building and configuring CMake with multi-threaded runtime on Windows. This ensures proper handling of static runtime linkage and improves build parallelism for Windows-specific configurations. --- .github/workflows/build.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68277430..79fc364e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,7 +78,13 @@ jobs: - name: Prepare build run: | ls - mkdir ${{github.workspace}}/build + mkdir ${{github.workspace}}/build + + - name: Prepare build (Win MT) + if: ${{ contains(matrix.config.os, 'win') }} + run: | + ls + mkdir ${{github.workspace}}/build-mt - name: Configure CMake if: ${{ contains(matrix.config.os, 'mac') }} @@ -110,6 +116,16 @@ jobs: -DDXFCXX_BUILD_DOC=OFF -DDXFCXX_FEATURE_STACKTRACE=ON + - name: Configure CMake (Win MT) + if: ${{ contains(matrix.config.os, 'win') }} + run: > + cmake -B ${{github.workspace}}/build-mt + -DCMAKE_BUILD_TYPE=${{matrix.buildType}} + -DDXFCXX_BUILD_DOC=OFF + -DDXFCXX_FEATURE_STACKTRACE=ON + -DDXFCXX_LINK_STATIC_RUNTIME=ON + -DXFCXX_NODEFAULTLIB_LIBCMT=ON + - name: Build if: ${{ !contains(matrix.config.os, 'win') }} run: > @@ -122,6 +138,13 @@ jobs: -- /p:CL_MPCount=${{matrix.config.cores}} + - name: Build (Win MT) + if: ${{ contains(matrix.config.os, 'win') }} + run: > + cmake --build ${{github.workspace}}/build-mt --config ${{matrix.buildType}} -j ${{matrix.config.cores}} + -- + /p:CL_MPCount=${{matrix.config.cores}} + - name: Test if: ${{ ! cancelled() }} continue-on-error: true From cd312ae567637317e2c2569db61bf2562d0632ac Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Thu, 10 Apr 2025 16:49:43 +0300 Subject: [PATCH 09/12] Add support for Windows static builds with MT runtime This commit introduces steps for preparing, building, and packaging Windows static builds with the multi-threaded runtime (MT). It updates GitHub workflows and CMake configurations to enable the `DXFCXX_LINK_STATIC_RUNTIME` option and adjusts related packaging and artifact upload processes. --- .github/workflows/build.yml | 1 - .github/workflows/release.yml | 42 +++++++++++++++++++++++++++++++++++ CMakeLists.txt | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 79fc364e..f235a304 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -124,7 +124,6 @@ jobs: -DDXFCXX_BUILD_DOC=OFF -DDXFCXX_FEATURE_STACKTRACE=ON -DDXFCXX_LINK_STATIC_RUNTIME=ON - -DXFCXX_NODEFAULTLIB_LIBCMT=ON - name: Build if: ${{ !contains(matrix.config.os, 'win') }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6c09f788..fda160bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -96,6 +96,12 @@ jobs: ls mkdir ${{github.workspace}}/build-${{matrix.buildType}} + - name: Prepare build [Lib][Win with static with MT] + if: ${{ contains(matrix.config.os, 'win') }} + run: | + ls + mkdir ${{github.workspace}}/build-${{matrix.buildType}}-mt + - name: Prepare build [Samples][Tools] if: ${{ !contains(matrix.buildType, 'Deb') }} run: | @@ -118,6 +124,22 @@ jobs: -DDXFCXX_BUILD_DOC=OFF -DDXFCXX_FEATURE_STACKTRACE=ON + - name: Configure CMake [Lib][Win with static with MT] + if: ${{ contains(matrix.config.os, 'win') }} + run: > + cmake -B ${{github.workspace}}/build-${{matrix.buildType}}-mt + -DCMAKE_BUILD_TYPE=${{matrix.buildType}} + -DDXFCXX_VERSION="${{needs.get_version.outputs.version}}" + -DDXFCXX_PACKAGE_SUFFIX="-${{matrix.buildType}}-static-mt" + -DDXFCXX_BUILD_UNIT_TESTS=OFF + -DDXFCXX_BUILD_SAMPLES=OFF + -DDXFCXX_BUILD_TOOLS=OFF + -DDXFCXX_INSTALL_SAMPLES=OFF + -DDXFCXX_INSTALL_TOOLS=OFF + -DDXFCXX_BUILD_DOC=OFF + -DDXFCXX_FEATURE_STACKTRACE=ON + -DDXFCXX_LINK_STATIC_RUNTIME=ON + - name: Configure CMake [Samples][Tools] if: ${{ contains(matrix.config.os, 'windows') && !contains(matrix.buildType, 'Deb') }} run: > @@ -249,6 +271,14 @@ jobs: -- /p:CL_MPCount=${{matrix.config.cores}} + - name: Build [Lib][Win with static with MT] + if: ${{ contains(matrix.config.os, 'win') }} + run: > + cmake --build ${{github.workspace}}/build-${{matrix.buildType}}-mt + --config ${{matrix.buildType}} -j ${{matrix.config.cores}} + -- + /p:CL_MPCount=${{matrix.config.cores}} + - name: Build [Samples][Tools] if: ${{ !contains(matrix.buildType, 'Deb') && !contains(matrix.config.os, 'win') }} run: | @@ -274,6 +304,11 @@ jobs: working-directory: "${{github.workspace}}/build-${{matrix.buildType}}" run: cpack -G ZIP -C ${{matrix.buildType}} --config ./dxFeedGraalCxxApiPackConfig.cmake + - name: Pack [Lib][Win with static with MT] + if: ${{ contains(matrix.config.os, 'win') }} + working-directory: "${{github.workspace}}/build-${{matrix.buildType}}-mt" + run: cpack -G ZIP -C ${{matrix.buildType}} --config ./dxFeedGraalCxxApiPackConfig.cmake + - name: Pack [Samples] if: ${{ !contains(matrix.buildType, 'Deb') }} working-directory: ${{github.workspace}}/build-Samples @@ -290,6 +325,13 @@ jobs: name: artifacts-lib-${{matrix.config.name}}-${{matrix.buildType}} path: build-${{matrix.buildType}}/*.zip + - name: Upload [Lib][Win with static with MT] + if: ${{ contains(matrix.config.os, 'win') }} + uses: actions/upload-artifact@v4 + with: + name: artifacts-lib-${{matrix.config.name}}-${{matrix.buildType}}-mt + path: build-${{matrix.buildType}}-mt/*.zip + - name: Upload [Samples][Tools] if: ${{ !contains(matrix.buildType, 'Deb') }} uses: actions/upload-artifact@v4 diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e3b2758..513c83c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,7 @@ option(DXFCXX_INSTALL_SAMPLES "Prepare install the samples" ${DXFCXX_IS_ROOT_PRO option(DXFCXX_INSTALL_TOOLS "Prepare install the tools" ${DXFCXX_IS_ROOT_PROJECT}) option(DXFCXX_LINK_STATIC_RUNTIME "Compile and link with -MT/-MTd or equivalent flag(s) to use a multi-threaded statically-linked runtime library. Visual Studio only." OFF) -option(DXFCXX_NODEFAULTLIB_LIBCMT "Ignore libcmt/libcmtd. Use if DXFCXX_LINK_STATIC_RUNTIME == ON." OFF) +option(DXFCXX_NODEFAULTLIB_LIBCMT "Ignore libcmt/libcmtd. Use if DXFCXX_LINK_STATIC_RUNTIME == ON." ${DXFCXX_LINK_STATIC_RUNTIME}) option(DXFCXX_ENABLE_METRICS "Enable metrics collection" OFF) From d246870bce904c9bd62c4013f4b77162644fb26a Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Thu, 10 Apr 2025 17:45:32 +0300 Subject: [PATCH 10/12] Enable static runtime linkage and improve build configuration Added an option to link the static runtime in `CMakeLists.txt` with configurable runtime library behavior for MSVC. Updated the GitHub Actions workflow to set `DXFCXX_LINK_STATIC_RUNTIME=ON` during the build process. --- .github/workflows/build.yml | 2 +- CMakeLists.txt | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f235a304..1376ece0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -122,7 +122,7 @@ jobs: cmake -B ${{github.workspace}}/build-mt -DCMAKE_BUILD_TYPE=${{matrix.buildType}} -DDXFCXX_BUILD_DOC=OFF - -DDXFCXX_FEATURE_STACKTRACE=ON + -DDXFCXX_FEATURE_STACKTRACE=ON -DDXFCXX_LINK_STATIC_RUNTIME=ON - name: Build diff --git a/CMakeLists.txt b/CMakeLists.txt index 513c83c4..34c73c7b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,19 @@ else () CPMAddPackage("gh:ttldtor/Process#v${PROCESS_VERSION}") endif () +if (DXFCXX_LINK_STATIC_RUNTIME) + set_target_properties(process PROPERTIES + MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>" + ) + + if (DXFCXX_NODEFAULTLIB_LIBCMT) + target_link_options(process PRIVATE + "/NODEFAULTLIB:LIBCMT" + "/NODEFAULTLIB:LIBCMTD" + ) + endif () +endif () + if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/Console-${CONSOLE_VERSION}/CMakeLists.txt") add_subdirectory(third_party/Console-${CONSOLE_VERSION}) else () From cbfef791db96e0119c6de6d9dea6364866e8b3ce Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Thu, 10 Apr 2025 18:26:58 +0300 Subject: [PATCH 11/12] v4.2.0-rc1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34c73c7b..1fb42fd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ project(dxFeedGraalCxxApi) include(cmake/ParseVersion.cmake) -set(DXFCXX_VERSION "v4.1.0" CACHE STRING "The dxFeed Graal CXX API package version") +set(DXFCXX_VERSION "v4.2.0-rc1" CACHE STRING "The dxFeed Graal CXX API package version") dxfcxx_ParseVersion(${DXFCXX_VERSION} DXFCXX_MAJOR_VERSION DXFCXX_MINOR_VERSION DXFCXX_PATCH_VERSION DXFCXX_SUFFIX_VERSION) From 13c1b9208ff98352ea919979ca74cb8f010aff07 Mon Sep 17 00:00:00 2001 From: AnatolyKalin Date: Thu, 10 Apr 2025 19:27:39 +0300 Subject: [PATCH 12/12] Add preparation of static runtime library releases Updated ReleaseNotes.md to document the preparation of Windows library releases linked statically with runtime libraries. These artifacts are named with the `-static-mt` suffix to indicate their static runtime linkage. --- ReleaseNotes.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ReleaseNotes.md b/ReleaseNotes.md index 5d30a9ad..41c2775c 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -14,6 +14,9 @@ `DXFCXX_LINK_STATIC_RUNTIME` parameter * Added the ability to ignore the libcmt/libcmtd library when statically linking Windows runtime libraries using the `DXFCXX_NODEFAULTLIB_LIBCMT` parameter (works only when the `DXFCXX_LINK_STATIC_RUNTIME` parameter is enabled) +* Added preparation of library releases for Windows, linked statically with runtime libraries (with parameters: `/MT`, + `/MTd`, `/NODEFAULTLIB:LIBCMT`, `/NODEFAULTLIB:LIBCMTD`). The names of these artifacts end with `-static-mt`, for + example `dxFeedGraalCxxApi-v4.2.0-rc1-x86_64-windows-Release-static-mt.zip` ## v4.1.0