diff options
Diffstat (limited to 'portmidi/pm_common/CMakeLists.txt')
| -rw-r--r-- | portmidi/pm_common/CMakeLists.txt | 167 |
1 files changed, 0 insertions, 167 deletions
diff --git a/portmidi/pm_common/CMakeLists.txt b/portmidi/pm_common/CMakeLists.txt deleted file mode 100644 index 1ad54ad..0000000 --- a/portmidi/pm_common/CMakeLists.txt +++ /dev/null | |||
| @@ -1,167 +0,0 @@ | |||
| 1 | # pm_common/CMakeLists.txt -- how to build portmidi library | ||
| 2 | |||
| 3 | # creates the portmidi library | ||
| 4 | # exports PM_NEEDED_LIBS to parent. It seems that PM_NEEDED_LIBS for | ||
| 5 | # Linux should include Thread::Thread and ALSA::ALSA, but these | ||
| 6 | # are not visible in other CMake files, even though the portmidi | ||
| 7 | # target is. Therefore, Thread::Thread is replaced by | ||
| 8 | # CMAKE_THREAD_LIBS_INIT and ALSA::ALSA is replaced by ALSA_LIBRARIES. | ||
| 9 | # Is there a better way to do this? Maybe this whole file should be | ||
| 10 | # at the parent level. | ||
| 11 | |||
| 12 | # Support alternative name for static libraries to avoid confusion. | ||
| 13 | # (In particular, Xcode has automatically converted portmidi.a to | ||
| 14 | # portmidi.dylib without warning, so using portmidi-static.a eliminates | ||
| 15 | # this possibility, but default for all libs is "portmidi"): | ||
| 16 | set(PM_STATIC_LIB_NAME "portmidi" CACHE STRING | ||
| 17 | "For static builds, the PortMidi library name, e.g. portmidi-static. | ||
| 18 | Default is portmidi") | ||
| 19 | set(PM_ACTUAL_LIB_NAME "portmidi") | ||
| 20 | if(NOT BUILD_SHARED_LIBS) | ||
| 21 | set(PM_ACTUAL_LIB_NAME ${PM_STATIC_LIB_NAME}) | ||
| 22 | endif() | ||
| 23 | |||
| 24 | # set the build directory for libportmidi.a to be in portmidi, not in | ||
| 25 | # portmidi/pm_common. Must be done here BEFORE add_library below. | ||
| 26 | if(APPLE OR WIN32) | ||
| 27 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
| 28 | # set the build directory for .dylib libraries | ||
| 29 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
| 30 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
| 31 | endif(APPLE OR WIN32) | ||
| 32 | |||
| 33 | # we need full paths to sources because they are shared with other targets | ||
| 34 | # (in particular pmjni). Set PMDIR to the top-level portmidi directory: | ||
| 35 | get_filename_component(PMDIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY) | ||
| 36 | set(PM_LIB_PUBLIC_SRC ${PMDIR}/pm_common/portmidi.c | ||
| 37 | ${PMDIR}/pm_common/pmutil.c | ||
| 38 | ${PMDIR}/porttime/porttime.c) | ||
| 39 | add_library(portmidi ${PM_LIB_PUBLIC_SRC}) | ||
| 40 | |||
| 41 | # MSVCRT_DLL is "DLL" for shared runtime library, and "" for static: | ||
| 42 | set_target_properties(portmidi PROPERTIES | ||
| 43 | VERSION ${LIBRARY_VERSION} | ||
| 44 | SOVERSION ${LIBRARY_SOVERSION} | ||
| 45 | OUTPUT_NAME "${PM_ACTUAL_LIB_NAME}" | ||
| 46 | MSVC_RUNTIME_LIBRARY | ||
| 47 | "MultiThreaded$<$<CONFIG:Debug>:Debug>${MSVCRT_DLL}" | ||
| 48 | WINDOWS_EXPORT_ALL_SYMBOLS TRUE) | ||
| 49 | target_include_directories(portmidi PUBLIC | ||
| 50 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> | ||
| 51 | $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>) | ||
| 52 | |||
| 53 | |||
| 54 | option(PM_CHECK_ERRORS | ||
| 55 | "Insert a check for error return values at the end of each PortMidi function. | ||
| 56 | If an error is encountered, a text message is printed using printf(), the user | ||
| 57 | is asked to type ENTER, and then exit(-1) is called to clean up and terminate | ||
| 58 | the program. | ||
| 59 | |||
| 60 | You should not use PM_CHECK_ERRORS if printf() does not work (e.g. this is not | ||
| 61 | a console application under Windows, or there is no visible console on some | ||
| 62 | other OS), and you should not use PM_CHECK_ERRORS if you intend to recover | ||
| 63 | from errors rather than abruptly terminate the program." OFF) | ||
| 64 | if(PM_CHECK_ERRORS) | ||
| 65 | target_compile_definitions(portmidi PRIVATE PM_CHECK_ERRORS) | ||
| 66 | endif(PM_CHECK_ERRORS) | ||
| 67 | |||
| 68 | macro(prepend_path RESULT PATH) | ||
| 69 | set(${RESULT}) | ||
| 70 | foreach(FILE ${ARGN}) | ||
| 71 | list(APPEND ${RESULT} "${PATH}${FILE}") | ||
| 72 | endforeach(FILE) | ||
| 73 | endmacro(prepend_path) | ||
| 74 | |||
| 75 | # UNIX needs pthread library | ||
| 76 | if(NOT WIN32) | ||
| 77 | set(THREADS_PREFER_PTHREAD_FLAG ON) | ||
| 78 | find_package(Threads REQUIRED) | ||
| 79 | endif() | ||
| 80 | |||
| 81 | # Check for sndio | ||
| 82 | if(USE_SNDIO) | ||
| 83 | include (FindPackageHandleStandardArgs) | ||
| 84 | find_path(SNDIO_INCLUDE_DIRS NAMES sndio.h) | ||
| 85 | find_library(SNDIO_LIBRARY sndio) | ||
| 86 | find_package_handle_standard_args(Sndio | ||
| 87 | REQUIRED_VARS SNDIO_LIBRARY SNDIO_INCLUDE_DIRS) | ||
| 88 | endif(USE_SNDIO) | ||
| 89 | |||
| 90 | # first include the appropriate system-dependent file: | ||
| 91 | if(SNDIO_FOUND AND USE_SNDIO) | ||
| 92 | set(PM_LIB_PRIVATE_SRC | ||
| 93 | ${PMDIR}/porttime/ptlinux.c | ||
| 94 | ${PMDIR}/pm_sndio/pmsndio.c) | ||
| 95 | set(PM_NEEDED_LIBS Threads::Threads ${SNDIO_LIBRARY} PARENT_SCOPE) | ||
| 96 | target_link_libraries(portmidi PRIVATE Threads::Threads ${SNDIO_LIBRARY}) | ||
| 97 | target_include_directories(portmidi PRIVATE ${SNDIO_INCLUDE_DIRS}) | ||
| 98 | elseif(UNIX AND APPLE) | ||
| 99 | set(Threads::Threads "" PARENT_SCOPE) | ||
| 100 | set(PM_LIB_PRIVATE_SRC | ||
| 101 | ${PMDIR}/porttime/ptmacosx_mach.c | ||
| 102 | ${PMDIR}/pm_mac/pmmac.c | ||
| 103 | ${PMDIR}/pm_mac/pmmacosxcm.c) | ||
| 104 | set(PM_NEEDED_LIBS | ||
| 105 | ${CMAKE_THREAD_LIBS_INIT} | ||
| 106 | -Wl,-framework,CoreAudio | ||
| 107 | -Wl,-framework,CoreFoundation | ||
| 108 | -Wl,-framework,CoreMidi | ||
| 109 | -Wl,-framework,CoreServices | ||
| 110 | PARENT_SCOPE) | ||
| 111 | target_link_libraries(portmidi PRIVATE | ||
| 112 | Threads::Threads | ||
| 113 | -Wl,-framework,CoreAudio | ||
| 114 | -Wl,-framework,CoreFoundation | ||
| 115 | -Wl,-framework,CoreMidi | ||
| 116 | -Wl,-framework,CoreServices | ||
| 117 | ) | ||
| 118 | # set to CMake default; is this right?: | ||
| 119 | set_target_properties(portmidi PROPERTIES MACOSX_RPATH ON) | ||
| 120 | elseif(HAIKU) | ||
| 121 | set(PM_LIB_PRIVATE_SRC | ||
| 122 | ${PMDIR}/porttime/pthaiku.cpp | ||
| 123 | ${PMDIR}/pm_haiku/pmhaiku.cpp) | ||
| 124 | set(PM_NEEDED_LIBS be midi midi2 PARENT_SCOPE) | ||
| 125 | target_link_libraries(portmidi PRIVATE be midi midi2) | ||
| 126 | elseif(UNIX) | ||
| 127 | target_compile_definitions(portmidi PRIVATE ${LINUX_FLAGS}) | ||
| 128 | set(PM_LIB_PRIVATE_SRC | ||
| 129 | ${PMDIR}/porttime/ptlinux.c | ||
| 130 | ${PMDIR}/pm_linux/pmlinux.c | ||
| 131 | ${PMDIR}/pm_linux/pmlinuxnull.c) | ||
| 132 | if(${LINUX_DEFINES} MATCHES ".*PMALSA.*") | ||
| 133 | # Note that ALSA is not required if PMNULL is defined -- PortMidi will then | ||
| 134 | # compile without ALSA and report no MIDI devices. Later, PMSNDIO or PMJACK | ||
| 135 | # might be additional options. | ||
| 136 | find_package(ALSA REQUIRED) | ||
| 137 | list(APPEND PM_LIB_PRIVATE_SRC ${PMDIR}/pm_linux/pmlinuxalsa.c) | ||
| 138 | set(PM_NEEDED_LIBS ${CMAKE_THREAD_LIBS_INIT} ${ALSA_LIBRARIES} PARENT_SCOPE) | ||
| 139 | target_link_libraries(portmidi PRIVATE Threads::Threads ALSA::ALSA) | ||
| 140 | set(PKGCONFIG_REQUIRES_PRIVATE "alsa" PARENT_SCOPE) | ||
| 141 | else() | ||
| 142 | message(WARNING "No PMALSA, so PortMidi will not use ALSA, " | ||
| 143 | "and will not find or open MIDI devices.") | ||
| 144 | set(PM_NEEDED_LIBS ${CMAKE_THREAD_LIBS_INIT} PARENT_SCOPE) | ||
| 145 | target_link_libraries(portmidi PRIVATE Threads::Threads) | ||
| 146 | endif() | ||
| 147 | elseif(WIN32) | ||
| 148 | set(PM_LIB_PRIVATE_SRC | ||
| 149 | ${PMDIR}/porttime/ptwinmm.c | ||
| 150 | ${PMDIR}/pm_win/pmwin.c | ||
| 151 | ${PMDIR}/pm_win/pmwinmm.c) | ||
| 152 | set(PM_NEEDED_LIBS winmm PARENT_SCOPE) | ||
| 153 | target_link_libraries(portmidi PRIVATE winmm) | ||
| 154 | # if(NOT BUILD_SHARED_LIBS AND PM_USE_STATIC_RUNTIME) | ||
| 155 | # /MDd is multithread debug DLL, /MTd is multithread debug | ||
| 156 | # /MD is multithread DLL, /MT is multithread. Change to static: | ||
| 157 | # include(../pm_win/static.cmake) | ||
| 158 | # endif() | ||
| 159 | else() | ||
| 160 | message(FATAL_ERROR "Operating system not supported.") | ||
| 161 | endif() | ||
| 162 | |||
| 163 | set(PM_LIB_PUBLIC_SRC ${PM_LIB_PUBLIC_SRC} PARENT_SCOPE) # export to parent | ||
| 164 | set(PM_LIB_PRIVATE_SRC ${PM_LIB_PRIVATE_SRC} PARENT_SCOPE) # export to parent | ||
| 165 | |||
| 166 | target_sources(portmidi PRIVATE ${PM_LIB_PRIVATE_SRC}) | ||
| 167 | |||
