tInitial support for plugins. - vaccinewars - be a doctor and try to vaccinate … | |
git clone git://src.adamsgaard.dk/vaccinewars | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 4babd3f50a5087c0bdd753dd2ee97b1802ca9675 | |
parent f2d9ed4d35d05763c0dc5c35097b26d11724ee57 | |
Author: Ben Webb <[email protected]> | |
Date: Mon, 30 Mar 2015 23:21:20 -0700 | |
Initial support for plugins. | |
Diffstat: | |
M CMakeLists.txt | 32 +++++++++++++++++++++++++++++… | |
A cmake_modules/FindDL.cmake | 17 +++++++++++++++++ | |
M config-cmake.h.in | 6 +++--- | |
A src/plugins/CMakeLists.txt | 7 +++++++ | |
4 files changed, 59 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/CMakeLists.txt b/CMakeLists.txt | |
t@@ -10,6 +10,7 @@ include(GNUInstallDirs) | |
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |
${PROJECT_SOURCE_DIR}/cmake_modules) | |
include(${PROJECT_SOURCE_DIR}/cmake_modules/FindGLIB.cmake) | |
+include(${PROJECT_SOURCE_DIR}/cmake_modules/FindDL.cmake) | |
# Find source headers | |
include_directories("${PROJECT_SOURCE_DIR}/src") | |
t@@ -45,6 +46,7 @@ option(NETWORKING | |
option(WITH_ESD "support ESD sound output" ON) | |
option(WITH_SDL "support SDL sound output" ON) | |
+option(PLUGINS "use dynamically-loaded sound modules" ON) | |
find_package(GLIB) | |
if (!GLIB_FOUND) | |
t@@ -85,6 +87,36 @@ if (GUI_CLIENT OR GUI_SERVER) | |
endif() | |
endif() | |
+if (PLUGINS) | |
+ find_package(DL) | |
+ if (DL_FOUND) | |
+ include_directories(${DL_INCLUDE_DIR}) | |
+ set(EXTRA_LIBS ${EXTRA_LIBS} ${DL_LIBRARIES}) | |
+ else() | |
+ set(PLUGINS OFF) | |
+ endif() | |
+endif() | |
+ | |
+if (PLUGINS) | |
+ # Add esound support if available | |
+ find_package(ESD) | |
+ if (ESD_FOUND) | |
+ include_directories(${ESD_INCLUDE_DIR}) | |
+ set(SOUND_LIBS ${SOUND_LIBS} ${ESD_LIBRARY}) | |
+ set(HAVE_ESD ON) | |
+ endif() | |
+ | |
+ # Add SDL_mixer sound support if available | |
+ find_package(SDL_mixer) | |
+ if (SDL_MIXER_FOUND) | |
+ include_directories(${SDL_MIXER_INCLUDE_DIRS}) | |
+ set(SOUND_LIBS ${SOUND_LIBS} ${SDL_MIXER_LIBRARIES}) | |
+ set(HAVE_SDL_MIXER ON) | |
+ endif() | |
+endif() | |
+ | |
+add_subdirectory("src/plugins") | |
+ | |
configure_file("${PROJECT_SOURCE_DIR}/config-cmake.h.in" | |
"${PROJECT_BINARY_DIR}/config.h") | |
diff --git a/cmake_modules/FindDL.cmake b/cmake_modules/FindDL.cmake | |
t@@ -0,0 +1,17 @@ | |
+# - find where dlopen and friends are located. | |
+# DL_FOUND - system has dynamic linking interface available | |
+# DL_INCLUDE_DIR - where dlfcn.h is located. | |
+# DL_LIBRARIES - libraries needed to use dlopen | |
+ | |
+include(CheckFunctionExists) | |
+ | |
+find_path(DL_INCLUDE_DIR NAMES dlfcn.h) | |
+find_library(DL_LIBRARIES NAMES dl) | |
+if(DL_LIBRARIES) | |
+set(DL_FOUND) | |
+else(DL_LIBRARIES) | |
+check_function_exists(dlopen DL_FOUND) | |
+# If dlopen can be found without linking in dl then dlopen is part | |
+# of libc, so don't need to link extra libs. | |
+set(DL_LIBRARIES "") | |
+endif(DL_LIBRARIES) | |
diff --git a/config-cmake.h.in b/config-cmake.h.in | |
t@@ -82,7 +82,7 @@ | |
#undef HAVE_MEMORY_H | |
/* Do we have the SDL_mixer sound library? */ | |
-#undef HAVE_SDL_MIXER | |
+#cmakedefine HAVE_SDL_MIXER | |
/* Define to 1 if you have the `select' function. */ | |
#cmakedefine HAVE_SELECT | |
t@@ -164,10 +164,10 @@ | |
#undef PACKAGE_VERSION | |
/* The directory containing the plugins */ | |
-#undef PLUGINDIR | |
+#define PLUGINDIR "@CMAKE_INSTALL_FULL_LIBDIR@/dopewars" | |
/* Define if using dynamically-loaded sound modules */ | |
-#undef PLUGINS | |
+#cmakedefine PLUGINS | |
/* The size of `long long', as computed by sizeof. */ | |
#undef SIZEOF_LONG_LONG | |
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt | |
t@@ -0,0 +1,7 @@ | |
+if (HAVE_ESD) | |
+ add_library(libsound_esd MODULE sound_esd.c) | |
+endif() | |
+ | |
+if (HAVE_SDL_MIXER) | |
+ add_library(libsound_sdl MODULE sound_sdl.c) | |
+endif() |