Skip to content

Commit

Permalink
Completely skip compiling native preset loading code if disabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
kblaschke committed Nov 5, 2021
1 parent 3142a41 commit 1f2d081
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ cmake_dependent_option(ENABLE_SHARED_LINKING "Link all built UI applications aga
option(ENABLE_DOXYGEN "Build and install Doxygen source code documentation in PROJECTM_DATADIR_PATH/docs." OFF)
option(ENABLE_CXX_INTERFACE "Enable exporting all C++ symbols, not only the C API, in the shared library. Warning: This is not very portable." OFF)
option(ENABLE_PRESETS "Build and install bundled presets" ON)
option(ENABLE_NATIVE_PRESETS "Build and install native libraries written in C/C++" OFF)
option(ENABLE_NATIVE_PRESETS "Build and install native preset loading support and preset libraries written in C/C++" OFF)
option(ENABLE_TESTING "Build and install the projectM test suite" OFF)
option(ENABLE_EMSCRIPTEN "Build for web with emscripten" OFF)
cmake_dependent_option(ENABLE_SDL "Enable SDL2 support" ON "NOT ENABLE_EMSCRIPTEN;NOT ENABLE_TESTING" ON)
Expand Down
3 changes: 3 additions & 0 deletions config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,8 @@
/* Define USE_THREADS */
#cmakedefine01 USE_THREADS

/* Define ENABLE_NATIVE_PRESETS */
#cmakedefine ENABLE_NATIVE_PRESETS

/* Version number of package */
#define VERSION "@PROJECT_VERSION@"
17 changes: 10 additions & 7 deletions src/libprojectM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
)
endif()

# List of targets used in export().
# Optional libraries will be added to the list as configured in the build options.
set(EXPORTED_TARGETS
MilkdropPresetFactory
Renderer
hlslparser
SOIL2
)

add_subdirectory(MilkdropPresetFactory)
add_subdirectory(NativePresetFactory)
add_subdirectory(Renderer)
Expand Down Expand Up @@ -147,13 +156,7 @@ endif()

# For use from a local projectM build tree (without installing)
export(TARGETS
MilkdropPresetFactory
NativePresetFactory
Renderer
hlslparser
SOIL2
${EXPORT_STATIC_LIB_TARGET}
${EXPORT_SHARED_LIB_TARGET}
${EXPORTED_TARGETS}
NAMESPACE libprojectM::
FILE projectM-exports.cmake
)
Expand Down
6 changes: 6 additions & 0 deletions src/libprojectM/NativePresetFactory/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(NOT ENABLE_NATIVE_PRESETS)
return()
endif()

add_library(NativePresetFactory OBJECT
MilkdropCompatability.hpp
NativePreset.hpp
Expand All @@ -22,3 +26,5 @@ target_link_libraries(NativePresetFactory
set_target_properties(NativePresetFactory PROPERTIES
FOLDER libprojectM
)

set(EXPORTED_TARGETS ${EXPORTED_TARGETS} NativePresetFactory PARENT_SCOPE)
15 changes: 6 additions & 9 deletions src/libprojectM/PresetFactoryManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,16 @@
//
//
#include "PresetFactoryManager.hpp"

#ifndef DISABLE_MILKDROP_PRESETS
#include "MilkdropPresetFactory/MilkdropPresetFactory.hpp"
#endif

#ifndef DISABLE_NATIVE_PRESETS
#ifdef ENABLE_NATIVE_PRESETS
#include "NativePresetFactory/NativePresetFactory.hpp"
#endif

#include "config.h"
#include "Common.hpp"
#include <sstream>

PresetFactoryManager::PresetFactoryManager() : _gx(0), _gy(0), initialized(false) {}

PresetFactoryManager::~PresetFactoryManager() {
Expand All @@ -45,13 +44,11 @@ void PresetFactoryManager::initialize(int gx, int gy) {
}

PresetFactory * factory;

#ifndef DISABLE_MILKDROP_PRESETS

factory = new MilkdropPresetFactory(_gx, _gy);
registerFactory(factory->supportedExtensions(), factory);
#endif

#ifndef DISABLE_NATIVE_PRESETS

#ifdef ENABLE_NATIVE_PRESETS
factory = new NativePresetFactory();
registerFactory(factory->supportedExtensions(), factory);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/libprojectM/libprojectM_shared.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_library(projectM_shared SHARED

$<TARGET_OBJECTS:projectM_main>
$<TARGET_OBJECTS:MilkdropPresetFactory>
$<TARGET_OBJECTS:NativePresetFactory>
$<$<TARGET_EXISTS:NativePresetFactory>:$<TARGET_OBJECTS:NativePresetFactory>>
$<TARGET_OBJECTS:Renderer>
$<TARGET_OBJECTS:hlslparser>
$<TARGET_OBJECTS:SOIL2>
Expand Down Expand Up @@ -76,4 +76,4 @@ install(TARGETS projectM_shared
COMPONENT Runtime
)

set(EXPORT_SHARED_LIB_TARGET projectM_shared)
list(APPEND EXPORTED_TARGETS projectM_shared)
4 changes: 2 additions & 2 deletions src/libprojectM/libprojectM_static.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ add_library(projectM_static STATIC

$<TARGET_OBJECTS:projectM_main>
$<TARGET_OBJECTS:MilkdropPresetFactory>
$<TARGET_OBJECTS:NativePresetFactory>
$<$<TARGET_EXISTS:NativePresetFactory>:$<TARGET_OBJECTS:NativePresetFactory>>
$<TARGET_OBJECTS:Renderer>
$<TARGET_OBJECTS:hlslparser>
$<TARGET_OBJECTS:SOIL2>
Expand Down Expand Up @@ -71,7 +71,7 @@ install(TARGETS projectM_static
COMPONENT Runtime
)

set(EXPORT_SHARED_LIB_TARGET projectM_static)
list(APPEND EXPORTED_TARGETS projectM_static)


# pkg-config export, only supports static library on UNIX systems.
Expand Down

0 comments on commit 1f2d081

Please sign in to comment.