diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 68277430..1376ece0 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,15 @@ 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 + - name: Build if: ${{ !contains(matrix.config.os, 'win') }} run: > @@ -122,6 +137,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 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 f47a677a..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) @@ -51,14 +51,20 @@ 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" 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" 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." ${DXFCXX_LINK_STATIC_RUNTIME}) + option(DXFCXX_ENABLE_METRICS "Enable metrics collection" OFF) option(DXFCXX_USE_DXFEED_GRAAL_NATIVE_SDK_JFROG "" ON) @@ -140,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 () @@ -450,7 +469,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/ReleaseNotes.md b/ReleaseNotes.md index a2f8076d..41c2775c 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,10 +1,30 @@ -## 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) +* 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 * **\[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 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 82758b86..0b65ff5e 100644 --- a/include/dxfeed_graal_cpp_api/internal/Conf.hpp +++ b/include/dxfeed_graal_cpp_api/internal/Conf.hpp @@ -30,37 +30,37 @@ # 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 -#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/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/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/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/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..b0f7d4ee 100644 --- a/samples/cpp/API/AuthSample/CMakeLists.txt +++ b/samples/cpp/API/AuthSample/CMakeLists.txt @@ -35,20 +35,49 @@ 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) + + 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) 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..997c028b 100644 --- a/samples/cpp/API/ConnectSample/CMakeLists.txt +++ b/samples/cpp/API/ConnectSample/CMakeLists.txt @@ -37,20 +37,49 @@ 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) + + 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) 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..0c689c9e 100644 --- a/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt +++ b/samples/cpp/API/PrintQuoteEventsSample/CMakeLists.txt @@ -35,22 +35,51 @@ 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) + + 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) 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..94331994 100644 --- a/samples/cpp/API/PublishProfilesSample/CMakeLists.txt +++ b/samples/cpp/API/PublishProfilesSample/CMakeLists.txt @@ -35,20 +35,49 @@ 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) + + 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) 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..5d6d1506 100644 --- a/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt +++ b/samples/cpp/API/QuoteAndTradeSample/CMakeLists.txt @@ -35,22 +35,51 @@ 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) + + 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) 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..0ce1a11d 100644 --- a/samples/cpp/API/ReconnectSample/CMakeLists.txt +++ b/samples/cpp/API/ReconnectSample/CMakeLists.txt @@ -35,20 +35,49 @@ 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) + + 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) 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..50705df3 100644 --- a/samples/cpp/API/RequestProfileSample/CMakeLists.txt +++ b/samples/cpp/API/RequestProfileSample/CMakeLists.txt @@ -35,20 +35,49 @@ 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) + + 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) 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..1dc0d70f 100644 --- a/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt +++ b/samples/cpp/Candle/FetchDailyCandlesSample/CMakeLists.txt @@ -35,22 +35,51 @@ 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) + + 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) 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..cffdb6be 100644 --- a/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt +++ b/samples/cpp/Console/LastEventConsoleSample/CMakeLists.txt @@ -35,22 +35,51 @@ 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) + + 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) 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..21c13b8d 100644 --- a/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt +++ b/samples/cpp/File/ConvertTapeFileSample/CMakeLists.txt @@ -35,53 +35,51 @@ 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) + + 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) 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..646f34c6 100644 --- a/samples/cpp/File/FileParserSample/CMakeLists.txt +++ b/samples/cpp/File/FileParserSample/CMakeLists.txt @@ -35,20 +35,49 @@ 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) + + 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) 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..5aa1204f 100644 --- a/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt +++ b/samples/cpp/File/WriteTapeFileSample/CMakeLists.txt @@ -35,20 +35,49 @@ 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) + + 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) 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..49f76278 100644 --- a/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt +++ b/samples/cpp/IPF/IpfLiveSample/CMakeLists.txt @@ -35,20 +35,49 @@ 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) + + 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) 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..b1a31e72 100644 --- a/samples/cpp/IPF/IpfSample/CMakeLists.txt +++ b/samples/cpp/IPF/IpfSample/CMakeLists.txt @@ -35,22 +35,51 @@ 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) + + 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) 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..5f88c17f 100644 --- a/samples/cpp/IPF/OptionChainSample/CMakeLists.txt +++ b/samples/cpp/IPF/OptionChainSample/CMakeLists.txt @@ -35,22 +35,51 @@ 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) + + 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) 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..d83f7324 100644 --- a/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt +++ b/samples/cpp/Model/IncOrderSnapshotSample/CMakeLists.txt @@ -37,20 +37,49 @@ 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) + + 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) 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..0009280b 100644 --- a/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt +++ b/samples/cpp/Model/MarketDepthModelSample/CMakeLists.txt @@ -37,20 +37,49 @@ 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) + + 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) 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..1f1311d9 100644 --- a/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt +++ b/samples/cpp/Model/MultipleMarketDepthSample/CMakeLists.txt @@ -35,20 +35,49 @@ 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) + + 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) 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..11a1f0f3 100644 --- a/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt +++ b/samples/cpp/Model/PriceLevelBookSample/CMakeLists.txt @@ -35,20 +35,49 @@ 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) + + 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) 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..33280802 100644 --- a/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt +++ b/samples/cpp/OnDemand/OnDemandSample/CMakeLists.txt @@ -35,22 +35,51 @@ 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) + + 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) 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..aec0b72f 100644 --- a/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt +++ b/samples/cpp/Schedule/ScheduleSample/CMakeLists.txt @@ -35,24 +35,53 @@ 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) + + 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) 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 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 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8dbcf219..bce04330 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -47,7 +47,21 @@ 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) + + 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}) @@ -68,5 +82,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 () 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 diff --git a/tools/Tools/CMakeLists.txt b/tools/Tools/CMakeLists.txt index 6f7f7fb6..a435fa66 100644 --- a/tools/Tools/CMakeLists.txt +++ b/tools/Tools/CMakeLists.txt @@ -41,27 +41,49 @@ 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) + + 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) 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