Skip to content

Commit 44fc9f7

Browse files
committed
Build base_alloc test with base_alloc sources
base_alloc is an internal compontent of umf and it's symbols should not be visible outside. This avoids error LNK2019: unresolved external symbol umf_ba_create errors on Windows.
1 parent 29d028a commit 44fc9f7

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/CMakeLists.txt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@ add_subdirectory(utils)
88

99
set(UMF_LIBS umf_utils)
1010

11+
set(BA_SOURCES
12+
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc.c
13+
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linear.c)
14+
15+
if (LINUX)
16+
set(BA_SOURCES ${BA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linux.c)
17+
elseif(WINDOWS)
18+
set(BA_SOURCES ${BA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_windows.c)
19+
elseif(MACOSX)
20+
set(BA_SOURCES ${BA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linux.c)
21+
endif()
22+
23+
set(BA_SOURCES ${BA_SOURCES} PARENT_SCOPE)
24+
1125
set(UMF_SOURCES
12-
base_alloc/base_alloc.c
13-
base_alloc/base_alloc_linear.c
26+
${BA_SOURCES}
1427
memory_pool.c
1528
memory_provider.c
1629
memory_provider_get_last_failed.c
@@ -21,17 +34,14 @@ set(UMF_SOURCES
2134
)
2235

2336
set(UMF_SOURCES_LINUX
24-
base_alloc/base_alloc_linux.c
2537
provider/provider_tracking_linux.c
2638
)
2739

2840
set(UMF_SOURCES_WINDOWS
29-
base_alloc/base_alloc_windows.c
3041
provider/provider_tracking_windows.c
3142
)
3243

3344
set(UMF_SOURCES_MACOSX
34-
base_alloc/base_alloc_linux.c
3545
provider/provider_tracking_linux.c
3646
)
3747

test/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ endif()
115115
if(LINUX)
116116
# the base_alloc test uses linux pthreads
117117
add_umf_test(NAME base_alloc
118-
SRCS test_base_alloc.c
118+
SRCS ${BA_SOURCES} test_base_alloc.c
119119
LIBS umf_utils)
120120
add_umf_test(NAME base_alloc_linear
121-
SRCS test_base_alloc_linear.c
121+
SRCS ${BA_SOURCES} test_base_alloc_linear.c
122122
LIBS umf_utils)
123123
endif()

0 commit comments

Comments
 (0)