about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/c-ares
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-12-06 19:57:55 +0000
committerAlyssa Ross <hi@alyssa.is>2023-02-08 13:48:30 +0000
commitbf3aadfdd39aa197e18bade671fab6726349ffa4 (patch)
tree698567af766ed441d757b57a7b21e68d4a342a2b /nixpkgs/pkgs/development/libraries/c-ares
parentf4afc5a01d9539ce09e47494e679c51f80723d07 (diff)
parent99665eb45f58d959d2cb9e49ddb960c79d596f33 (diff)
downloadnixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.gz
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.bz2
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.lz
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.xz
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.tar.zst
nixlib-bf3aadfdd39aa197e18bade671fab6726349ffa4.zip
Merge commit '99665eb45f58d959d2cb9e49ddb960c79d596f33'
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/c-ares')
-rw-r--r--nixpkgs/pkgs/development/libraries/c-ares/default.nix18
1 files changed, 11 insertions, 7 deletions
diff --git a/nixpkgs/pkgs/development/libraries/c-ares/default.nix b/nixpkgs/pkgs/development/libraries/c-ares/default.nix
index b133f9867d32..a5a41813bc3e 100644
--- a/nixpkgs/pkgs/development/libraries/c-ares/default.nix
+++ b/nixpkgs/pkgs/development/libraries/c-ares/default.nix
@@ -25,13 +25,17 @@ stdenv.mkDerivation rec {
   };
 
   # Adapted from running a cmake build
-  passthru.cmake-config = writeTextDir "c-ares-config.cmake"
+  passthru.cmake-config = let
+    extension = if stdenv.hostPlatform.isStatic then ".a" else stdenv.hostPlatform.extensions.sharedLibrary;
+    buildType = if stdenv.hostPlatform.isStatic then "STATIC" else "SHARED";
+    buildTypeLower = if stdenv.hostPlatform.isStatic then "static" else "shared";
+    in writeTextDir "c-ares-config.cmake"
     ''
       set(c-ares_INCLUDE_DIR "${self}/include")
 
       set(c-ares_LIBRARY c-ares::cares)
 
-      add_library(c-ares::cares SHARED IMPORTED)
+      add_library(c-ares::cares ${buildType} IMPORTED)
 
       set_target_properties(c-ares::cares PROPERTIES
         INTERFACE_INCLUDE_DIRECTORIES "${self}/include"
@@ -39,12 +43,12 @@ stdenv.mkDerivation rec {
       )
       set_property(TARGET c-ares::cares APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
       set_target_properties(c-ares::cares PROPERTIES
-        IMPORTED_LOCATION_RELEASE "${self}/lib/libcares${stdenv.targetPlatform.extensions.sharedLibrary}"
-        IMPORTED_SONAME_RELEASE "libcares${stdenv.targetPlatform.extensions.sharedLibrary}"
+        IMPORTED_LOCATION_RELEASE "${self}/lib/libcares${extension}"
+        IMPORTED_SONAME_RELEASE "libcares${extension}"
         )
-      add_library(c-ares::cares_shared INTERFACE IMPORTED)
-      set_target_properties(c-ares::cares_shared PROPERTIES INTERFACE_LINK_LIBRARIES "c-ares::cares")
-      set(c-ares_SHARED_LIBRARY c-ares::cares_shared)
+      add_library(c-ares::cares_${buildTypeLower} INTERFACE IMPORTED)
+      set_target_properties(c-ares::cares_${buildTypeLower} PROPERTIES INTERFACE_LINK_LIBRARIES "c-ares::cares")
+      set(c-ares_${buildType}_LIBRARY c-ares::cares_${buildTypeLower})
     '';
 
 }; in self