Skip to content

Commit aeac8b5

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 c7cf5ad commit aeac8b5

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/CMakeLists.txt

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,23 @@ 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+
${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_global.c)
15+
16+
if (LINUX)
17+
set(BA_SOURCES ${BA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linux.c)
18+
elseif(WINDOWS)
19+
set(BA_SOURCES ${BA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_windows.c)
20+
elseif(MACOSX)
21+
set(BA_SOURCES ${BA_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/base_alloc/base_alloc_linux.c)
22+
endif()
23+
24+
set(BA_SOURCES ${BA_SOURCES} PARENT_SCOPE)
25+
1126
set(UMF_SOURCES
12-
base_alloc/base_alloc.c
13-
base_alloc/base_alloc_linear.c
14-
base_alloc/base_alloc_global.c
27+
${BA_SOURCES}
1528
memory_pool.c
1629
memory_provider.c
1730
memory_provider_get_last_failed.c
@@ -22,17 +35,14 @@ set(UMF_SOURCES
2235
)
2336

2437
set(UMF_SOURCES_LINUX
25-
base_alloc/base_alloc_linux.c
2638
libumf_linux.c
2739
)
2840

2941
set(UMF_SOURCES_WINDOWS
30-
base_alloc/base_alloc_windows.c
3142
libumf_windows.c
3243
)
3344

3445
set(UMF_SOURCES_MACOSX
35-
base_alloc/base_alloc_linux.c
3646
libumf_linux.c
3747
)
3848

test/CMakeLists.txt

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

0 commit comments

Comments
 (0)