Skip to content
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

Fix build with BUILD_SHARED_LIBS=ON #132

Merged
merged 5 commits into from
Mar 30, 2022
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
16 changes: 11 additions & 5 deletions .github/workflows/feature_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
- gcc5
- clang10
- clang40
sharedlibs: [OFF, ON]

runs-on: ubuntu-latest
container:
Expand All @@ -29,7 +30,7 @@ jobs:

- name: Configure
working-directory: build/
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}}
- name: Build
working-directory: build/
run: cmake --build . --config Debug
Expand All @@ -42,6 +43,7 @@ jobs:
fail-fast: false
matrix:
xcode: ['11', '13']
sharedlibs: [OFF, ON]

runs-on: macos-latest

Expand All @@ -55,7 +57,7 @@ jobs:

- name: Configure
working-directory: build/
run: cmake $GITHUB_WORKSPACE
run: cmake $GITHUB_WORKSPACE -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}}
- name: Build
working-directory: build/
run: cmake --build .
Expand All @@ -64,17 +66,21 @@ jobs:
run: ctest --output-on-failure

windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
sharedlibs: [OFF, ON]

runs-on: windows-2019

steps:
- uses: actions/checkout@v2
- name: Create Build Environment
run: cmake -E make_directory build

- name: Configure
shell: bash
working-directory: build/
run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019"
run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019" -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}}
- name: Build
working-directory: build/
run: cmake --build . --config Debug
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/main_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- clang50
- clang40
build_type: [Debug, Release]
sharedlibs: [OFF, ON]

runs-on: ubuntu-latest
container:
Expand All @@ -35,10 +36,9 @@ jobs:
- uses: actions/checkout@v2
- name: Create Build Environment
run: cmake -E make_directory build

- name: Configure
working-directory: build/
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}}
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=${{matrix.build_type}} -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}}
- name: Build
working-directory: build/
run: cmake --build . --config ${{matrix.build_type}}
Expand All @@ -54,6 +54,7 @@ jobs:
- '11'
- '12'
- '13'
sharedlibs: [OFF, ON]

runs-on: macos-latest

Expand All @@ -64,10 +65,9 @@ jobs:
xcode-version: ${{matrix.xcode}}
- name: Create Build Environment
run: cmake -E make_directory build

- name: Configure
working-directory: build/
run: cmake $GITHUB_WORKSPACE
run: cmake $GITHUB_WORKSPACE -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}}
- name: Build
working-directory: build/
run: cmake --build .
Expand All @@ -80,18 +80,18 @@ jobs:
fail-fast: false
matrix:
build_type: [Debug, Release]
sharedlibs: [OFF, ON]

runs-on: windows-latest
runs-on: windows-2019

steps:
- uses: actions/checkout@v2
- name: Create Build Environment
run: cmake -E make_directory build

- name: Configure
shell: bash
working-directory: build/
run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019"
run: cmake $GITHUB_WORKSPACE -G"Visual Studio 16 2019" -DBUILD_SHARED_LIBS=${{matrix.sharedlibs}}
- name: Build
working-directory: build/
run: cmake --build . --config ${{matrix.build_type}}
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ elseif(WIN32)
set(FOONATHAN_MEMORY_CMAKE_CONFIG_INSTALL_DIR "share/foonathan_memory/cmake")
set(FOONATHAN_MEMORY_ADDITIONAL_FILES_INSTALL_DIR "share/foonathan_memory")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
else()
message(FATAL_ERROR "Could not set install folders for this platform!")
endif()
Expand Down
7 changes: 7 additions & 0 deletions include/foonathan/memory/virtual_memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,15 @@ namespace foonathan
/// All virtual memory allocations must be multiple of this size.
/// It is usually 4KiB.
/// \ingroup allocator
/// \deprecated use \ref get_virtual_memory_page_size instead.
extern const std::size_t virtual_memory_page_size;

/// \returns the page size of the virtual memory.
/// All virtual memory allocations must be multiple of this size.
/// It is usually 4KiB.
/// \ingroup allocator
std::size_t get_virtual_memory_page_size() noexcept;

/// Reserves virtual memory.
/// \effects Reserves the given number of pages.
/// Each page is \ref virtual_memory_page_size big.
Expand Down
5 changes: 5 additions & 0 deletions src/virtual_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ void foonathan::memory::virtual_memory_decommit(void* memory, std::size_t no_pag
#warning "virtual memory functions not available on your platform, define your own"
#endif

std::size_t foonathan::memory::get_virtual_memory_page_size() noexcept
{
return virtual_memory_page_size;
}

namespace
{
std::size_t calc_no_pages(std::size_t size) noexcept
Expand Down
2 changes: 1 addition & 1 deletion test/default_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,5 @@ TEST_CASE("static_allocator")
TEST_CASE("virtual_memory_allocator")
{
virtual_memory_allocator alloc;
check_default_allocator(alloc, virtual_memory_page_size);
check_default_allocator(alloc, get_virtual_memory_page_size());
}