Commit 6048802decaf0e2d2888a4497d757cba0c2f7989
1 parent
586e5e7b
Add switch for building a shared or static library
Showing
1 changed file
with
13 additions
and
6 deletions
library.cmake
1 | -# @brief Adds a single shared library target and performs related actions, | ||
2 | -# such as target properties, hsoa versioning, and some packaging variables. | 1 | +# @brief Adds a single shared or static library target and performs related actions, |
2 | +# such as target properties and some packaging variables. | ||
3 | # @note The default binary directory is CMAKE_BINARY_DIR, but can be overridden by specifying the ${PROJECT_NAME}_CURRENT_BINARY_DIR. | 3 | # @note The default binary directory is CMAKE_BINARY_DIR, but can be overridden by specifying the ${PROJECT_NAME}_CURRENT_BINARY_DIR. |
4 | function(add_libraries) | 4 | function(add_libraries) |
5 | 5 | ||
@@ -12,10 +12,17 @@ if (${PROJECT_NAME}_CURRENT_BINARY_DIR) | @@ -12,10 +12,17 @@ if (${PROJECT_NAME}_CURRENT_BINARY_DIR) | ||
12 | endif() | 12 | endif() |
13 | message(STATUS "CURRENT_PROJECT_BINARY_DIR : ${CURRENT_PROJECT_BINARY_DIR}") | 13 | message(STATUS "CURRENT_PROJECT_BINARY_DIR : ${CURRENT_PROJECT_BINARY_DIR}") |
14 | 14 | ||
15 | -include_directories(${HSOA_VERSION_INCLUDE_DIR}) | 15 | +if(DEFINED ${BUILD_STATIC}) |
16 | + if(${BUILD_STATIC} STREQUAL "ON") | ||
17 | + set(SHARED_OR_STATIC "STATIC") | ||
18 | + else() | ||
19 | + set(SHARED_OR_STATIC "SHARED") | ||
20 | + endif() | ||
21 | +else() | ||
22 | + set(SHARED_OR_STATIC "SHARED") | ||
23 | +endif() | ||
16 | 24 | ||
17 | -add_library( ${PROJECT_NAME} SHARED | ||
18 | - ${HSOA_VERSION_SRC_FILE} | 25 | +add_library( ${PROJECT_NAME} ${SHARED_OR_STATIC} |
19 | ${SRC_LIST} | 26 | ${SRC_LIST} |
20 | ) | 27 | ) |
21 | 28 | ||
@@ -28,7 +35,7 @@ set_target_properties( ${PROJECT_NAME} | @@ -28,7 +35,7 @@ set_target_properties( ${PROJECT_NAME} | ||
28 | VERSION ${PROJECT_VERSION} | 35 | VERSION ${PROJECT_VERSION} |
29 | SOVERSION ${PROJECT_VERSION_MAJOR} | 36 | SOVERSION ${PROJECT_VERSION_MAJOR} |
30 | LIBRARY_OUTPUT_DIRECTORY ${CURRENT_PROJECT_BINARY_DIR}/lib | 37 | LIBRARY_OUTPUT_DIRECTORY ${CURRENT_PROJECT_BINARY_DIR}/lib |
31 | - ARCHIVE_OUTPUT_DIRECTORY ${CURRENT_PROJECT_BINARY_DIR}/archive | 38 | + ARCHIVE_OUTPUT_DIRECTORY ${CURRENT_PROJECT_BINARY_DIR}/lib |
32 | ) | 39 | ) |
33 | 40 | ||
34 | endfunction() | 41 | endfunction() |