Skip to content

Commit

Permalink
Move to the sst-plugininfra version code; reorganize the cmake (#1474)
Browse files Browse the repository at this point in the history
Still to do: port the basic installer out, move to the clap first
cmake.
  • Loading branch information
baconpaul authored Jan 17, 2025
1 parent 79c938d commit 990260b
Show file tree
Hide file tree
Showing 15 changed files with 94 additions and 365 deletions.
76 changes: 7 additions & 69 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,17 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# TODO Remove This before we ship non beta version. Remember
# the AU rescans only when versions change even if binaries are
# different.
message(STATUS "ShortcircuitXT: Using date-driven version while in alpha")
string(TIMESTAMP DAY_OF_YEAR "%j")
string(TIMESTAMP YEAR "%Y")
math(EXPR PART0 "${YEAR}-2023 + 6")
math(EXPR PART1 "${DAY_OF_YEAR} + 1")

project(ShortcircuitXT VERSION 0.${PART0}.${PART1}.0 LANGUAGES C CXX ASM)
set(ShortcircuitXT_VERSION ${PROJECT_VERSION})
message(STATUS "ShortcircuitXT: Using date-driven version while in alpha - ${PROJECT_VERSION}")

if (APPLE)
enable_language(OBJC)
enable_language(OBJCXX)
set(CMAKE_OBJC_VISIBILITY_PRESET hidden)
set(CMAKE_OBJCXX_VISIBILITY_PRESET hidden)
if( ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "15.0.0" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "15.1")
add_link_options(-Wl,-ld_classic)
add_compile_definitions(JUCE_SILENCE_XCODE_15_LINKER_WARNING=1)
endif()
endif ()

set(BUILD_SHARED_LIBS OFF CACHE BOOL "Never want shared if not specified")
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

include(libs/sst/sst-plugininfra/cmake/git-version-functions.cmake)
version_from_versionfile_or_git()

# Build Time Options
option(SCXT_BUILD_VST3 "Build a VST3 plugin" ON)
Expand Down Expand Up @@ -78,74 +62,28 @@ else()
option(SCXT_USE_CLAP_WRAPPER_STANDALONE "Build with the clap wrapper standalone rather than our temp one" OFF)
endif()

# Calculate bitness
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
if (NOT ${BITS} EQUAL 64)
message(WARNING "${PROJECT_NAME} has only been tested on 64 bits. This may not work")
endif ()

# Share some information about the build
message(STATUS "Shortcircuit XT ${CMAKE_PROJECT_VERSION}")
message(STATUS "Compiler Version is ${CMAKE_CXX_COMPILER_VERSION}")
if (MSVC)
message(STATUS "Windows Architecture is ${CMAKE_GENERATOR_PLATFORM}")
endif()

# Everything here is C++ 17 now
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND UNIX AND NOT APPLE AND NOT SCXT_SKIP_PIE_CHANGE)
message(STATUS "Setting -no-pie on EXE flags; use SCXT_SKIP_PIE_CHANGE=TRUE to avoid")
set(CMAKE_EXE_LINKER_FLAGS "-no-pie")
endif ()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
if (${SCXT_SANITIZE})
message(STATUS "Sanitizer is ON")
endif ()

# BP note: If you want to turn on llvm/gcc sanitize, remove this and the link options below
add_compile_options(
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=address>
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=undefined>
)

add_link_options(
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=address>
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=undefined>
)
endif ()

add_compile_definitions(SCXT_ROOT_BUILD_DIR="${CMAKE_SOURCE_DIR}")

include(cmake/compiler-and-git.cmake)
include(cmake/compiler-options.cmake)
include(cmake/CmakeRC.cmake)

# Setup libraries
add_subdirectory(libs)


# Next for now
add_subdirectory(src)
add_subdirectory(resources)
add_subdirectory(src-ui)
add_subdirectory(tests)
add_subdirectory(clients)

include(cmake/basic-installer.cmake)

include(cmake/basic-installer.cmake)

add_custom_target(scxt-code-checks)

# Clang Format checks
find_program(CLANG_FORMAT_EXE NAMES clang-format-12 clang-format)
set(CLANG_FORMAT_DIRS src src-ui tests clients)
set(CLANG_FORMAT_EXTS cpp h)
foreach (dir ${CLANG_FORMAT_DIRS})
foreach (ext ${CLANG_FORMAT_EXTS})
list(APPEND CLANG_FORMAT_GLOBS "':(glob)${dir}/**/*.${ext}'")
endforeach ()
endforeach ()
add_custom_command(TARGET scxt-code-checks
POST_BUILD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -E echo About to check clang-format using ${CLANG_FORMAT_EXE}
COMMAND git ls-files -- ${CLANG_FORMAT_GLOBS} | xargs ${CLANG_FORMAT_EXE} --dry-run --Werror
)
# }}}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#include <juce_audio_utils/juce_audio_utils.h>
#include "utils.h"

#include "version.h"

#include "engine/engine.h"
#include "app/SCXTEditor.h"
#include "sst/voicemanager/midi1_to_voicemanager.h"
Expand Down
23 changes: 12 additions & 11 deletions clients/clap-first/scxt-plugin/scxt-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <chrono>

#include "scxt-plugin.h"
#include "version.h"
#include "sst/plugininfra/version_information.h"
#include "app/SCXTEditor.h"

namespace scxt::clap_first::scxt_plugin
Expand All @@ -39,16 +39,17 @@ const clap_plugin_descriptor *getDescription()
static const char *features[] = {CLAP_PLUGIN_FEATURE_INSTRUMENT, CLAP_PLUGIN_FEATURE_SAMPLER,
CLAP_PLUGIN_FEATURE_SYNTHESIZER, "Free and Open Source",
nullptr};
static clap_plugin_descriptor desc = {CLAP_VERSION,
"org.surge-synth-team.shortcircuit-xt",
"Shortcircuit XT",
"Surge Synth Team",
"https://surge-synth-team.org",
"",
"",
scxt::build::FullVersionStr,
"The Flagship Creative Sampler from the Surge Synth Team",
&features[0]};
static clap_plugin_descriptor desc = {
CLAP_VERSION,
"org.surge-synth-team.shortcircuit-xt",
"Shortcircuit XT",
"Surge Synth Team",
"https://surge-synth-team.org",
"",
"",
sst::plugininfra::VersionInformation::project_version_and_hash,
"The Flagship Creative Sampler from the Surge Synth Team",
&features[0]};
return &desc;
}

Expand Down
17 changes: 0 additions & 17 deletions cmake/code-quality.cmake

This file was deleted.

80 changes: 51 additions & 29 deletions cmake/compiler-and-git.cmake → cmake/compiler-options.cmake
Original file line number Diff line number Diff line change
@@ -1,38 +1,60 @@
# Set up version information using the same approach as surge, namely
# with an external cmake run, a git-info target, and a generated
# ${bld}/geninclude/version.cpp

add_custom_target(version-info BYPRODUCTS ${CMAKE_BINARY_DIR}/geninclude/version.cpp
DEPENDS ${CMAKE_SOURCE_DIR}/cmake/version.h
${CMAKE_SOURCE_DIR}/cmake/version.cpp.in
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND}
-D PROJECT_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
-D PROJECT_VERSION_MINOR=${PROJECT_VERSION_MINOR}
-D SHORTCSRC=${CMAKE_SOURCE_DIR}
-D SHORTCBLD=${CMAKE_BINARY_DIR}
-D AZURE_PIPELINE=${AZURE_PIPELINE}
-D WIN32=${WIN32}
-D CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}
-D CMAKE_CXX_COMPILER_VERSION=${CMAKE_CXX_COMPILER_VERSION}
-P ${CMAKE_SOURCE_DIR}/cmake/versiontools.cmake
)

# Calculate bitness
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
if (NOT ${BITS} EQUAL 64)
message(WARNING "${PROJECT_NAME} has only been tested on 64 bits. This may not work")
endif ()


# Everything here is C++ 17 now
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND UNIX AND NOT APPLE AND NOT SCXT_SKIP_PIE_CHANGE)
message(STATUS "Setting -no-pie on EXE flags; use SCXT_SKIP_PIE_CHANGE=TRUE to avoid")
set(CMAKE_EXE_LINKER_FLAGS "-no-pie")
endif ()

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
if (${SCXT_SANITIZE})
message(STATUS "Sanitizer is ON")
endif ()

# BP note: If you want to turn on llvm/gcc sanitize, remove this and the link options below
add_compile_options(
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=address>
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=undefined>
)

add_link_options(
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=address>
$<$<BOOL:${SCXT_SANITIZE}>:-fsanitize=undefined>
)
endif ()


# Platform Specific Compile Settings
add_library(sc-compiler-options)
add_library(sc-compiler-options INTERFACE)

target_sources(sc-compiler-options PRIVATE ${CMAKE_BINARY_DIR}/geninclude/version.cpp)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Never want shared if not specified")
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

target_include_directories(sc-compiler-options PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if (${BUILD_SHARED_LIBS})
message(FATAL_ERROR "You have overriden BUILD_SHARED_LIBS to be ON. This is an unsupported configuration")
endif()

# visibility needs to be consistent across the whole project
add_compile_options(
# PE/COFF doesn't support visibility
$<$<NOT:$<BOOL:${WIN32}>>:-fvisibility=hidden>
if (APPLE)
enable_language(OBJC)
enable_language(OBJCXX)
set(CMAKE_OBJC_VISIBILITY_PRESET hidden)
set(CMAKE_OBJCXX_VISIBILITY_PRESET hidden)
if( ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "15.0.0" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS "15.1")
add_link_options(-Wl,-ld_classic)
add_compile_definitions(JUCE_SILENCE_XCODE_15_LINKER_WARNING=1)
endif()
endif ()

# Inlines visibility is only relevant with C++
$<$<AND:$<NOT:$<BOOL:${WIN32}>>,$<COMPILE_LANGUAGE:CXX>>:-fvisibility-inlines-hidden>
)

if (APPLE)
set(OS_COMPILE_OPTIONS
Expand Down
39 changes: 0 additions & 39 deletions cmake/version.cpp.in

This file was deleted.

64 changes: 0 additions & 64 deletions cmake/version.h

This file was deleted.

Loading

0 comments on commit 990260b

Please sign in to comment.