Skip to content

Commit

Permalink
Fix dynamic linking by VS (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatolyKalin authored Aug 31, 2023
1 parent d049b89 commit f970a11
Show file tree
Hide file tree
Showing 67 changed files with 399 additions and 292 deletions.
17 changes: 10 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ jobs:
if: ${{ contains(matrix.os, 'macos') }}
run: sudo xcode-select -s '/Applications/Xcode_${{env.XCODE_VERSION}}.app/Contents/Developer'

- name: Select gcc version
if: ${{ contains(matrix.os, 'ubuntu') }}
run: |
export CC=gcc-${{env.GCC_VERSION}}
export CXX=g++-${{env.GCC_VERSION}}
- name: Prepare build
run: |
ls
mkdir ${{github.workspace}}/build
- name: Configure CMake
- name: Configure CMake (!Ubuntu)
if: ${{ !contains(matrix.os, 'ubuntu') }}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}

- name: Configure CMake (Ubuntu)
env:
CC: gcc-${{env.GCC_VERSION}}
CXX: g++-${{env.GCC_VERSION}}
if: ${{ contains(matrix.os, 'ubuntu') }}
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}


- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

Expand Down
25 changes: 13 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- id: get_latest_tag
run: |
echo "tag=$(git describe --abbrev=0 --tags)" >> $GITHUB_OUTPUT
- id: set_version
run: |
if [[ "${{ !inputs.use_latest_tag && startsWith(github.ref, 'refs/tags/') }}" == "true" ]]
Expand All @@ -43,10 +43,10 @@ jobs:
echo "version=${{ steps.get_latest_tag.outputs.tag }}" >> $GITHUB_OUTPUT
echo "tag_name=${{ format('refs/tags/{0}', steps.get_latest_tag.outputs.tag) }}" >> $GITHUB_OUTPUT
fi
build_package_and_upload:
name: Build, Package & Upload
needs: [get_version]
needs: [ get_version ]
strategy:
matrix:
# os: [windows-latest, macos-latest, ubuntu-latest]
Expand All @@ -66,12 +66,6 @@ jobs:
if: ${{ contains(matrix.os, 'macos') }}
run: sudo xcode-select -s '/Applications/Xcode_${{env.XCODE_VERSION}}.app/Contents/Developer'

- name: Select gcc version
if: ${{ contains(matrix.os, 'ubuntu') }}
run: |
export CC=gcc-${{env.GCC_VERSION}}
export CXX=g++-${{env.GCC_VERSION}}
- name: Prepare build
run: |
ls
Expand All @@ -81,8 +75,15 @@ jobs:
if: ${{ contains(matrix.os, 'windows') }}
run: cmake -B ${{github.workspace}}/build-${{matrix.buildType}} -DCMAKE_BUILD_TYPE=${{matrix.buildType}} -DDXFCXX_VERSION="${{needs.get_version.outputs.version}}" -DDXFCXX_PACKAGE_SUFFIX="-${{matrix.buildType}}"

- name: Configure CMake (!Win)
if: ${{ !contains(matrix.os, 'windows') }}
- name: Configure CMake (MacOS)
if: ${{ contains(matrix.os, 'macos') }}
run: cmake -B ${{github.workspace}}/build-${{matrix.buildType}} -DCMAKE_BUILD_TYPE=${{matrix.buildType}} -DDXFCXX_VERSION=${{needs.get_version.outputs.version}} -DDXFCXX_PACKAGE_SUFFIX=-${{matrix.buildType}}

- name: Configure CMake (Ubuntu)
env:
CC: gcc-${{env.GCC_VERSION}}
CXX: g++-${{env.GCC_VERSION}}
if: ${{ contains(matrix.os, 'ubuntu') }}
run: cmake -B ${{github.workspace}}/build-${{matrix.buildType}} -DCMAKE_BUILD_TYPE=${{matrix.buildType}} -DDXFCXX_VERSION=${{needs.get_version.outputs.version}} -DDXFCXX_PACKAGE_SUFFIX=-${{matrix.buildType}}

- name: Build
Expand All @@ -102,7 +103,7 @@ jobs:
if: ${{ inputs.publish || contains(github.event_name, 'push')}}
runs-on: ubuntu-latest
name: Publish Release
needs: [get_version, build_package_and_upload]
needs: [ get_version, build_package_and_upload ]
permissions:
contents: write
steps:
Expand Down
90 changes: 70 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(DXFEED_GRAAL_NATIVE_SDK_JFROG_BASE_URL "https://dxfeed.jfrog.io/artifactory/

option(DXFCXX_ENABLE_ASAN_UBSAN "Enable address, UB sanitizers etc" OFF)
option(DXFCXX_ENABLE_VS_ASAN "Enable VS address sanitizer" OFF)
option(DXFCXX_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)

include(FetchContent)

Expand Down Expand Up @@ -94,45 +95,45 @@ set(dxFeedNativeAPIInternalSources
src/internal/EventClassList.cpp
src/internal/SymbolList.cpp
src/internal/Common.cpp
)
)

set(dxFeedNativeAPIInternalUtilsSources
src/internal/utils/StringUtils.cpp
)
)

set(dxFeedNativeAPIInternalUtilsDebugSources
src/internal/utils/debug/Debug.cpp
)
)

set(dxFeedNativeAPIAPISources
src/api/DXEndpoint.cpp
src/api/DXFeed.cpp
src/api/DXFeedSubscription.cpp
src/api/DXPublisher.cpp
)
)

set(dxFeedNativeAPIAPIOsubSources
src/api/osub/WildcardSymbol.cpp
src/api/osub/TimeSeriesSubscriptionSymbol.cpp
src/api/osub/IndexedEventSubscriptionSymbol.cpp
)
)

set(dxFeedNativeAPISymbolsSources
src/symbols/StringSymbol.cpp
src/symbols/SymbolWrapper.cpp
)
)

set(dxFeedNativeAPISystemSources
src/system/System.cpp
)
)

set(dxFeedNativeAPIEventSources
src/event/EventTypeEnum.cpp
src/event/IndexedEventSource.cpp
src/event/EventFlag.cpp
src/event/IndexedEvent.cpp
src/event/EventMapper.cpp
)
)

set(dxFeedNativeAPIEventCandleSources
src/event/candle/Candle.cpp
Expand All @@ -144,7 +145,7 @@ set(dxFeedNativeAPIEventCandleSources
src/event/candle/CandleType.cpp
src/event/candle/CandleSession.cpp
src/event/candle/CandleSymbol.cpp
)
)

set(dxFeedNativeAPIEventMarketSources
src/event/market/AnalyticOrder.cpp
Expand All @@ -170,19 +171,19 @@ set(dxFeedNativeAPIEventMarketSources
src/event/market/TradeBase.cpp
src/event/market/TradeETH.cpp
src/event/market/TradingStatus.cpp
)
)

set(dxFeedNativeAPIEventOptionSources
src/event/option/Greeks.cpp
src/event/option/Underlying.cpp
src/event/option/TheoPrice.cpp
src/event/option/Series.cpp
)
)

set(dxFeedNativeAPIScheduleSources
src/schedule/SessionFilter.cpp
src/schedule/SessionType.cpp
)
)

if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_MACOSX_RPATH ON)
Expand Down Expand Up @@ -213,7 +214,7 @@ add_library(${PROJECT_NAME}_static STATIC
${dxFeedNativeAPIEventOptionSources}
${dxFeedNativeAPIScheduleSources}
src/api.cpp
)
)

add_library(${PROJECT_NAME} SHARED
${dxFeedNativeAPIInternalSources}
Expand All @@ -229,29 +230,78 @@ add_library(${PROJECT_NAME} SHARED
${dxFeedNativeAPIEventOptionSources}
${dxFeedNativeAPIScheduleSources}
src/api.cpp
)
)

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)

add_library(${PROJECT_NAME}_CompilerOptions INTERFACE)

target_include_directories(${PROJECT_NAME}_static PUBLIC include)
target_compile_definitions(${PROJECT_NAME}_static PRIVATE
FMT_HEADER_ONLY=1)
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_compile_definitions(${PROJECT_NAME} PRIVATE
DXFCPP_USE_DLLS LIBDXFCPP_EXPORTS FMT_HEADER_ONLY=1)

target_link_libraries(${PROJECT_NAME}_static PUBLIC DxFeedGraalNativeSdk utf8cpp fmt::fmt-header-only PUBLIC ${PROJECT_NAME}_CompilerOptions)
target_link_libraries(${PROJECT_NAME} PUBLIC DxFeedGraalNativeSdk utf8cpp fmt::fmt-header-only PUBLIC ${PROJECT_NAME}_CompilerOptions)
target_compile_options(${PROJECT_NAME}
PUBLIC
$<$<COMPILE_LANG_AND_ID:C,CXX,MSVC>:
/W2
>
)

target_compile_options(${PROJECT_NAME}_static
PUBLIC
$<$<COMPILE_LANG_AND_ID:C,CXX,MSVC>:
/W2
>
)

target_compile_options(${PROJECT_NAME}
PUBLIC
$<$<COMPILE_LANG_AND_ID:C,CXX,GNU,Clang,AppleClang,Intel>:
-fPIC
-Wall
-Wextra
-pedantic
>
)

target_link_options(${PROJECT_NAME}
PUBLIC
$<$<COMPILE_LANG_AND_ID:C,CXX,GNU,Clang,AppleClang,Intel>:
-fPIC
>)

target_compile_options(${PROJECT_NAME}_static
PUBLIC
$<$<COMPILE_LANG_AND_ID:C,CXX,GNU,Clang,AppleClang,Intel>:
-fPIC
-Wall
-Wextra
-pedantic
>
)

target_link_options(${PROJECT_NAME}_static
PUBLIC
$<$<COMPILE_LANG_AND_ID:C,CXX,GNU,Clang,AppleClang,Intel>:
-fPIC
>)

if (DXFCXX_USE_PRECOMPILED_HEADERS)
target_precompile_headers(${PROJECT_NAME} PRIVATE include/dxfeed_graal_cpp_api/internal/PrecompiledHeaders.hpp)
target_precompile_headers(${PROJECT_NAME}_static PRIVATE include/dxfeed_graal_cpp_api/internal/PrecompiledHeaders.hpp)
endif ()

target_link_libraries(${PROJECT_NAME}_static PUBLIC DxFeedGraalNativeSdk utf8cpp fmt::fmt-header-only)
target_link_libraries(${PROJECT_NAME} PUBLIC DxFeedGraalNativeSdk utf8cpp fmt::fmt-header-only)

if (DXFCXX_ENABLE_ASAN_UBSAN)
target_compile_options(${PROJECT_NAME} PRIVATE "-fsanitize=address" "-fsanitize=undefined" "-fPIC")
target_link_options(${PROJECT_NAME} PRIVATE "-fsanitize=address" "-fsanitize=undefined" "-fPIC")
target_compile_options(${PROJECT_NAME} PRIVATE "-fsanitize=address" "-fsanitize=undefined")
target_link_options(${PROJECT_NAME} PRIVATE "-fsanitize=address" "-fsanitize=undefined")
target_link_libraries(${PROJECT_NAME} PUBLIC asan ubsan)
endif ()

Expand Down
4 changes: 2 additions & 2 deletions include/dxfeed_graal_cpp_api/api/ApiModule.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

#include "../internal/Conf.hpp"

#include "osub/OsubModule.hpp"
#include "DXEndpoint.hpp"
#include "DXFeed.hpp"
#include "DXFeedSubscription.hpp"
#include "DXPublisher.hpp"
#include "FilteredSubscriptionSymbol.hpp"
#include "FilteredSubscriptionSymbol.hpp"
#include "osub/OsubModule.hpp"
Loading

0 comments on commit f970a11

Please sign in to comment.