Skip to content

[MDAPI-246][С++] Build a project with statically linked runtime libraries. #78

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}
Expand Down Expand Up @@ -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: >
Expand All @@ -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
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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: >
Expand Down Expand Up @@ -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: |
Expand All @@ -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
Expand All @@ -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
Expand Down
38 changes: 36 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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$<$<CONFIG:Debug>: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 ()
Expand Down Expand Up @@ -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$<$<CONFIG:Debug>: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
Expand Down
26 changes: 23 additions & 3 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading
Loading