$NetBSD$

On Darwin, don't build as a framework.
Add NetBSD support.

--- CMakeLists.txt.orig	2022-11-23 19:53:55.000000000 +0000
+++ CMakeLists.txt
@@ -1,7 +1,6 @@
 cmake_minimum_required(VERSION 3.5)
 
 # silence RPATH cmake warning
-set(CMAKE_MACOSX_RPATH 1)
 set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
 
 
@@ -357,14 +356,14 @@ endif()
 
 # Set plugins install directory
 if(USE_DOUBLE)
-    if(APPLE)
+    if(FALSE)
         set(CSOUNDLIB "CsoundLib64")
         set(PLUGIN_INSTALL_DIR "${CS_FRAMEWORK_DEST}/${CSOUNDLIB}.framework/Versions/${APIVERSION}/Resources/Opcodes64")
     else()
         set(CSOUNDLIB "csound64")
     endif()
 else()
-    if(APPLE)
+    if(FALSE)
         set(CSOUNDLIB "CsoundLib")
         set(PLUGIN_INSTALL_DIR "${CS_FRAMEWORK_DEST}/${CSOUNDLIB}.framework/Versions/${APIVERSION}/Resources/Opcodes")
     else()
@@ -373,7 +372,7 @@ else()
 endif()
 
 # set default user plugin directory
-if(APPLE)
+if(FALSE)
     if(BUILD_INSTALLER)
        	set(CS_FRAMEWORK_FULL_PATH "/Library/Frameworks/${CSOUNDLIB}.framework/Versions/${APIVERSION}/Resources/Opcodes64")
     else()
@@ -395,6 +394,12 @@ if(APPLE)
     add_definitions("-DCS_DEFAULT_USER_PLUGINDIR=\"${DEFAULT_USER_PLUGINDIR}\"")
 endif()
 
+if(CMAKE_SYSTEM_NAME MATCHES "NetBSD")
+     set(NETBSD YES)
+else()
+     set(NETBSD NO)
+endif()
+
 # LINUX definition
 if(CMAKE_SYSTEM_NAME MATCHES "Linux")
     set(LINUX YES)
@@ -405,7 +410,7 @@ endif()
 
 
 
-if(LINUX)
+if(UNIX)
     set(DEFAULT_OPCODEDIR "${PLUGIN_INSTALL_DIR}")
     add_definitions("-DCS_DEFAULT_PLUGINDIR=\"${DEFAULT_OPCODEDIR}\"")
     # dir relative to $HOME
@@ -1112,7 +1117,7 @@ if(INIT_STATIC_MODULES)
     set_target_properties(${CSOUNDLIB} PROPERTIES COMPILE_FLAGS "-DINIT_STATIC_MODULES")
 endif()
 
-if(APPLE)
+if(FALSE)
     set_target_properties(${CSOUNDLIB} PROPERTIES FRAMEWORK YES)
     set_target_properties(${CSOUNDLIB} PROPERTIES FRAMEWORK_VERSION "${APIVERSION}")
     set_target_properties(${CSOUNDLIB} PROPERTIES PUBLIC_HEADER
@@ -1145,6 +1150,7 @@ function(make_plugin libname srcs)
     endwhile()
 
     set_target_properties(${libname} PROPERTIES
+        INSTALL_NAME_DIR "${PLUGIN_INSTALL_DIR}"
         RUNTIME_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR}
         LIBRARY_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR}
         ARCHIVE_OUTPUT_DIRECTORY ${BUILD_PLUGINS_DIR})
@@ -1230,7 +1236,9 @@ if(LINUX)
       list(APPEND libcsound_LIBS ${LIBRT_LIBRARY})
       message(STATUS "  ADDING LIBRT LIBRARY: ${LIBRT_LIBRARY}.")
     endif()
+endif()
 
+if(LINUX OR NETBSD)
     find_library(LIBEXECINFO_LIBRARY execinfo)
 
     if(LIBEXECINFO_LIBRARY)
