From aaf9b73dafd49614a325b4a1c3159ac1db0c2ee0 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 11 Feb 2013 18:42:28 -0800 Subject: [PATCH] add find modules for Jack and librt, link to interface --- cmake/modules/FindJack.cmake | 82 +++++++++++++++++++++++++++++++++++ cmake/modules/FindLibrt.cmake | 61 ++++++++++++++++++++++++++ interface/CMakeLists.txt | 14 ++++++ 3 files changed, 157 insertions(+) create mode 100644 cmake/modules/FindJack.cmake create mode 100644 cmake/modules/FindLibrt.cmake diff --git a/cmake/modules/FindJack.cmake b/cmake/modules/FindJack.cmake new file mode 100644 index 0000000000..a39fd63470 --- /dev/null +++ b/cmake/modules/FindJack.cmake @@ -0,0 +1,82 @@ +# - Try to find jack-2.6 +# Once done this will define +# +# JACK_FOUND - system has jack +# JACK_INCLUDE_DIRS - the jack include directory +# JACK_LIBRARIES - Link these to use jack +# JACK_DEFINITIONS - Compiler switches required for using jack +# +# Copyright (c) 2008 Andreas Schneider +# Modified for other libraries by Lasse Kärkkäinen +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +if (JACK_LIBRARIES AND JACK_INCLUDE_DIRS) + # in cache already + set(JACK_FOUND TRUE) +else (JACK_LIBRARIES AND JACK_INCLUDE_DIRS) + # use pkg-config to get the directories and then use these values + # in the FIND_PATH() and FIND_LIBRARY() calls + if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + include(UsePkgConfig) + pkgconfig(jack _JACK_INCLUDEDIR _JACK_LIBDIR _JACK_LDFLAGS _JACK_CFLAGS) + else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(_JACK jack) + endif (PKG_CONFIG_FOUND) + endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_path(JACK_INCLUDE_DIR + NAMES + jack/jack.h + PATHS + ${_JACK_INCLUDEDIR} + /usr/include + /usr/local/include + /opt/local/include + /sw/include + ) + + find_library(JACK_LIBRARY + NAMES + jack + PATHS + ${_JACK_LIBDIR} + /usr/lib + /usr/local/lib + /opt/local/lib + /sw/lib + ) + + if (JACK_LIBRARY AND JACK_INCLUDE_DIR) + set(JACK_FOUND TRUE) + + set(JACK_INCLUDE_DIRS + ${JACK_INCLUDE_DIR} + ) + + set(JACK_LIBRARIES + ${JACK_LIBRARIES} + ${JACK_LIBRARY} + ) + + endif (JACK_LIBRARY AND JACK_INCLUDE_DIR) + + if (JACK_FOUND) + if (NOT JACK_FIND_QUIETLY) + message(STATUS "Found jack: ${JACK_LIBRARY}") + endif (NOT JACK_FIND_QUIETLY) + else (JACK_FOUND) + if (JACK_FIND_REQUIRED) + message(FATAL_ERROR "Could not find JACK") + endif (JACK_FIND_REQUIRED) + endif (JACK_FOUND) + + # show the JACK_INCLUDE_DIRS and JACK_LIBRARIES variables only in the advanced view + mark_as_advanced(JACK_INCLUDE_DIRS JACK_LIBRARIES) + +endif (JACK_LIBRARIES AND JACK_INCLUDE_DIRS) + diff --git a/cmake/modules/FindLibrt.cmake b/cmake/modules/FindLibrt.cmake new file mode 100644 index 0000000000..34450d3924 --- /dev/null +++ b/cmake/modules/FindLibrt.cmake @@ -0,0 +1,61 @@ +# You may redistribute this program and/or modify it under the terms of +# the GNU General Public License as published by the Free Software Foundation, +# either version 3 of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +if(NOT LIBRT_FOUND) + + find_path(LIBRT_INCLUDE_DIR + NAMES + time.h + PATHS + ${LIBRTDIR}/include/ + ) + + find_file( + LIBRT_LIBRARIES librt.a + PATHS + ${LIBRTDIR}/lib/ + /usr/local/lib64/ + /usr/local/lib/ + /usr/lib/i386-linux-gnu/ + /usr/lib/x86_64-linux-gnu/ + /usr/lib64/ + /usr/lib/ + ) + set (LIBRT_DYNAMIC "Using static library.") + + if (NOT LIBRT_LIBRARIES) + find_library( + LIBRT_LIBRARIES rt + PATHS + ${LIBRTDIR}/lib/ + /usr/local/lib64/ + /usr/local/lib/ + /usr/lib/i386-linux-gnu/ + /usr/lib/x86_64-linux-gnu/ + /usr/lib64/ + /usr/lib/ + ) + set (LIBRT_DYNAMIC "Using dynamic library.") + endif (NOT LIBRT_LIBRARIES) + + if (LIBRT_INCLUDE_DIR AND LIBRT_LIBRARIES) + set (LIBRT_FOUND TRUE) + endif (LIBRT_INCLUDE_DIR AND LIBRT_LIBRARIES) + + if (LIBRT_FOUND) + message(STATUS "Found librt: ${LIBRT_INCLUDE_DIR}, ${LIBRT_LIBRARIES} ${LIBRT_DYNAMIC}") + else (LIBRT_FOUND) + if (Librt_FIND_REQUIRED) + message (FATAL_ERROR "Could not find librt, try to setup LIBRT_PREFIX accordingly") + endif (Librt_FIND_REQUIRED) + endif (LIBRT_FOUND) + +endif (NOT LIBRT_FOUND) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index e29812f11b..190faffa31 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -21,6 +21,20 @@ find_package(GLUT REQUIRED) find_package(GLM REQUIRED) find_package(LodePNG REQUIRED) +if (UNIX AND NOT APPLE) + find_package(Threads REQUIRED) + find_package(Librt REQUIRED) + find_package(Jack REQUIRED) + find_package(ALSA REQUIRED) + + target_link_libraries(interface + ${CMAKE_THREAD_LIBS_INIT} + ${LIBRT_LIBRARIES} + ${JACK_LIBRARIES} + ${ALSA_LIBRARIES} + ) +endif (UNIX AND NOT APPLE) + include_directories( ${OPENGL_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS}