Skip to content

Commit

Permalink
Improve vcpkg manifest, use features for build options.
Browse files Browse the repository at this point in the history
Now pulling in the required vcpkg dependencies only if a certain build feature is requested.
  • Loading branch information
kblaschke committed Aug 7, 2024
1 parent 6d20977 commit db035da
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 18 deletions.
36 changes: 28 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,34 @@ set(CMAKE_CXX_VISIBILITY_PRESET hidden)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# General build options
option(ENABLE_SYSTEM_GLM "Enable use of system-install GLM library" OFF)
option(ENABLE_SYSTEM_PROJECTM_EVAL "Enable use of a system-installed/external projectM-eval library" ON)
option(ENABLE_DEBUG_POSTFIX "Add \"d\" (by default) after library names for debug builds." ON)
option(ENABLE_PLAYLIST "Enable building the playlist management library" ON)
option(ENABLE_BOOST_FILESYSTEM "Force the use of boost::filesystem, even if the compiler supports C++17." OFF)
option(ENABLE_SDL_UI "Build the SDL2-based developer test UI. Ignored when building with Emscripten or for Android." OFF)

option(BUILD_TESTING "Build the libprojectM test suite" OFF)
option(BUILD_DOCS "Build documentation" OFF)

# Enable vcpkg manifest features according to the build options set
if(ENABLE_SYSTEM_GLM)
list(APPEND VCPKG_MANIFEST_FEATURES external-glm)
endif()
if(ENABLE_SYSTEM_PROJECTM_EVAL)
list(APPEND VCPKG_MANIFEST_FEATURES external-evallib)
endif()
if(ENABLE_BOOST_FILESYSTEM)
list(APPEND VCPKG_MANIFEST_FEATURES boost-filesystem)
endif()
if(ENABLE_SDL_UI)
list(APPEND VCPKG_MANIFEST_FEATURES gui)
endif()
if(BUILD_TESTING)
list(APPEND VCPKG_MANIFEST_FEATURES test)
endif()

if(ENABLE_DEBUG_POSTFIX)
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Output file debug postfix. Default is \"d\".")
endif()
Expand Down Expand Up @@ -65,17 +92,10 @@ else()
set(ENABLE_EMSCRIPTEN OFF CACHE BOOL "Build for web with emscripten. Requires emscripten toolset for building." FORCE)
endif()

# Feature options, including dependencies.
option(BUILD_TESTING "Build the libprojectM test suite" OFF)
# Compiler-/system-dependent options, including dependencies.
cmake_dependent_option(BUILD_SHARED_LIBS "Build and install libprojectM as a shared libraries. If OFF, builds as static libraries." ON "NOT ENABLE_EMSCRIPTEN" OFF)
option(ENABLE_PLAYLIST "Enable building the playlist management library" ON)
cmake_dependent_option(ENABLE_SDL_UI "Build the SDL2-based developer test UI" OFF "NOT ENABLE_EMSCRIPTEN" OFF)
cmake_dependent_option(ENABLE_GLES "Enable OpenGL ES support" OFF "NOT ENABLE_EMSCRIPTEN AND NOT CMAKE_SYSTEM_NAME STREQUAL Android" ON)
option(ENABLE_BOOST_FILESYSTEM "Force the use of boost::filesystem, even if the compiler supports C++17." OFF)
cmake_dependent_option(ENABLE_INSTALL "Enable installing projectM libraries and headers." OFF "NOT PROJECT_IS_TOP_LEVEL" ON)
option(ENABLE_SYSTEM_GLM "Enable use of system-install GLM library" OFF)
option(ENABLE_SYSTEM_PROJECTM_EVAL "Enable use of a system-installed/external projectM-eval library" ON)
option(BUILD_DOCS "Build documentation" OFF)

# Experimental/unsupported features
option(ENABLE_CXX_INTERFACE "Enable exporting C++ symbols for ProjectM and PCM classes, not only the C API. Warning: This is not very portable." OFF)
Expand Down
2 changes: 1 addition & 1 deletion src/sdl-test-ui/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if(NOT ENABLE_SDL_UI)
if(NOT ENABLE_SDL_UI OR ENABLE_EMSCRIPTEN OR CMAKE_SYSTEM_NAME STREQUAL Android)
return()
endif()

Expand Down
3 changes: 1 addition & 2 deletions vcpkg-configuration.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg-configuration.schema.json",
"default-registry": {
"kind": "git",
"baseline": "815d93b520779e4354bb4b954fc2179b3e520c26",
"baseline": "a0f7f5379aa39d638efb1b89ac88a39c1011e4aa",
"repository": "https://github.com/microsoft/vcpkg"
}
}
53 changes: 47 additions & 6 deletions vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,49 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "projectm",
"version": "4.1.2",
"description": "projectM is an open-source project that reimplements the esteemed Winamp Milkdrop by Geiss in a more modern, cross-platform reusable library.",
"homepage": "https://github.com/projectM-visualizer/projectm",
"license": "LGPL-2.1-only",
"dependencies": [
"glew",
"gtest",
"sdl2"
]
}
{
"name": "glew",
"platform": "windows"
}
],
"default-features": [
"external-glm",
"external-evallib"
],
"features": {
"external-glm": {
"description": "Use external GLM headers instead of the built-in ones",
"dependencies": [
"glm"
]
},
"external-evallib": {
"description": "Use external projectm-eval library instead of the Git submodule",
"dependencies": [
"projectm-eval"
]
},
"gui": {
"description": "Build a simple, SDL2-based development test UI",
"dependencies": [
"sdl2"
]
},
"boost-filesystem": {
"description": "Force using boost::filesystem instead of std::filesystem",
"dependencies": [
"boost-filesystem"
]
},
"test": {
"description": "Build unit tests",
"dependencies": [
"gtest"
]
}
}
}

0 comments on commit db035da

Please sign in to comment.