Skip to content

Commit 02481ec

Browse files
committed
Add test export interface
1 parent 8d9b9b1 commit 02481ec

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ target_compile_definitions(scratchcpp PRIVATE LIBSCRATCHCPP_VERSION_MINOR=${PROJ
139139
target_compile_definitions(scratchcpp PRIVATE LIBSCRATCHCPP_VERSION_PATCH=${PROJECT_VERSION_PATCH})
140140

141141
# Unit tests
142+
target_link_libraries(scratchcpp PRIVATE scratchcpp-test-export)
143+
142144
if (LIBSCRATCHCPP_BUILD_UNIT_TESTS)
145+
target_compile_definitions(scratchcpp PRIVATE LIBSCRATCHCPP_TEST)
146+
143147
enable_testing()
144148
add_subdirectory(test)
145149
endif()

src/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ target_sources(scratchcpp
1111
rect_p.h
1212
)
1313

14+
add_library(scratchcpp-test-export
15+
INTERFACE
16+
test_export.h
17+
)
18+
19+
target_include_directories(scratchcpp-test-export INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
20+
1421
add_subdirectory(blocks)
1522
add_subdirectory(engine)
1623
add_subdirectory(internal)

src/test_export.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
#pragma once
4+
5+
#ifdef LIBSCRATCHCPP_TEST
6+
#if defined(_MSC_VER) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
7+
#define LIBSCRATCHCPP_TEST_EXPORT __declspec(dllexport)
8+
#else
9+
#define LIBSCRATCHCPP_TEST_EXPORT __attribute__((visibility("default")))
10+
#endif
11+
#else
12+
#define LIBSCRATCHCPP_TEST_EXPORT
13+
#endif

0 commit comments

Comments
 (0)