Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@
[submodule "3rdparty/rapidhash"]
path = 3rdparty/rapidhash
url = https://github.com/Nicoshev/rapidhash
[submodule "3rdparty/abseil-cpp"]
path = 3rdparty/abseil-cpp
url = https://github.com/abseil/abseil-cpp
1 change: 1 addition & 0 deletions 3rdparty/abseil-cpp
Submodule abseil-cpp added at 76bb24
2 changes: 1 addition & 1 deletion 3rdparty/re2
Submodule re2 updated 134 files
2 changes: 2 additions & 0 deletions cmake/OssiaDeps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ find_package(Git)
if(Git_FOUND AND OSSIA_SUBMODULE_AUTOUPDATE)
message(STATUS "Update general libossia dependencies :")
set(OSSIA_SUBMODULES
abseil-cpp
concurrentqueue
compile-time-regular-expressions
Flicks
Expand Down Expand Up @@ -85,6 +86,7 @@ if(Git_FOUND AND OSSIA_SUBMODULE_AUTOUPDATE)
endif()

# Download various dependencies
include(deps/abseil)
include(deps/boost)
include(deps/concurrentqueue)
include(deps/ctre)
Expand Down
49 changes: 49 additions & 0 deletions cmake/deps/abseil.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
if(OSSIA_USE_SYSTEM_LIBRARIES)
find_package(absl CONFIG GLOBAL QUIET)
endif()

# Abseil is pulled in as a dependency of re2 (see deps/re2.cmake).
# We build the in-tree copy through its own CMake build, like the other
# add_subdirectory-based dependencies (rubberband, libremidi, ...).
if(NOT TARGET absl::strings)
block()
set(BUILD_SHARED_LIBS 0)
set(BUILD_TESTING 0)
set(ABSL_BUILD_TESTING OFF CACHE INTERNAL "")
set(ABSL_PROPAGATE_CXX_STD ON CACHE INTERNAL "")
# Treat Abseil's headers as system headers so that re2 (and ossia) do not
# get flooded with warnings coming from them.
set(ABSL_USE_SYSTEM_INCLUDES ON CACHE INTERNAL "")

# Abseil's CMakeLists forcibly overrides CMAKE_MSVC_RUNTIME_LIBRARY from its
# own ABSL_MSVC_STATIC_RUNTIME option (default OFF -> /MD), ignoring what the
# rest of the build selected. Static ossia builds (Max/PD/Python/Unity, ...)
# use the static /MT runtime, which then mismatches Abseil's /MD at link
# time. Mirror ossia's choice so the runtimes agree.
if(MSVC AND CMAKE_MSVC_RUNTIME_LIBRARY AND NOT CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL")
set(ABSL_MSVC_STATIC_RUNTIME ON CACHE INTERNAL "")
else()
set(ABSL_MSVC_STATIC_RUNTIME OFF CACHE INTERNAL "")
endif()

# When we install our static dependencies, re2 links Abseil publicly, so its
# targets must be installable/exportable too.
if(OSSIA_INSTALL_STATIC_DEPENDENCIES)
set(ABSL_ENABLE_INSTALL ON CACHE INTERNAL "")

# NB: no EXCLUDE_FROM_ALL here. CMake skips the install() rules of a
# subdirectory added with EXCLUDE_FROM_ALL, so Abseil's libraries,
# headers and CMake package (abslConfig / abslTargets) would never be
# installed - leaving the installed re2 export (which links Abseil
# publicly) dangling for downstream consumers. Building all of Abseil is
# acceptable here as this branch is only taken for static packaging builds.
add_subdirectory("${OSSIA_3RDPARTY_FOLDER}/abseil-cpp")
else()
add_subdirectory("${OSSIA_3RDPARTY_FOLDER}/abseil-cpp" EXCLUDE_FROM_ALL)
endif()
endblock()
endif()

if(TARGET absl::strings)
set(OSSIA_HAS_ABSEIL 1 CACHE INTERNAL "")
endif()
27 changes: 25 additions & 2 deletions cmake/deps/re2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ else()
${OSSIA_3RDPARTY_FOLDER}/re2/re2/regexp.cc
${OSSIA_3RDPARTY_FOLDER}/re2/re2/set.cc
${OSSIA_3RDPARTY_FOLDER}/re2/re2/simplify.cc
${OSSIA_3RDPARTY_FOLDER}/re2/re2/stringpiece.cc
${OSSIA_3RDPARTY_FOLDER}/re2/re2/tostring.cc
${OSSIA_3RDPARTY_FOLDER}/re2/re2/unicode_casefold.cc
${OSSIA_3RDPARTY_FOLDER}/re2/re2/unicode_groups.cc
Expand All @@ -55,6 +54,27 @@ else()

target_include_directories(re2 SYSTEM PUBLIC $<BUILD_INTERFACE:${OSSIA_3RDPARTY_FOLDER}/re2>)

# Since 2023-07-01, re2 depends on Abseil (see deps/abseil.cmake which is
# included before this file). This is the set of targets listed in re2's own
# CMakeLists.txt (ABSL_DEPS).
target_link_libraries(re2 PUBLIC
absl::absl_check
absl::absl_log
absl::base
absl::core_headers
absl::fixed_array
absl::flags
absl::flat_hash_map
absl::flat_hash_set
absl::hash
absl::inlined_vector
absl::optional
absl::span
absl::str_format
absl::strings
absl::synchronization
)

if(UNIX)
target_link_libraries(re2 PUBLIC Threads::Threads)
endif()
Expand All @@ -68,7 +88,10 @@ else()

install(EXPORT re2-exports
DESTINATION lib/cmake/re2)
export(EXPORT re2-exports)
# NB: no build-tree export() here. re2 links Abseil publicly and Abseil only
# provides install(EXPORT) rules, not a build-tree export(), so a build-tree
# export() of re2 fails at generate time ("target ... not in any export
# set"). Only the installed re2 export is consumed (see ossiaConfig.cmake.in).
endif()
endif()

Expand Down
10 changes: 7 additions & 3 deletions cmake/deps/span.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ if(OSSIA_USE_SYSTEM_LIBRARIES)
find_package(span CONFIG GLOBAL)
endif()

# NB: the backing target is named "ossia_span" rather than "span" to avoid a
# clash with Abseil, which registers an un-prefixed "span" target (alias
# absl::span) when ABSL_ENABLE_INSTALL is ON (see deps/abseil.cmake). Consumers
# use the span::span alias.
if(NOT TARGET span::span)
add_library(span INTERFACE IMPORTED GLOBAL)
add_library(span::span ALIAS span)
target_include_directories(span INTERFACE "$<BUILD_INTERFACE:${OSSIA_3RDPARTY_FOLDER}/span/include>")
add_library(ossia_span INTERFACE IMPORTED GLOBAL)
add_library(span::span ALIAS ossia_span)
target_include_directories(ossia_span INTERFACE "$<BUILD_INTERFACE:${OSSIA_3RDPARTY_FOLDER}/span/include>")
endif()
3 changes: 3 additions & 0 deletions cmake/ossiaConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ find_dependency(Boost 1.83 REQUIRED)

if(@OSSIA_STATIC@)
if(EXISTS "${OSSIA_CMAKE_DIR}/../re2/re2-exports.cmake")
# re2 links Abseil publicly, so its targets must be resolved before the re2
# export (which references absl::*) is pulled in.
find_dependency(absl)
include("${OSSIA_CMAKE_DIR}/../re2/re2-exports.cmake")
endif()
endif()
Expand Down
Loading