From 3f9c47524c4757684f13d23af40fc24d065424ad Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Wed, 10 Jan 2024 08:49:49 +0100 Subject: [PATCH] add shared option in cmake Signed-off-by: Uilian Ries --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ab84f0..1555caf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,7 @@ option(LIBCORO_BUILD_TESTS "Build the tests, Default=ON." ON) option(LIBCORO_CODE_COVERAGE "Enable code coverage, tests must also be enabled, Default=OFF" OFF) option(LIBCORO_BUILD_EXAMPLES "Build the examples, Default=ON." ON) option(LIBCORO_RUN_GITCONFIG "Set the githooks directory to auto format and update the readme, Default=OFF." OFF) +option(LIBCORO_BUILD_SHARED_LIBS "Build shared libraries, Default=OFF." OFF) # Set the githooks directory to auto format and update the readme. if (LIBCORO_RUN_GITCONFIG) @@ -38,6 +39,8 @@ message("${PROJECT_NAME} LIBCORO_BUILD_EXAMPLES = ${LIBCORO_BUILD_EXAMPLE message("${PROJECT_NAME} LIBCORO_FEATURE_PLATFORM = ${LIBCORO_FEATURE_PLATFORM}") message("${PROJECT_NAME} LIBCORO_FEATURE_NETWORKING = ${LIBCORO_FEATURE_NETWORKING}") message("${PROJECT_NAME} LIBCORO_FEATURE_TLS = ${LIBCORO_FEATURE_TLS}") +message("${PROJECT_NAME} LIBCORO_RUN_GITCONFIG = ${LIBCORO_RUN_GITCONFIG}") +message("${PROJECT_NAME} LIBCORO_BUILD_SHARED_LIBS = ${LIBCORO_BUILD_SHARED_LIBS}") if(LIBCORO_EXTERNAL_DEPENDENCIES) if(LIBCORO_FEATURE_NETWORKING) @@ -56,6 +59,8 @@ else() endif() endif() +set(BUILD_SHARED_LIBS ${LIBCORO_BUILD_SHARED_LIBS} CACHE INTERNAL "") + set(LIBCORO_SOURCE_FILES include/coro/concepts/awaitable.hpp include/coro/concepts/buffer.hpp @@ -130,7 +135,7 @@ if(DEFINED EMSCRIPTEN) add_link_options(-sEXIT_RUNTIME) endif() -add_library(${PROJECT_NAME} STATIC ${LIBCORO_SOURCE_FILES}) +add_library(${PROJECT_NAME} ${LIBCORO_SOURCE_FILES}) set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX PREFIX "") target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)