Set the API export symbols based on CMake BUILD_SHARED_LIBS

By default poly2tri is built as a static library.
This commit is contained in:
Pierre Dejoue 2022-04-20 22:12:21 +02:00
parent 7f5846b72d
commit 49a12eb378

View File

@ -11,6 +11,13 @@ file(GLOB HEADERS poly2tri/*.h poly2tri/common/*.h poly2tri/sweep/*.h)
add_library(poly2tri ${SOURCES} ${HEADERS})
target_include_directories(poly2tri INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
get_target_property(poly2tri_target_type poly2tri TYPE)
if(poly2tri_target_type STREQUAL SHARED_LIBRARY)
target_compile_definitions(poly2tri PRIVATE P2T_SHARED_EXPORTS)
else()
target_compile_definitions(poly2tri PUBLIC P2T_STATIC_EXPORTS)
endif()
if(P2T_BUILD_TESTS)
enable_testing()
add_subdirectory(unittest)