Skip to content

Commit

Permalink
- Added build checks on whether to use old or newer style of LV2 incl…
Browse files Browse the repository at this point in the history
…ude headers. (EXPERIMENTAL)
  • Loading branch information
rncbc committed Jan 25, 2024
1 parent d37f2fe commit d99eafb
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 9 deletions.
33 changes: 30 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,27 @@ if (CONFIG_LV2)
pkg_check_modules (LV2 lv2)
if (LV2_FOUND)
include_directories (${LV2_INCLUDE_DIRS})
# Check for LV2 old/new headers style.
check_include_file (lv2/urid/urid.h HAVE_LV2_URID_H)
if (NOT HAVE_LV2_URID_H)
check_include_file (lv2/lv2plug.in/ns/ext/urid/urid.h HAVE_LV2_URID_H)
if (NOT HAVE_LV2_URID_H)
set (CONFIG_LV2 0)
else ()
set (CONFIG_LV2_OLD_HEADERS 1)
endif ()
else ()
set (CONFIG_LV2_OLD_HEADERS 0)
endif ()
endif ()

if (CONFIG_LV2)
# Check for LV2 Atom support.
check_include_file (lv2/lv2plug.in/ns/ext/atom/atom.h HAVE_LV2_ATOM_H)
if (CONFIG_LV2_OLD_HEADERS)
check_include_file (lv2/lv2plug.in/ns/ext/atom/atom.h HAVE_LV2_ATOM_H)
else ()
check_include_file (lv2/atom/atom.h HAVE_LV2_ATOM_H)
endif ()
if (NOT HAVE_LV2_ATOM_H)
set (CONFIG_LV2_ATOM 0)
else ()
Expand All @@ -232,7 +251,11 @@ if (CONFIG_LV2)
set (CONFIG_LV2_ATOM_FORGE_OBJECT ${CONFIG_LV2_ATOM})
set (CONFIG_LV2_ATOM_FORGE_KEY ${CONFIG_LV2_ATOM})
# Check for LV2 UI support.
check_include_file (lv2/lv2plug.in/ns/extensions/ui/ui.h HAVE_LV2_UI_H)
if (CONFIG_LV2_OLD_HEADERS)
check_include_file (lv2/lv2plug.in/ns/extensions/ui/ui.h HAVE_LV2_UI_H)
else ()
check_include_file (lv2/ui/ui.h HAVE_LV2_UI_H)
endif ()
if (NOT HAVE_LV2_UI_H)
set (CONFIG_LV2_UI 0)
else ()
Expand Down Expand Up @@ -285,7 +308,11 @@ if (CONFIG_LV2_PROGRAMS)
endif ()

if (CONFIG_LV2_PATCH)
check_include_file (lv2/lv2plug.in/ns/ext/patch/patch.h HAVE_LV2_PATCH_H)
if (CONFIG_LV2_OLD_HEADERS)
check_include_file (lv2/lv2plug.in/ns/ext/patch/patch.h HAVE_LV2_PATCH_H)
else ()
check_include_file (lv2/patch/patch.h HAVE_LV2_PATCH_H)
endif ()
if (NOT HAVE_LV2_PATCH_H)
set (CONFIG_LV2_PATCH 0)
endif ()
Expand Down
3 changes: 3 additions & 0 deletions src/config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@
/* Define if LV2 plug-in build is enabled. */
#cmakedefine CONFIG_LV2 @CONFIG_LV2@

/* Define if LV2 old headers are enabled. */
#cmakedefine CONFIG_LV2_OLD_HEADERS @CONFIG_LV2_OLD_HEADERS@

/* Define if lv2_atom_forge_object is available. */
#cmakedefine CONFIG_LV2_ATOM_FORGE_OBJECT @CONFIG_LV2_ATOM_FORGE_OBJECT@

Expand Down
16 changes: 13 additions & 3 deletions src/synthv1_lv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@
#include "synthv1_programs.h"
#include "synthv1_controls.h"

#ifdef CONFIG_OLD_HEADERS
#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include "lv2/lv2plug.in/ns/ext/time/time.h"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"

#include "lv2/lv2plug.in/ns/ext/state/state.h"

#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/ext/buf-size/buf-size.h"

#ifdef CONFIG_LV2_PATCH
#include "lv2/lv2plug.in/ns/ext/patch/patch.h"
#endif
#else
#include "lv2/midi/midi.h"
#include "lv2/time/time.h"
#include "lv2/atom/util.h"
#include "lv2/state/state.h"
#include "lv2/options/options.h"
#include "lv2/buf-size/buf-size.h"
#ifdef CONFIG_LV2_PATCH
#include "lv2/patch/patch.h"
#endif
#endif


#ifndef CONFIG_LV2_ATOM_FORGE_OBJECT
#define lv2_atom_forge_object(forge, frame, id, otype) \
Expand Down
6 changes: 6 additions & 0 deletions src/synthv1_lv2.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@

#include "synthv1.h"

#ifdef CONFIG_OLD_HEADERS
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "lv2/lv2plug.in/ns/ext/atom/forge.h"
#else
#include "lv2/urid/urid.h"
#include "lv2/atom/atom.h"
#include "lv2/atom/forge.h"
#endif

#include "lv2/lv2plug.in/ns/ext/worker/worker.h"

Expand Down
6 changes: 5 additions & 1 deletion src/synthv1_lv2ui.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// synthv1_lv2ui.cpp
//
/****************************************************************************
Copyright (C) 2012-2021, rncbc aka Rui Nuno Capela. All rights reserved.
Copyright (C) 2012-2024, rncbc aka Rui Nuno Capela. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Expand All @@ -22,7 +22,11 @@
#include "synthv1_lv2ui.h"
#include "synthv1_lv2.h"

#ifdef CONFIG_LV2_OLD_HEADERS
#include "lv2/lv2plug.in/ns/ext/instance-access/instance-access.h"
#else
#include "lv2/instance-access/instance-access.h"
#endif

#include <synthv1widget_lv2.h>

Expand Down
7 changes: 5 additions & 2 deletions src/synthv1_lv2ui.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// synthv1_lv2ui.h
//
/****************************************************************************
Copyright (C) 2012-2021, rncbc aka Rui Nuno Capela. All rights reserved.
Copyright (C) 2012-2024, rncbc aka Rui Nuno Capela. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
Expand All @@ -24,8 +24,11 @@

#include "synthv1_ui.h"

#ifdef CONFIG_LV2_OLD_HEADERS
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"

#else
#include "lv2/ui/ui.h"
#endif

#define SYNTHV1_LV2UI_URI SYNTHV1_LV2_PREFIX "ui"

Expand Down

0 comments on commit d99eafb

Please sign in to comment.