Skip to content

Commit 1f2d081

Browse files
committed
Completely skip compiling native preset loading code if disabled.
1 parent 3142a41 commit 1f2d081

File tree

7 files changed

+30
-21
lines changed

7 files changed

+30
-21
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cmake_dependent_option(ENABLE_SHARED_LINKING "Link all built UI applications aga
4343
option(ENABLE_DOXYGEN "Build and install Doxygen source code documentation in PROJECTM_DATADIR_PATH/docs." OFF)
4444
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)
4545
option(ENABLE_PRESETS "Build and install bundled presets" ON)
46-
option(ENABLE_NATIVE_PRESETS "Build and install native libraries written in C/C++" OFF)
46+
option(ENABLE_NATIVE_PRESETS "Build and install native preset loading support and preset libraries written in C/C++" OFF)
4747
option(ENABLE_TESTING "Build and install the projectM test suite" OFF)
4848
option(ENABLE_EMSCRIPTEN "Build for web with emscripten" OFF)
4949
cmake_dependent_option(ENABLE_SDL "Enable SDL2 support" ON "NOT ENABLE_EMSCRIPTEN;NOT ENABLE_TESTING" ON)

config.h.cmake.in

+3
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,8 @@
6969
/* Define USE_THREADS */
7070
#cmakedefine01 USE_THREADS
7171

72+
/* Define ENABLE_NATIVE_PRESETS */
73+
#cmakedefine ENABLE_NATIVE_PRESETS
74+
7275
/* Version number of package */
7376
#define VERSION "@PROJECT_VERSION@"

src/libprojectM/CMakeLists.txt

+10-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
2828
)
2929
endif()
3030

31+
# List of targets used in export().
32+
# Optional libraries will be added to the list as configured in the build options.
33+
set(EXPORTED_TARGETS
34+
MilkdropPresetFactory
35+
Renderer
36+
hlslparser
37+
SOIL2
38+
)
39+
3140
add_subdirectory(MilkdropPresetFactory)
3241
add_subdirectory(NativePresetFactory)
3342
add_subdirectory(Renderer)
@@ -147,13 +156,7 @@ endif()
147156

148157
# For use from a local projectM build tree (without installing)
149158
export(TARGETS
150-
MilkdropPresetFactory
151-
NativePresetFactory
152-
Renderer
153-
hlslparser
154-
SOIL2
155-
${EXPORT_STATIC_LIB_TARGET}
156-
${EXPORT_SHARED_LIB_TARGET}
159+
${EXPORTED_TARGETS}
157160
NAMESPACE libprojectM::
158161
FILE projectM-exports.cmake
159162
)

src/libprojectM/NativePresetFactory/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
if(NOT ENABLE_NATIVE_PRESETS)
2+
return()
3+
endif()
4+
15
add_library(NativePresetFactory OBJECT
26
MilkdropCompatability.hpp
37
NativePreset.hpp
@@ -22,3 +26,5 @@ target_link_libraries(NativePresetFactory
2226
set_target_properties(NativePresetFactory PROPERTIES
2327
FOLDER libprojectM
2428
)
29+
30+
set(EXPORTED_TARGETS ${EXPORTED_TARGETS} NativePresetFactory PARENT_SCOPE)

src/libprojectM/PresetFactoryManager.cpp

+6-9
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@
1010
//
1111
//
1212
#include "PresetFactoryManager.hpp"
13-
14-
#ifndef DISABLE_MILKDROP_PRESETS
1513
#include "MilkdropPresetFactory/MilkdropPresetFactory.hpp"
16-
#endif
1714

18-
#ifndef DISABLE_NATIVE_PRESETS
15+
#ifdef ENABLE_NATIVE_PRESETS
1916
#include "NativePresetFactory/NativePresetFactory.hpp"
2017
#endif
2118

19+
#include "config.h"
2220
#include "Common.hpp"
2321
#include <sstream>
22+
2423
PresetFactoryManager::PresetFactoryManager() : _gx(0), _gy(0), initialized(false) {}
2524

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

4746
PresetFactory * factory;
48-
49-
#ifndef DISABLE_MILKDROP_PRESETS
47+
5048
factory = new MilkdropPresetFactory(_gx, _gy);
5149
registerFactory(factory->supportedExtensions(), factory);
52-
#endif
53-
54-
#ifndef DISABLE_NATIVE_PRESETS
50+
51+
#ifdef ENABLE_NATIVE_PRESETS
5552
factory = new NativePresetFactory();
5653
registerFactory(factory->supportedExtensions(), factory);
5754
#endif

src/libprojectM/libprojectM_shared.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ add_library(projectM_shared SHARED
55

66
$<TARGET_OBJECTS:projectM_main>
77
$<TARGET_OBJECTS:MilkdropPresetFactory>
8-
$<TARGET_OBJECTS:NativePresetFactory>
8+
$<$<TARGET_EXISTS:NativePresetFactory>:$<TARGET_OBJECTS:NativePresetFactory>>
99
$<TARGET_OBJECTS:Renderer>
1010
$<TARGET_OBJECTS:hlslparser>
1111
$<TARGET_OBJECTS:SOIL2>
@@ -76,4 +76,4 @@ install(TARGETS projectM_shared
7676
COMPONENT Runtime
7777
)
7878

79-
set(EXPORT_SHARED_LIB_TARGET projectM_shared)
79+
list(APPEND EXPORTED_TARGETS projectM_shared)

src/libprojectM/libprojectM_static.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ add_library(projectM_static STATIC
55

66
$<TARGET_OBJECTS:projectM_main>
77
$<TARGET_OBJECTS:MilkdropPresetFactory>
8-
$<TARGET_OBJECTS:NativePresetFactory>
8+
$<$<TARGET_EXISTS:NativePresetFactory>:$<TARGET_OBJECTS:NativePresetFactory>>
99
$<TARGET_OBJECTS:Renderer>
1010
$<TARGET_OBJECTS:hlslparser>
1111
$<TARGET_OBJECTS:SOIL2>
@@ -71,7 +71,7 @@ install(TARGETS projectM_static
7171
COMPONENT Runtime
7272
)
7373

74-
set(EXPORT_SHARED_LIB_TARGET projectM_static)
74+
list(APPEND EXPORTED_TARGETS projectM_static)
7575

7676

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

0 commit comments

Comments
 (0)