Index: portmidi/pm_common/CMakeLists.txt
===================================================================
--- portmidi.orig/pm_common/CMakeLists.txt
+++ portmidi/pm_common/CMakeLists.txt
@@ -120,8 +120,8 @@ set_target_properties(pmjni PROPERTIES E
 # install the libraries (Linux and Mac OS X command line)
 if(UNIX)
   INSTALL(TARGETS portmidi-static pmjni
-    LIBRARY DESTINATION /usr/local/lib
-    ARCHIVE DESTINATION /usr/local/lib)
+    LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+    ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
 # .h files installed by pm_dylib/CMakeLists.txt, so don't need them here
 #  INSTALL(FILES portmidi.h ../porttime/porttime.h
 #    DESTINATION /usr/local/include)
Index: portmidi/pm_dylib/CMakeLists.txt
===================================================================
--- portmidi.orig/pm_dylib/CMakeLists.txt
+++ portmidi/pm_dylib/CMakeLists.txt
@@ -59,7 +59,7 @@ if(UNIX)
 
     set(JAVAVM_LIB "${FRAMEWORK_PATH}/JavaVM.framework")
     set(JAVA_INCLUDE_PATHS ${JAVAVM_LIB}/Headers)
-    set(INSTALL_NAME_DIR "/usr/local/lib")
+    set(INSTALL_NAME_DIR ${LIB_INSTALL_DIR})
     message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
   else(APPLE)
     # LINUX settings...
@@ -75,11 +75,7 @@ if(UNIX)
     # JAVA_INCLUDE_PATH2; if no, then we need to make both JAVA_INCLUDE_PATH
     # and JAVA_INCLUDE_PATH2 set by user (will need clear documentation
     # because JAVA_INCLUDE_PATH2 is pretty obscure)
-    set(JAVA_INCLUDE_PATH  ${JAVA_INCLUDE_PATH-UNKNOWN}
-        CACHE STRING "where to find Java SDK include directory")
-    set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH}/linux)
-    # libjvm.so is found relative to JAVA_INCLUDE_PATH:
-    set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../jre/lib/i386/client/libjvm.so)
+    set(JAVAVM_LIB ${JAVA_JVM_LIBRARY})
 
     set(LINUXSRC pmlinuxalsa pmlinux finddefault)
     prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
@@ -114,14 +110,14 @@ prepend_path(SHARED_PATHS ../pm_common/
 list(APPEND LIBSRC ${SHARED_PATHS})
 
 add_library(portmidi-dynamic SHARED ${LIBSRC})
-set_target_properties(portmidi-dynamic PROPERTIES OUTPUT_NAME "portmidi")
+set_target_properties(portmidi-dynamic PROPERTIES LINK_FLAGS "-L${CMAKE_CACHEFILE_DIR}/Release" SOVERSION 0 VERSION 0.${VERSION} OUTPUT_NAME "portmidi")
 target_link_libraries(portmidi-dynamic ${PM_NEEDED_LIBS})
 
 # install the libraries (Linux and Mac OS X command line)
 if(UNIX)
   INSTALL(TARGETS portmidi-dynamic
-    LIBRARY DESTINATION /usr/local/lib
-    ARCHIVE DESTINATION /usr/local/lib)
+    LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+    ARCHIVE DESTINATION ${LIB_INSTALL_DIR})
   INSTALL(FILES ../pm_common/portmidi.h ../porttime/porttime.h
-    DESTINATION /usr/local/include)
+    DESTINATION ${INCLUDE_INSTALL_DIR})
 endif(UNIX)
Index: portmidi/pm_java/CMakeLists.txt
===================================================================
--- portmidi.orig/pm_java/CMakeLists.txt
+++ portmidi/pm_java/CMakeLists.txt
@@ -41,7 +41,7 @@ if(UNIX)
     INSTALL(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar
       DESTINATION /usr/share/java)
     INSTALL(PROGRAMS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults
-      DESTINATION /usr/local/bin)
+      DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
   endif(APPLE)
 endif(UNIX)
 # In windows, use pm_java/make.bat
Index: portmidi/pm_test/CMakeLists.txt
===================================================================
--- portmidi.orig/pm_test/CMakeLists.txt
+++ portmidi/pm_test/CMakeLists.txt
@@ -12,7 +12,7 @@ endif(WIN32)
 
 macro(make_a_test name)
   add_executable(${name} ${name}.c)
-  target_link_libraries(${name} portmidi-static ${PM_NEEDED_LIBS})
+  target_link_libraries(${name} portmidi-dynamic)
   add_dependencies(${name} portmidi-static)
 endmacro(make_a_test)
 
Index: portmidi/CMakeLists.txt
===================================================================
--- portmidi.orig/CMakeLists.txt
+++ portmidi/CMakeLists.txt
@@ -71,7 +71,3 @@ add_subdirectory(pm_common)
 add_subdirectory(pm_test)
 
 add_subdirectory(pm_dylib)
-
-# Cannot figure out how to make an xcode Java application with CMake
-add_subdirectory(pm_java)
-
