Explorar o código

CMake: Build libraries with VERSION/SOVERSION

This takes advantage of SONAME and versioning on platforms that support it.
Sam Edwards %!s(int64=7) %!d(string=hai) anos
pai
achega
2f6c79b9e6
Modificáronse 2 ficheiros con 7 adicións e 0 borrados
  1. 1 0
      CMakeLists.txt
  2. 6 0
      cmake/macros/Versioning.cmake

+ 1 - 0
CMakeLists.txt

@@ -47,6 +47,7 @@ include(AddFlexTarget)      # Defines add_flex_target function
 include(CompositeSources)   # Defines composite_sources function
 include(Interrogate)        # Defines target_interrogate AND add_python_module
 include(RunPzip)            # Defines run_pzip function
+include(Versioning)         # Hooks 'add_library' to apply VERSION/SOVERSION
 
 # Add the include path for source and header files generated by CMake
 include_directories("${PROJECT_BINARY_DIR}/include")

+ 6 - 0
cmake/macros/Versioning.cmake

@@ -0,0 +1,6 @@
+function(add_library target_name)
+  _add_library("${target_name}" ${ARGN})
+  set_target_properties("${target_name}" PROPERTIES
+    VERSION "${PROJECT_VERSION}"
+    SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
+endfunction(add_library)