zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit d7b918eb065bcc47e798b653d95aef691fa28797
parent 3f055b00d2165903e091947e715f94e60321487c
Author: fundamental <[email protected]>
Date:   Sat, 27 Aug 2011 11:35:00 -0400

CMake: rewriting some of the find scripts

- Find scripts should be more descriptive
- Port Audio is only enabled for 19+ versions

Diffstat:
Mcmake/FindJACK.cmake | 38++++++++++++--------------------------
Mcmake/FindMXML.cmake | 38++++++++++++--------------------------
Mcmake/FindPortAudio.cmake | 38+++++++++++++-------------------------
Mcmake/Findfftw.cmake | 40++++++++++++----------------------------
Mcmake/Findzlib.cmake | 57+++++++++++++++++++++++++++++++++------------------------
Acmake/LibFindMacros.cmake | 100+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/CMakeLists.txt | 20++++++++++----------
Msrc/Tests/CMakeLists.txt | 6+++---
8 files changed, 195 insertions(+), 142 deletions(-)

diff --git a/cmake/FindJACK.cmake b/cmake/FindJACK.cmake @@ -1,31 +1,17 @@ -# - Try to find Motif (or lesstif) -# Once done this will define: -# JACK_FOUND - system has JACK -# JACK_INCLUDE_DIR - incude paths to use Motif -# JACK_LIBRARIES - Link these to use Motif +#Find JACK Audio Connection Kit -SET(JACK_FOUND 0) - -IF(UNIX) - FIND_PATH(JACK_INCLUDE_DIR - jack/ringbuffer.h - /usr/include +include(LibFindMacros) +libfind_pkg_check_modules(JACK jack) +find_path(JACK_INCLUDE_DIR + NAMES jack/jack.h + PATHS ${JACK_INCLUDE_DIRS} ) - FIND_LIBRARY(JACK_LIBRARIES - jack - /usr/lib +find_library(JACK_LIBRARY + NAMES jack + PATHS ${JACK_LIBRARY_DIRS} ) -ENDIF(UNIX) - -# handle the QUIETLY and REQUIRED arguments and set JACK_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(JACK DEFAULT_MSG JACK_LIBRARIES JACK_INCLUDE_DIR) - - -MARK_AS_ADVANCED( - JACK_INCLUDE_DIR - JACK_LIBRARIES -) +set(JACK_PROCESS_INCLUDES JACK_INCLUDE_DIR) +set(JACK_PROCESS_LIBS JACK_LIBRARY) +libfind_process(JACK) diff --git a/cmake/FindMXML.cmake b/cmake/FindMXML.cmake @@ -1,31 +1,17 @@ -# - Try to find Motif (or lesstif) -# Once done this will define: -# MXML_FOUND - system has MXML -# MXML_INCLUDE_DIR - incude paths to use Motif -# MXML_LIBRARIES - Link these to use Motif +#Find mxml (mini xml library) -SET(MXML_FOUND 0) - -IF(UNIX) - FIND_PATH(MXML_INCLUDE_DIR - mxml.h - /usr/include +include(LibFindMacros) +libfind_pkg_check_modules(MXML mxml) +find_path(MXML_INCLUDE_DIR + NAMES mxml.h + PATHS ${MXML_INCLUDE_DIRS} ) - FIND_LIBRARY(MXML_LIBRARIES - mxml - /usr/lib +find_library(MXML_LIBRARY + NAMES mxml + PATHS ${MXML_LIBRARY_DIRS} ) -ENDIF(UNIX) - -# handle the QUIETLY and REQUIRED arguments and set MXML_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(MXML DEFAULT_MSG MXML_LIBRARIES MXML_INCLUDE_DIR) - - -MARK_AS_ADVANCED( - MXML_INCLUDE_DIR - MXML_LIBRARIES -) +set(MXML_PROCESS_INCLUDES MXML_INCLUDE_DIR) +set(MXML_PROCESS_LIBS MXML_LIBRARY) +libfind_process(MXML) diff --git a/cmake/FindPortAudio.cmake b/cmake/FindPortAudio.cmake @@ -1,31 +1,19 @@ -# - Try to find Motif (or lesstif) -# Once done this will define: -# PORTAUDIO_FOUND - system has PORTAUDIO -# PORTAUDIO_INCLUDE_DIR - incude paths to use Motif -# PORTAUDIO_LIBRARIES - Link these to use Motif +#Find Port Audio -SET(PORTAUDIO_FOUND 0) -IF(UNIX) - FIND_PATH(PORTAUDIO_INCLUDE_DIR - portaudio.h - /usr/include - ) +include(LibFindMacros) +libfind_pkg_check_modules(PortAudio portaudio-2.0>=19) - FIND_LIBRARY(PORTAUDIO_LIBRARIES - portaudio - /usr/lib +find_path(PortAudio_INCLUDE_DIR + NAMES portaudio.h + PATHS ${PortAudio_INCLUDE_DIRS} ) -ENDIF(UNIX) - -# handle the QUIETLY and REQUIRED arguments and set PORTAUDIO_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(PortAudio DEFAULT_MSG PORTAUDIO_LIBRARIES PORTAUDIO_INCLUDE_DIR) - +find_library(PortAudio_LIBRARY + NAMES portaudio + PATHS ${Portaudio_LIBRARY_DIRS} + ) -MARK_AS_ADVANCED( - PORTAUDIO_INCLUDE_DIR - PORTAUDIO_LIBRARIES -) +set(PortAudio_PROCESS_INCLUDES PortAudio_INCLUDE_DIR) +set(PortAudio_PROCESS_LIBS PortAudio_LIBRARY) +libfind_process(PortAudio) diff --git a/cmake/Findfftw.cmake b/cmake/Findfftw.cmake @@ -1,33 +1,17 @@ -# - Try to find fftw -# Once done this will define: -# fftw_FOUND - system has fftw -# fftw_INCLUDE_DIR - incude paths to use fftw -# fftw_LIBRARIES - Link these to use fftw -# fftw_VERSION - Version of fftw found +#Find fftw (FFT algorithm library) -SET(fftw_FOUND 0) - -IF(UNIX OR CYGWIN) - FIND_PATH(fftw_INCLUDE_DIR - fftw3.h - /usr/include +include(LibFindMacros) +libfind_pkg_check_modules(fftw fftw3) +find_path(fftw_INCLUDE_DIR + NAMES fftw3.h + PATHS ${fftw_INCLUDE_DIRS} ) - FIND_LIBRARY(fftw_LIBRARIES - fftw3 - /usr/lib +find_library(fftw_LIBRARY + NAMES fftw3 + PATHS ${fftw_LIBRARY_DIRS} ) -ENDIF(UNIX OR CYGWIN) - -# handle the QUIETLY and REQUIRED arguments and set fftw_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(fftw DEFAULT_MSG fftw_LIBRARIES fftw_INCLUDE_DIR) - -set(fftw_VERSION 3) #only one option for now [TODO]:extend for version two - -MARK_AS_ADVANCED( - fftw_INCLUDE_DIR - fftw_LIBRARIES -) +set(fftw_PROCESS_INCLUDES fftw_INCLUDE_DIR) +set(fftw_PROCESS_LIBS fftw_LIBRARY) +libfind_process(fftw) diff --git a/cmake/Findzlib.cmake b/cmake/Findzlib.cmake @@ -1,30 +1,39 @@ -# Try to find zlib -# Once done this will define: -# zlib_FOUND - system has ZLIB -# zlib_INCLUDE_DIR - incude paths for zlib -# zlib_LIBRARIES - Link these to use zlib +# - Find zlib +# Find the native ZLIB includes and library +# +# ZLIB_INCLUDE_DIRS - where to find zlib.h, etc. +# ZLIB_LIBRARIES - List of libraries when using zlib. +# ZLIB_FOUND - True if zlib found. -SET(zlib_FOUND 0) +#============================================================================= +# Copyright 2001-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distributed this file outside of CMake, substitute the full +# License text for the above reference.) -IF(UNIX) - FIND_PATH(zlib_INCLUDE_DIR - zlib.h - /usr/include - ) - FIND_LIBRARY(zlib_LIBRARIES - NAMES z zlib - PATHS/usr/lib /usr/local/lib - ) +IF (zlib_INCLUDE_DIR) + # Already in cache, be silent + SET(zlib_FIND_QUIETLY TRUE) +ENDIF (zlib_INCLUDE_DIR) -ENDIF(UNIX) +FIND_PATH(zlib_INCLUDE_DIR zlib.h) -# handle the QUIETLY and REQUIRED arguments and set ZLIB_FOUND to TRUE if -# all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(zlib DEFAULT_MSG zlib_LIBRARIES zlib_INCLUDE_DIR) +SET(zlib_NAMES z zlib zdll) +FIND_LIBRARY(zlib_LIBRARY NAMES ${zlib_NAMES} ) +MARK_AS_ADVANCED( zlib_LIBRARY zlib_INCLUDE_DIR ) +# Per-recommendation +SET(zlib_INCLUDE_DIRS "${zlib_INCLUDE_DIR}") +SET(zlib_LIBRARIES "${zlib_LIBRARY}") -MARK_AS_ADVANCED( - zlib_INCLUDE_DIR - zlib_LIBRARIES -) +# handle the QUIETLY and REQUIRED arguments and set zlib_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(zlib DEFAULT_MSG zlib_LIBRARIES zlib_INCLUDE_DIRS) diff --git a/cmake/LibFindMacros.cmake b/cmake/LibFindMacros.cmake @@ -0,0 +1,100 @@ +# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments +# used for the current package. For this to work, the first parameter must be the +# prefix of the current package, then the prefix of the new package etc, which are +# passed to find_package. +macro (libfind_package PREFIX) + set (LIBFIND_PACKAGE_ARGS ${ARGN}) + if (${PREFIX}_FIND_QUIETLY) + set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET) + endif (${PREFIX}_FIND_QUIETLY) + if (${PREFIX}_FIND_REQUIRED) + set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED) + endif (${PREFIX}_FIND_REQUIRED) + find_package(${LIBFIND_PACKAGE_ARGS}) +endmacro (libfind_package) + +# CMake developers made the UsePkgConfig system deprecated in the same release (2.6) +# where they added pkg_check_modules. Consequently I need to support both in my scripts +# to avoid those deprecated warnings. Here's a helper that does just that. +# Works identically to pkg_check_modules, except that no checks are needed prior to use. +macro (libfind_pkg_check_modules PREFIX PKGNAME) + if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + include(UsePkgConfig) + pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS) + else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(${PREFIX} ${PKGNAME}) + endif (PKG_CONFIG_FOUND) + endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) +endmacro (libfind_pkg_check_modules) + +# Do the final processing once the paths have been detected. +# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain +# all the variables, each of which contain one include directory. +# Ditto for ${PREFIX}_PROCESS_LIBS and library files. +# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. +# Also handles errors in case library detection was required, etc. +# Performs very basic version checks +macro (libfind_process PREFIX) + # Skip processing if already processed during this run + if (NOT ${PREFIX}_FOUND) + # Start with the assumption that the library was found + set (${PREFIX}_FOUND TRUE) + + # Process all includes and set _FOUND to false if any are missing + foreach (i ${${PREFIX}_PROCESS_INCLUDES}) + if (${i}) + set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}}) + mark_as_advanced(${i}) + else (${i}) + set (${PREFIX}_FOUND FALSE) + endif (${i}) + endforeach (i) + + # Process all libraries and set _FOUND to false if any are missing + foreach (i ${${PREFIX}_PROCESS_LIBS}) + if (${i}) + set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}}) + mark_as_advanced(${i}) + else (${i}) + set (${PREFIX}_FOUND FALSE) + endif (${i}) + endforeach (i) + + # Print message and/or exit on fatal error + if (${PREFIX}_FOUND) + if (NOT ${PREFIX}_FIND_QUIETLY) + message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") + endif (NOT ${PREFIX}_FIND_QUIETLY) + else (${PREFIX}_FOUND) + if (${PREFIX}_FIND_REQUIRED) + foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS}) + message("${i}=${${i}}") + endforeach (i) + message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.") + endif (${PREFIX}_FIND_REQUIRED) + endif (${PREFIX}_FOUND) + endif (NOT ${PREFIX}_FOUND) +endmacro (libfind_process) + +macro(libfind_library PREFIX basename) + set(TMP "") + if(MSVC80) + set(TMP -vc80) + endif(MSVC80) + if(MSVC90) + set(TMP -vc90) + endif(MSVC90) + set(${PREFIX}_LIBNAMES ${basename}${TMP}) + if(${ARGC} GREATER 2) + set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2}) + string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES}) + set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP}) + endif(${ARGC} GREATER 2) + find_library(${PREFIX}_LIBRARY + NAMES ${${PREFIX}_LIBNAMES} + PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS} + ) +endmacro(libfind_library) + diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt @@ -23,12 +23,12 @@ pkg_search_module(DSSI dssi>=0.9.0) mark_as_advanced(DSSI_LIBRARIES) #simple cxxtest find until cmake 2.6 support is changed find_path(CXXTEST_INCLUDE_DIR cxxtest/TestSuite.h) -message("searching for cxxtest...") +message(STATUS "searching for cxxtest...") if(CXXTEST_INCLUDE_DIR) - message("CxxTest found at ${CXXTEST_INCLUDE_DIR}") + message(STATUS "Found CxxTest: ${CXXTEST_INCLUDE_DIR}") set(CXXTEST_FOUND true) else() - message("CxxTest not found...") + message(STATUS "CxxTest not found...") set(CXXTEST_FOUND false) endif() @@ -254,14 +254,14 @@ add_executable(zynaddsubfx ) target_link_libraries(zynaddsubfx - ${NONGUI_LIBRARIES} + ${NONGUI_LIBRARIES} ${GUI_LIBRARIES} - ${zlib_LIBRARIES} - ${fftw_LIBRARIES} - ${MXML_LIBRARIES} - ${NIO_LIBRARIES} - ${AUDIO_LIBRARIES} - ${OS_LIBRARIES} + ${zlib_LIBRARIES} + ${fftw_LIBRARIES} + ${MXML_LIBRARIES} + ${NIO_LIBRARIES} + ${AUDIO_LIBRARIES} + ${OS_LIBRARIES} ) if (DssiEnable) diff --git a/src/Tests/CMakeLists.txt b/src/Tests/CMakeLists.txt @@ -6,11 +6,11 @@ CXXTEST_ADD_TEST(EchoTest EchoTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/EchoTest.h) #CXXTEST_ADD_TEST(SampleTest SampleTest.h) CXXTEST_ADD_TEST(MicrotonalTest MicrotonalTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/MicrotonalTest.h) CXXTEST_ADD_TEST(XMLwrapperTest XMLwrapper.cpp ${CMAKE_CURRENT_SOURCE_DIR}/XMLwrapperTest.h) -CXXTEST_ADD_TEST(ADnoteTest AdNoteTest.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/AdNoteTest.h) +CXXTEST_ADD_TEST(ADnoteTest AdNoteTest.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/AdNoteTest.h) CXXTEST_ADD_TEST(SUBnoteTest SubNoteTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/SubNoteTest.h) CXXTEST_ADD_TEST(OscilGenTest OscilGenTest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/OscilGenTest.h) - + set(test_lib ${NONGUI_LIBRARIES} ${zlib_LIBRARIES} ${fftw_LIBRARIES} ${MXML_LIBRARIES}) target_link_libraries(ADnoteTest ${test_lib})