diff options
author | José Fonseca <jfonseca@vmware.com> | 2014-06-25 13:46:35 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2014-06-25 13:46:35 +0100 |
commit | c56b9acc6abcae465b916f6ebafa3a282d1f36fc (patch) | |
tree | a4a0a04879c4b48f23eddc33fb58ba8396143dd7 /cmake | |
parent | e11baf1cb0a60855c975374890c497e3e5bbe4ab (diff) |
cmake: Refactor all convenience library generation into a function.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/ConvenienceLibrary.cmake | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cmake/ConvenienceLibrary.cmake b/cmake/ConvenienceLibrary.cmake new file mode 100644 index 00000000..bf18b381 --- /dev/null +++ b/cmake/ConvenienceLibrary.cmake @@ -0,0 +1,19 @@ +# Function for convenience libraries, ie., libraries which can be statically +# linked into shared libraries. +function (add_convenience_library) + + set (name "${ARGV0}") + list (REMOVE_AT ARGV 0) + + add_library ("${name}" STATIC ${ARGV}) + + if (NOT "${CMAKE_SHARED_LIBRARY_C_FLAGS}" STREQUAL "${CMAKE_SHARED_LIBRARY_CXX_FLAGS}") + message (FATAL_ERROR "CMAKE_SHARED_LIBRARY_C_FLAGS (${CMAKE_SHARED_LIBRARY_C_FLAGS}) != CMAKE_SHARED_LIBRARY_CXX_FLAGS (${CMAKE_SHARED_LIBRARY_CXX_FLAGS})") + endif () + + set_target_properties ("${name}" PROPERTIES + # Ensure it can be statically linked in shared libraries + COMPILE_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}" + ) + +endfunction () |