Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPP 20 flags #296

Merged
merged 1 commit into from
Aug 19, 2024
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
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@

cmake_minimum_required(VERSION 3.21)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13 CACHE STRING "Minimum macOS version")
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build Universal Always")
if (NOT DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
message(STATUS "[clap-wrapper]: OSX_DEPLOYEMNT_TARGET is undefined. Setting to 10.13")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13 CACHE STRING "Minimum macOS version")
endif()
if (NOT DEFINED CMAKE_OSX_ARCHITECTURES)
message(STATUS "[clap-wrapper]: CMAKE_OSX_ARCHITECTURES is not set. Using native build for clap wrapper")
endif()
if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
if (WIN32)
message(STATUS "CMAKE_MSVC_RUNTIME_LIBRARY not defined. Setting to static link")
Expand All @@ -52,13 +57,18 @@ if (APPLE)
enable_language(OBJCXX)
endif()

if (DEFINED CLAP_WRAPPER_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${CLAP_WRAPPER_CXX_STANDARD})
else()
set(CMAKE_CXX_STANDARD 17)
if (PROJECT_IS_TOP_LEVEL)
if (DEFINED CLAP_WRAPPER_CXX_STANDARD)
set(CMAKE_CXX_STANDARD ${CLAP_WRAPPER_CXX_STANDARD})
else()
if (NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
elseif ( ${CMAKE_CXX_STANDARD} VERSION_LESS 17)
message(WARNING "CMAKE_CXX_STANDARD of ${CMAKE_CXX_STANDARD} < 17 not well tested")
endif()
endif()
endif()
message(STATUS "clap-wrapper: Building with C++ standard ${CMAKE_CXX_STANDARD}")

set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_OBJC_VISIBILITY_PRESET hidden)
Expand Down
10 changes: 8 additions & 2 deletions cmake/shared_prologue.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ endif()

# Compiler options for warnings, errors etc
add_library(clap-wrapper-compile-options INTERFACE)
add_library(clap-wrapper-compile-options-public INTERFACE)
target_link_libraries(clap-wrapper-compile-options INTERFACE clap-wrapper-compile-options-public)

# This is useful for debugging cmake link problems2
# target_compile_definitions(clap-wrapper-compile-options INTERFACE -DTHIS_BUILD_USED_CLAP_WRAPPER_COMPILE_OPTIONS=1)
# target_compile_definitions(clap-wrapper-compile-options-public INTERFACE -DTHIS_BUILD_USED_CLAP_WRAPPER_COMPILE_OPTIONS_PUBLIC=1)
add_library(clap-wrapper-sanitizer-options INTERFACE)

target_compile_options(clap-wrapper-compile-options INTERFACE -D${CLAP_WRAPPER_PLATFORM}=1 -DCLAP_WRAPPER_VERSION="${CLAP_WRAPPER_VERSION}")
Expand All @@ -58,7 +64,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
endif()
if (${CMAKE_CXX_STANDARD} GREATER_EQUAL 20)
message(STATUS "clap-wrapper: Turning off char8_t c++20 changes")
target_compile_options(clap-wrapper-compile-options INTERFACE -fno-char8_t)
target_compile_options(clap-wrapper-compile-options-public INTERFACE -fno-char8_t)
endif()
if (${CLAP_WRAPPER_ENABLE_SANITIZER})
message(STATUS "clap-wrapper: enabling sanitizer build")
Expand All @@ -82,7 +88,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(clap-wrapper-compile-options INTERFACE /utf-8)
if (${CMAKE_CXX_STANDARD} GREATER_EQUAL 20)
message(STATUS "clap-wrapper: Turning off char8_t c++20 changes")
target_compile_options(clap-wrapper-compile-options INTERFACE /Zc:char8_t-)
target_compile_options(clap-wrapper-compile-options-public INTERFACE /Zc:char8_t-)
endif()
endif()

Expand Down
1 change: 1 addition & 0 deletions cmake/wrap_auv2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function(target_add_auv2_wrapper)
set(bhsc "${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/auv2/build-helper/")
add_executable(${bhtg} ${bhsc}/build-helper.cpp)
target_link_libraries(${bhtg} PRIVATE
clap-wrapper-compile-options
clap-wrapper-shared-detail
macos_filesystem_support
"-framework Foundation"
Expand Down
3 changes: 1 addition & 2 deletions cmake/wrap_standalone.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ function(target_add_standalone_wrapper)
)
target_link_libraries(${salib}
PUBLIC
clap-wrapper-compile-options
clap-wrapper-shared-detail
base-sdk-rtmidi
base-sdk-rtaudio
)
target_link_libraries(${salib} PRIVATE clap-wrapper-compile-options)

if (APPLE)
target_sources(${salib} PRIVATE)
Expand Down Expand Up @@ -185,7 +185,6 @@ function(target_add_standalone_wrapper)
)

target_link_libraries(${SA_TARGET} PRIVATE
clap-wrapper-compile-options
${salib}
)
endfunction(target_add_standalone_wrapper)
5 changes: 4 additions & 1 deletion cmake/wrap_vst3.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ function(target_add_vst3_wrapper)
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC clap base-sdk-vst3)

# clap-wrapper-extensions are PUBLIC, so a clap linking the library can access the clap-wrapper-extensions
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC clap-wrapper-extensions clap-wrapper-shared-detail)
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PUBLIC
clap-wrapper-compile-options-public
clap-wrapper-extensions
clap-wrapper-shared-detail)
target_link_libraries(${V3_TARGET}-clap-wrapper-vst3-lib PRIVATE clap-wrapper-compile-options)

target_compile_options(${V3_TARGET}-clap-wrapper-vst3-lib PRIVATE
Expand Down
Loading