logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

portmidi-217-cmake.patch (13905B)


  1. diff --git a/CMakeLists.txt b/CMakeLists.txt
  2. index 4919b78..9dc6e58 100644
  3. --- a/CMakeLists.txt
  4. +++ b/CMakeLists.txt
  5. @@ -9,12 +9,11 @@ if(UNIX)
  6. set(CMAKE_BUILD_TYPE Release CACHE STRING
  7. "Semicolon-separate list of supported configuration types")
  8. # set default directories but don't override cached values...
  9. - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CACHEFILE_DIR}/${CMAKE_BUILD_TYPE}
  10. + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  11. CACHE STRING "libraries go here")
  12. - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CACHEFILE_DIR}/${CMAKE_BUILD_TYPE}
  13. + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  14. CACHE STRING "libraries go here")
  15. - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
  16. - ${CMAKE_CACHEFILE_DIR}/${CMAKE_BUILD_TYPE}
  17. + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  18. CACHE STRING "executables go here")
  19. else(UNIX)
  20. @@ -68,10 +67,20 @@ endif(UNIX)
  21. include_directories(pm_common porttime)
  22. add_subdirectory(pm_common)
  23. -add_subdirectory(pm_test)
  24. +option(PORTMIDI_ENABLE_JAVA "Enable Java bindings support" ON)
  25. +option(PORTMIDI_ENABLE_STATIC "Build and install static libraries" OFF)
  26. +option(PORTMIDI_ENABLE_TEST "Build test programs" ON)
  27. +
  28. +if(PORTMIDI_ENABLE_TEST)
  29. + add_subdirectory(pm_test)
  30. +endif(PORTMIDI_ENABLE_TEST)
  31. add_subdirectory(pm_dylib)
  32. # Cannot figure out how to make an xcode Java application with CMake
  33. -add_subdirectory(pm_java)
  34. +if(PORTMIDI_ENABLE_JAVA)
  35. + set(JAR_INSTALL_DIR share/java
  36. + CACHE STRING "Define directory name for jar installation")
  37. + add_subdirectory(pm_java)
  38. +endif(PORTMIDI_ENABLE_JAVA)
  39. diff --git a/pm_common/CMakeLists.txt b/pm_common/CMakeLists.txt
  40. index e171047..d23442d 100644
  41. --- a/pm_common/CMakeLists.txt
  42. +++ b/pm_common/CMakeLists.txt
  43. @@ -44,9 +44,6 @@ set(CMAKE_C_FLAGS_RELEASE "${DEFAULT_RELEASE_FLAGS} ${LINUX_FLAGS}"
  44. # first include the appropriate system-dependent file:
  45. if(UNIX)
  46. - # add the -g switch for Linux and Mac OS X (not used in Win32)
  47. - set (CMAKE_C_FLAGS_DEBUG "-g ${CMAKE_C_FLAGS_DEBUG}"
  48. - CACHE STRING "enable extra checks for debugging" FORCE)
  49. if(APPLE)
  50. set(MACSRC pmmacosxcm pmmac readbinaryplist finddefault)
  51. prepend_path(LIBSRC ../pm_mac/ ${MACSRC})
  52. @@ -62,19 +59,23 @@ if(UNIX)
  53. ${COREMIDI_LIB} ${CORESERVICES_LIB}
  54. CACHE INTERNAL "")
  55. - set(JAVAVM_LIB "${FRAMEWORK_PATH}/JavaVM.framework")
  56. - set(JAVA_INCLUDE_PATHS ${JAVAVM_LIB}/Headers)
  57. + if(PORTMIDI_ENABLE_JAVA)
  58. + set(JAVAVM_LIB "${FRAMEWORK_PATH}/JavaVM.framework")
  59. + set(JAVA_INCLUDE_PATHS ${JAVAVM_LIB}/Headers)
  60. + endif(PORTMIDI_ENABLE_JAVA)
  61. message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
  62. else(APPLE)
  63. # LINUX settings...
  64. - include(FindJNI)
  65. - message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
  66. - message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
  67. - message(STATUS "JAVA_INCLUDE_PATH2 is " ${JAVA_INCLUDE_PATH2})
  68. - message(STATUS "JAVA_JVM_LIBRARY is " ${JAVA_JVM_LIBRARY})
  69. - set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
  70. - # libjvm.so is found relative to JAVA_INCLUDE_PATH:
  71. - set(JAVAVM_LIB ${JAVA_JVM_LIBRARY}/libjvm.so)
  72. + if(PORTMIDI_ENABLE_JAVA)
  73. + include(FindJNI)
  74. + message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
  75. + message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
  76. + message(STATUS "JAVA_INCLUDE_PATH2 is " ${JAVA_INCLUDE_PATH2})
  77. + message(STATUS "JAVA_JVM_LIBRARY is " ${JAVA_JVM_LIBRARY})
  78. + set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
  79. + # libjvm.so is found relative to JAVA_INCLUDE_PATH:
  80. + set(JAVAVM_LIB ${JAVA_JVM_LIBRARY}/libjvm.so)
  81. + endif(PORTMIDI_ENABLE_JAVA)
  82. set(LINUXSRC pmlinuxalsa pmlinux finddefault)
  83. prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
  84. @@ -88,10 +89,12 @@ else(UNIX)
  85. # /MD is multithread DLL, /MT is multithread. Change to static:
  86. include(../pm_win/static.cmake)
  87. - include(FindJNI)
  88. + if(PORTMIDI_ENABLE_JAVA)
  89. + include(FindJNI)
  90. - set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
  91. - # message(STATUS "JAVA_INCLUDE_PATHS: " ${JAVA_INCLUDE_PATHS})
  92. + set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
  93. + # message(STATUS "JAVA_INCLUDE_PATHS: " ${JAVA_INCLUDE_PATHS})
  94. + endif(PORTMIDI_ENABLE_JAVA)
  95. set(WINSRC pmwin pmwinmm)
  96. prepend_path(LIBSRC ../pm_win/ ${WINSRC})
  97. @@ -99,29 +102,43 @@ else(UNIX)
  98. set(PM_NEEDED_LIBS winmm.lib)
  99. endif(WIN32)
  100. endif(UNIX)
  101. -set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVA_JVM_LIBRARY})
  102. +
  103. +if(PORTMIDI_ENABLE_JAVA)
  104. + set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVA_JVM_LIBRARY})
  105. +endif(PORTMIDI_ENABLE_JAVA)
  106. # this completes the list of library sources by adding shared code
  107. list(APPEND LIBSRC pmutil portmidi)
  108. # now add the shared files to make the complete list of library sources
  109. -add_library(portmidi-static ${LIBSRC})
  110. -set_target_properties(portmidi-static PROPERTIES OUTPUT_NAME "portmidi_s")
  111. -target_link_libraries(portmidi-static ${PM_NEEDED_LIBS})
  112. -
  113. -# define the jni library
  114. -include_directories(${JAVA_INCLUDE_PATHS})
  115. -
  116. -set(JNISRC ${LIBSRC} ../pm_java/pmjni/pmjni.c)
  117. -add_library(pmjni SHARED ${JNISRC})
  118. -target_link_libraries(pmjni ${JNI_EXTRA_LIBS})
  119. -set_target_properties(pmjni PROPERTIES EXECUTABLE_EXTENSION "jnilib")
  120. +if(PORTMIDI_ENABLE_STATIC)
  121. + add_library(portmidi-static ${LIBSRC})
  122. + set_target_properties(portmidi-static PROPERTIES OUTPUT_NAME "portmidi")
  123. + target_link_libraries(portmidi-static ${PM_NEEDED_LIBS})
  124. +endif(PORTMIDI_ENABLE_STATIC)
  125. +
  126. +if(PORTMIDI_ENABLE_JAVA)
  127. + # define the jni library
  128. + include_directories(${JAVA_INCLUDE_PATHS})
  129. +
  130. + set(JNISRC ${LIBSRC} ../pm_java/pmjni/pmjni.c)
  131. + add_library(pmjni SHARED ${JNISRC})
  132. + target_link_libraries(pmjni ${JNI_EXTRA_LIBS})
  133. + set_target_properties(pmjni PROPERTIES EXECUTABLE_EXTENSION "jnilib")
  134. +endif(PORTMIDI_ENABLE_JAVA)
  135. # install the libraries (Linux and Mac OS X command line)
  136. if(UNIX)
  137. - INSTALL(TARGETS portmidi-static pmjni
  138. - LIBRARY DESTINATION /usr/local/lib
  139. - ARCHIVE DESTINATION /usr/local/lib)
  140. + if(PORTMIDI_ENABLE_STATIC)
  141. + INSTALL(TARGETS portmidi-static
  142. + LIBRARY DESTINATION lib${LIB_SUFFIX}
  143. + ARCHIVE DESTINATION lib${LIB_SUFFIX})
  144. + endif(PORTMIDI_ENABLE_STATIC)
  145. + if(PORTMIDI_ENABLE_JAVA)
  146. + INSTALL(TARGETS pmjni
  147. + LIBRARY DESTINATION lib${LIB_SUFFIX}
  148. + ARCHIVE DESTINATION lib${LIB_SUFFIX})
  149. + endif(PORTMIDI_ENABLE_JAVA)
  150. # .h files installed by pm_dylib/CMakeLists.txt, so don't need them here
  151. # INSTALL(FILES portmidi.h ../porttime/porttime.h
  152. # DESTINATION /usr/local/include)
  153. diff --git a/pm_dylib/CMakeLists.txt b/pm_dylib/CMakeLists.txt
  154. index f693dd6..c0e1449 100644
  155. --- a/pm_dylib/CMakeLists.txt
  156. +++ b/pm_dylib/CMakeLists.txt
  157. @@ -39,9 +39,6 @@ set(CMAKE_C_FLAGS_RELEASE "${DEFAULT_RELEASE_FLAGS} ${LINUX_FLAGS}"
  158. # first include the appropriate system-dependent file:
  159. if(UNIX)
  160. - # add the -g switch for Linux and Mac OS X (not used in Win32)
  161. - set (CMAKE_C_FLAGS_DEBUG "-g ${CMAKE_C_FLAGS_DEBUG}"
  162. - CACHE STRING "enable extra checks for debugging" FORCE)
  163. if(APPLE)
  164. set(MACSRC pmmacosxcm pmmac readbinaryplist finddefault)
  165. prepend_path(LIBSRC ../pm_mac/ ${MACSRC})
  166. @@ -63,7 +60,8 @@ if(UNIX)
  167. message(STATUS "SYSROOT: " ${CMAKE_OSX_SYSROOT})
  168. else(APPLE)
  169. # LINUX settings...
  170. - include(FindJNI)
  171. + if(PORTMIDI_ENABLE_JAVA)
  172. + include(FindJNI)
  173. # message(STATUS "JAVA_JVM_LIB_PATH is " ${JAVA_JVM_LIB_PATH})
  174. # message(STATUS "JAVA_INCLUDE_PATH is " ${JAVA_INCLUDE_PATH})
  175. # note: should use JAVA_JVM_LIB_PATH, but it is not set properly
  176. @@ -75,11 +73,8 @@ if(UNIX)
  177. # JAVA_INCLUDE_PATH2; if no, then we need to make both JAVA_INCLUDE_PATH
  178. # and JAVA_INCLUDE_PATH2 set by user (will need clear documentation
  179. # because JAVA_INCLUDE_PATH2 is pretty obscure)
  180. - set(JAVA_INCLUDE_PATH ${JAVA_INCLUDE_PATH-UNKNOWN}
  181. - CACHE STRING "where to find Java SDK include directory")
  182. - set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH}/linux)
  183. - # libjvm.so is found relative to JAVA_INCLUDE_PATH:
  184. - set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../jre/lib/i386/client/libjvm.so)
  185. + set(JAVAVM_LIB ${JAVA_JVM_LIBRARY})
  186. + endif(PORTMIDI_ENABLE_JAVA)
  187. set(LINUXSRC pmlinuxalsa pmlinux finddefault)
  188. prepend_path(LIBSRC ../pm_linux/ ${LINUXSRC})
  189. @@ -91,13 +86,15 @@ else(UNIX)
  190. if(WIN32)
  191. # /MDd is multithread debug DLL, /MTd is multithread debug
  192. # /MD is multithread DLL, /MT is multithread
  193. -
  194. - include(FindJNI)
  195. - # note: should use JAVA_JVM_LIB_PATH, but it is not set properly
  196. - set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../lib/jvm.lib)
  197. - set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
  198. - # message(STATUS "JAVA_INCLUDE_PATHS: " ${JAVA_INCLUDE_PATHS})
  199. + if(PORTMIDI_ENABLE_JAVA)
  200. + include(FindJNI)
  201. + # note: should use JAVA_JVM_LIB_PATH, but it is not set properly
  202. + set(JAVAVM_LIB ${JAVA_INCLUDE_PATH}/../lib/jvm.lib)
  203. +
  204. + set(JAVA_INCLUDE_PATHS ${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
  205. + # message(STATUS "JAVA_INCLUDE_PATHS: " ${JAVA_INCLUDE_PATHS})
  206. + endif(PORTMIDI_ENABLE_JAVA)
  207. set(WINSRC pmwin pmwinmm)
  208. prepend_path(LIBSRC ../pm_win/ ${WINSRC})
  209. @@ -106,7 +103,10 @@ else(UNIX)
  210. # message(STATUS "JAVAVM_LIB: " ${JAVAVM_LIB})
  211. endif(WIN32)
  212. endif(UNIX)
  213. +
  214. +if(PORTMIDI_ENABLE_JAVA)
  215. set(JNI_EXTRA_LIBS ${PM_NEEDED_LIBS} ${JAVAVM_LIB})
  216. +endif(PORTMIDI_ENABLE_JAVA)
  217. # this completes the list of library sources by adding shared code
  218. set(SHARED_FILES pmutil portmidi)
  219. @@ -120,8 +120,8 @@ target_link_libraries(portmidi-dynamic ${PM_NEEDED_LIBS})
  220. # install the libraries (Linux and Mac OS X command line)
  221. if(UNIX)
  222. INSTALL(TARGETS portmidi-dynamic
  223. - LIBRARY DESTINATION /usr/local/lib
  224. - ARCHIVE DESTINATION /usr/local/lib)
  225. + LIBRARY DESTINATION lib${LIB_SUFFIX}
  226. + ARCHIVE DESTINATION lib${LIB_SUFFIX})
  227. INSTALL(FILES ../pm_common/portmidi.h ../porttime/porttime.h
  228. - DESTINATION /usr/local/include)
  229. + DESTINATION include)
  230. endif(UNIX)
  231. diff --git a/pm_java/CMakeLists.txt b/pm_java/CMakeLists.txt
  232. index a350620..9cbee1c 100644
  233. --- a/pm_java/CMakeLists.txt
  234. +++ b/pm_java/CMakeLists.txt
  235. @@ -5,43 +5,24 @@ if(UNIX)
  236. # java not dealt with in CMake -- see pm_mac/pm_mac.xcodeproj
  237. else(APPLE)
  238. # linux
  239. - set(JPORTMIDICLASS JPortMidi.class JPortMidiException.class
  240. - JPortMidiApi.class)
  241. - set(PMDEFAULTSCLASS PmDefaultsFrame.class PmDefaults.class)
  242. - prepend_path(JPORTMIDICLASS2 jportmidi/ ${JPORTMIDICLASS})
  243. - prepend_path(PMDEFAULTSCLASS2 pmdefaults/ ${PMDEFAULTSCLASS})
  244. - set(PMDEFAULTS_ALL_CLASSES ${JPORTMIDICLASS2} ${PMDEFAULTSCLASS2})
  245. - # message(STATUS "PMDEFAULTS_ALL_CLASSES is " ${PMDEFAULTS_ALL_CLASSES})
  246. - add_custom_command(OUTPUT pmdefaults/PmDefaultsFrame.class
  247. - COMMAND javac -classpath . pmdefaults/PmDefaultsFrame.java
  248. - MAIN_DEPENDENCY pmdefaults/PmDefaultsFrame.java
  249. - DEPENDS pmdefaults/PmDefaults.java
  250. - WORKING_DIRECTORY pm_java)
  251. - add_custom_command(OUTPUT pmdefaults/PmDefaults.class
  252. - COMMAND javac -classpath . pmdefaults/PmDefaults.java
  253. - MAIN_DEPENDENCY pmdefaults/PmDefaults.java
  254. - DEPENDS pmdefaults/PmDefaultsFrame.java
  255. - WORKING_DIRECTORY pm_java)
  256. - add_custom_command(OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar
  257. - COMMAND cp pmdefaults/portmusic_logo.png .
  258. - COMMAND jar cmf pmdefaults/manifest.txt pmdefaults.jar
  259. - pmdefaults/*.class portmusic_logo.png jportmidi/*.class
  260. - COMMAND chmod +x pmdefaults/pmdefaults
  261. - COMMAND cp pmdefaults/pmdefaults ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
  262. - COMMAND mv pmdefaults.jar ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
  263. - COMMAND rm portmusic_logo.png
  264. - MAIN_DEPENDENCY pmdefaults/PmDefaults.class
  265. - DEPENDS ${PMDEFAULTS_ALL_CLASSES}
  266. - WORKING_DIRECTORY pm_java)
  267. - add_custom_target(pmdefaults_target ALL
  268. - DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar)
  269. - # message(STATUS "add_custom_target: pmdefaults.jar")
  270. + set(JAVA_CLASSES jportmidi pmdefaults)
  271. + add_custom_command(OUTPUT ${JAVA_CLASSES}
  272. + COMMAND javac -d ${CMAKE_CURRENT_BINARY_DIR} jportmidi/*.java pmdefaults/*.java
  273. + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  274. + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pmdefaults.jar
  275. + DEPENDS ${JAVA_CLASSES}
  276. + COMMAND jar cmf pmdefaults/manifest.txt ${CMAKE_CURRENT_BINARY_DIR}/pmdefaults.jar
  277. + -C pmdefaults portmusic_logo.png -C ${CMAKE_CURRENT_BINARY_DIR} jportmidi
  278. + -C ${CMAKE_CURRENT_BINARY_DIR} pmdefaults
  279. + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
  280. + add_custom_target(pmdefaults.jar ALL
  281. + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/pmdefaults.jar)
  282. # install the libraries (Linux only)
  283. - INSTALL(FILES ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults.jar
  284. - DESTINATION /usr/share/java)
  285. - INSTALL(PROGRAMS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/pmdefaults
  286. - DESTINATION /usr/local/bin)
  287. + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/pmdefaults.jar
  288. + DESTINATION ${JAR_INSTALL_DIR})
  289. + INSTALL(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/pmdefaults/pmdefaults
  290. + DESTINATION bin)
  291. endif(APPLE)
  292. endif(UNIX)
  293. # In windows, use pm_java/make.bat
  294. diff --git a/pm_test/CMakeLists.txt b/pm_test/CMakeLists.txt
  295. index b89074b..236ff49 100644
  296. --- a/pm_test/CMakeLists.txt
  297. +++ b/pm_test/CMakeLists.txt
  298. @@ -10,10 +10,12 @@ if(WIN32)
  299. include(../pm_win/static.cmake)
  300. endif(WIN32)
  301. +set(CMAKE_SKIP_BUILD_RPATH TRUE)
  302. +
  303. macro(make_a_test name)
  304. add_executable(${name} ${name}.c)
  305. - target_link_libraries(${name} portmidi-static ${PM_NEEDED_LIBS})
  306. - add_dependencies(${name} portmidi-static)
  307. + target_link_libraries(${name} portmidi-dynamic ${PM_NEEDED_LIBS})
  308. + add_dependencies(${name} portmidi-dynamic)
  309. endmacro(make_a_test)
  310. make_a_test(test)