From 7b100a7f36f38b20c44ae6c5b3b2398f97121fad Mon Sep 17 00:00:00 2001 From: Jesse Date: Sun, 22 Aug 2021 13:59:48 -0400 Subject: [PATCH] Cmake: Add BUILD_SHARED_LIBS option As of now there is no way to make a static build of the library. This adds a BUILD_SHARED_LIBS option to allow for only shared build or both shared and static builds. --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4927020..383b355 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,15 @@ else() endif() ## Add serial library +set(WJWSERIAL_BUILD_SHARED "ON" CACHE BOOL "Only build the shared version.") + +if(WJWSERIAL_BUILD_SHARED) add_library(${PROJECT_NAME} ${serial_SRCS}) +else() +add_library(${PROJECT_NAME} ${serial_SRCS}) +add_library(${PROJECT_NAME}_static STATIC ${serial_SRCS}) +endif() + if(APPLE) target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARY} ${IOKIT_LIBRARY}) elseif(UNIX)