From 6048802decaf0e2d2888a4497d757cba0c2f7989 Mon Sep 17 00:00:00 2001 From: Peter M. Groen Date: Thu, 21 Apr 2022 15:31:36 +0200 Subject: [PATCH] Add switch for building a shared or static library --- library.cmake | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/library.cmake b/library.cmake index 1afa245..8e07552 100644 --- a/library.cmake +++ b/library.cmake @@ -1,5 +1,5 @@ -# @brief Adds a single shared library target and performs related actions, -# such as target properties, hsoa versioning, and some packaging variables. +# @brief Adds a single shared or static library target and performs related actions, +# such as target properties and some packaging variables. # @note The default binary directory is CMAKE_BINARY_DIR, but can be overridden by specifying the ${PROJECT_NAME}_CURRENT_BINARY_DIR. function(add_libraries) @@ -12,10 +12,17 @@ if (${PROJECT_NAME}_CURRENT_BINARY_DIR) endif() message(STATUS "CURRENT_PROJECT_BINARY_DIR : ${CURRENT_PROJECT_BINARY_DIR}") -include_directories(${HSOA_VERSION_INCLUDE_DIR}) +if(DEFINED ${BUILD_STATIC}) + if(${BUILD_STATIC} STREQUAL "ON") + set(SHARED_OR_STATIC "STATIC") + else() + set(SHARED_OR_STATIC "SHARED") + endif() +else() + set(SHARED_OR_STATIC "SHARED") +endif() -add_library( ${PROJECT_NAME} SHARED - ${HSOA_VERSION_SRC_FILE} +add_library( ${PROJECT_NAME} ${SHARED_OR_STATIC} ${SRC_LIST} ) @@ -28,7 +35,7 @@ set_target_properties( ${PROJECT_NAME} VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR} LIBRARY_OUTPUT_DIRECTORY ${CURRENT_PROJECT_BINARY_DIR}/lib - ARCHIVE_OUTPUT_DIRECTORY ${CURRENT_PROJECT_BINARY_DIR}/archive + ARCHIVE_OUTPUT_DIRECTORY ${CURRENT_PROJECT_BINARY_DIR}/lib ) endfunction() -- libgit2 0.21.4