Organize CMake files
This commit is contained in:
parent
13e2dbee04
commit
11ade33e9d
6 changed files with 208 additions and 109 deletions
|
|
@ -1,56 +1,60 @@
|
|||
cmake_minimum_required(VERSION 3.13)
|
||||
project(sfizz VERSION 1.0.0 LANGUAGES CXX)
|
||||
project (sfizz VERSION 1.0.0 LANGUAGES CXX)
|
||||
|
||||
# Do not override the C++ standard if set to more than 14
|
||||
if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 14)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
# External configuration CMake scripts
|
||||
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
include (SfizzConfig)
|
||||
|
||||
# Export the compile_commands.json file
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
# Build Options
|
||||
set (BUILD_TESTING OFF CACHE BOOL "Disable Abseil's tests [default: OFF]")
|
||||
|
||||
# Only install what's explicitely said
|
||||
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
|
||||
set (SFIZZ_LV2_DIR "${CMAKE_INSTALL_PREFIX}/lib/lv2" CACHE STRING
|
||||
"Install destination for LV2 bundle [default: ${CMAKE_INSTALL_PREFIX}/lib/lv2]")
|
||||
|
||||
# Add required flags for the builds
|
||||
if (UNIX)
|
||||
add_compile_options(-Wall)
|
||||
add_compile_options(-Wextra)
|
||||
add_compile_options(-ffast-math)
|
||||
add_compile_options(-fno-omit-frame-pointer) # For debugging purposes
|
||||
add_compile_options(-fPIC)
|
||||
endif()
|
||||
|
||||
# If we build with Clang use libc++
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
||||
set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang")
|
||||
add_compile_options(-stdlib=libc++)
|
||||
# Presumably need the above for linking too, maybe other options missing as well
|
||||
add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release
|
||||
add_link_options(-lc++abi) # New command on CMake master, not in 3.12 release
|
||||
endif()
|
||||
option (SFIZZ_USE_LTO "Enable Link Time Optimization [default: ON]" ON)
|
||||
option (SFIZZ_JACK "Enable JACK stand-alone build [default: ON]" ON)
|
||||
option (SFIZZ_LV2 "Enable LV2 plug-in build [default: ON]" ON)
|
||||
option (SFIZZ_BENCHMARKS "Enable benchmarks build [default: OFF]" OFF)
|
||||
option (SFIZZ_TESTS "Enable tests build [default: OFF]" OFF)
|
||||
option (SFIZZ_SHARED "Enable shared library build [default: ON]" ON)
|
||||
|
||||
# Add Abseil
|
||||
set(BUILD_TESTING OFF CACHE BOOL "Disable Abseil's tests")
|
||||
add_subdirectory(external/abseil-cpp EXCLUDE_FROM_ALL)
|
||||
add_subdirectory (external/abseil-cpp EXCLUDE_FROM_ALL)
|
||||
|
||||
# Add the static library targets and sources
|
||||
add_subdirectory(src)
|
||||
add_subdirectory (src)
|
||||
|
||||
# Optional targets
|
||||
|
||||
if (SFIZZ_CLIENTS)
|
||||
add_subdirectory(clients)
|
||||
if (SFIZZ_JACK)
|
||||
add_subdirectory (clients)
|
||||
endif()
|
||||
|
||||
if (SFIZZ_LV2)
|
||||
add_subdirectory(lv2)
|
||||
add_subdirectory (lv2)
|
||||
endif()
|
||||
|
||||
if (SFIZZ_BENCHMARKS)
|
||||
add_subdirectory(benchmarks)
|
||||
add_subdirectory (benchmarks)
|
||||
endif()
|
||||
|
||||
if (SFIZZ_TESTS)
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
add_subdirectory (tests)
|
||||
endif()
|
||||
|
||||
message (STATUS "
|
||||
Project name: ${CMAKE_PROJECT_NAME}
|
||||
Build type: ${CMAKE_BUILD_TYPE}
|
||||
Build using LTO: ${SFIZZ_USE_LTO}
|
||||
Build as shared library: ${SFIZZ_SHARED}
|
||||
Build JACK stand-alone client: ${SFIZZ_JACK}
|
||||
Build LV2 plug-in: ${SFIZZ_LV2}
|
||||
Build benchmarks: ${SFIZZ_BENCHMARKS}
|
||||
Build tests: ${SFIZZ_TESTS}
|
||||
|
||||
Install prefix: ${CMAKE_INSTALL_PREFIX}
|
||||
LV2 destination directory: ${SFIZZ_LV2_DIR}
|
||||
|
||||
Compiler CXX debug flags: ${CMAKE_CXX_FLAGS_DEBUG}
|
||||
Compiler CXX release flags: ${CMAKE_CXX_FLAGS_RELEASE}
|
||||
Compiler CXX min size flags: ${CMAKE_CXX_FLAGS_MINSIZEREL}
|
||||
")
|
||||
|
|
|
|||
28
cmake/SfizzConfig.cmake
Normal file
28
cmake/SfizzConfig.cmake
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Do not override the C++ standard if set to more than 14
|
||||
if (NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 14)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
endif()
|
||||
|
||||
# Export the compile_commands.json file
|
||||
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Only install what's explicitely said
|
||||
set (CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
|
||||
|
||||
# Add required flags for the builds
|
||||
if (UNIX)
|
||||
add_compile_options(-Wall)
|
||||
add_compile_options(-Wextra)
|
||||
add_compile_options(-ffast-math)
|
||||
add_compile_options(-fno-omit-frame-pointer) # For debugging purposes
|
||||
add_compile_options(-fPIC)
|
||||
endif()
|
||||
|
||||
# If we build with Clang use libc++
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT ANDROID)
|
||||
set(USE_LIBCPP ON CACHE BOOL "Use libc++ with clang")
|
||||
add_compile_options(-stdlib=libc++)
|
||||
# Presumably need the above for linking too, maybe other options missing as well
|
||||
add_link_options(-stdlib=libc++) # New command on CMake master, not in 3.12 release
|
||||
add_link_options(-lc++abi) # New command on CMake master, not in 3.12 release
|
||||
endif()
|
||||
28
cmake/SfizzSimdSourceFilesCheck.cmake
Normal file
28
cmake/SfizzSimdSourceFilesCheck.cmake
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
# Check SIMD
|
||||
include (CheckIncludeFiles)
|
||||
CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H)
|
||||
CHECK_INCLUDE_FILES(intrin.h HAVE_INTRIN_H)
|
||||
|
||||
if (!APPLE)
|
||||
CHECK_INCLUDE_FILES (arm_neon.h HAVE_ARM_NEON_H)
|
||||
endif()
|
||||
|
||||
# SIMD checks
|
||||
if (HAVE_X86INTRIN_H AND UNIX)
|
||||
add_compile_options (-DHAVE_X86INTRIN_H)
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp)
|
||||
elseif (HAVE_INTRIN_H AND WIN32)
|
||||
add_compile_options (/DHAVE_INTRIN_H)
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp)
|
||||
elseif (HAVE_ARM_NEON_H AND UNIX)
|
||||
add_compile_options (-DHAVE_ARM_NEON_H)
|
||||
add_compile_options (-mfpu=neon-fp-armv8)
|
||||
add_compile_options (-march=native)
|
||||
add_compile_options (-mtune=cortex-a53)
|
||||
add_compile_options (-funsafe-math-optimizations)
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp)
|
||||
else()
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp)
|
||||
endif()
|
||||
|
||||
set (SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES})
|
||||
|
|
@ -1,30 +1,30 @@
|
|||
project(sfizz)
|
||||
project (sfizz)
|
||||
|
||||
add_library(sfizz_lv2 SHARED sfizz.c)
|
||||
set_target_properties(sfizz_lv2 PROPERTIES PREFIX "")
|
||||
set_target_properties(sfizz_lv2 PROPERTIES OUTPUT_NAME "sfizz")
|
||||
target_link_libraries(sfizz_lv2 sfizz::sfizz)
|
||||
add_library (sfizz_lv2 SHARED sfizz.c)
|
||||
set_target_properties (sfizz_lv2 PROPERTIES PREFIX "")
|
||||
set_target_properties (sfizz_lv2 PROPERTIES OUTPUT_NAME "sfizz")
|
||||
target_link_libraries (sfizz_lv2 sfizz::sfizz)
|
||||
|
||||
add_custom_command( TARGET sfizz_lv2 POST_BUILD
|
||||
add_custom_command (TARGET sfizz_lv2 POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_SOURCE_DIR}/lv2/sfizz.ttl
|
||||
${CMAKE_CURRENT_BINARY_DIR}/sfizz.ttl)
|
||||
|
||||
add_custom_command( TARGET sfizz_lv2 POST_BUILD
|
||||
add_custom_command (TARGET sfizz_lv2 POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_SOURCE_DIR}/lv2/manifest.ttl
|
||||
${CMAKE_CURRENT_BINARY_DIR}/manifest.ttl)
|
||||
if (SFIZZ_USE_LTO)
|
||||
set_property (TARGET sfizz_lv2 PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
|
||||
set_property(TARGET sfizz_lv2 PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
|
||||
|
||||
if(UNIX)
|
||||
if (UNIX)
|
||||
if (NOT LV2_INSTALL_PREFIX)
|
||||
set(LV2_INSTALL_PREFIX ${CMAKE_INSTALL_LIBDIR}/lv2/sfizz.lv2)
|
||||
set (LV2_INSTALL_PREFIX ${CMAKE_INSTALL_LIBDIR}/lv2/sfizz.lv2)
|
||||
endif()
|
||||
install(TARGETS sfizz_lv2
|
||||
install (TARGETS sfizz_lv2
|
||||
ARCHIVE DESTINATION ${LV2_INSTALL_PREFIX}
|
||||
LIBRARY DESTINATION ${LV2_INSTALL_PREFIX})
|
||||
install(FILES ${CMAKE_BINARY_DIR}/lv2/sfizz.ttl DESTINATION ${LV2_INSTALL_PREFIX})
|
||||
install(FILES ${CMAKE_BINARY_DIR}/lv2/manifest.ttl DESTINATION ${LV2_INSTALL_PREFIX})
|
||||
endif()
|
||||
install (FILES ${CMAKE_BINARY_DIR}/lv2/sfizz.ttl DESTINATION ${LV2_INSTALL_PREFIX})
|
||||
install (FILES ${CMAKE_BINARY_DIR}/lv2/manifest.ttl DESTINATION ${LV2_INSTALL_PREFIX})
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
project(sfizz)
|
||||
|
||||
set(SFIZZ_SOURCES
|
||||
set (SFIZZ_SOURCES
|
||||
sfizz/Synth.cpp
|
||||
sfizz/FilePool.cpp
|
||||
sfizz/Region.cpp
|
||||
|
|
@ -9,75 +9,53 @@ set(SFIZZ_SOURCES
|
|||
sfizz/SfzHelpers.cpp
|
||||
sfizz/FloatEnvelopes.cpp
|
||||
)
|
||||
include (SfizzSimdSourceFilesCheck)
|
||||
|
||||
# Check SIMD
|
||||
include(CheckIncludeFiles)
|
||||
CHECK_INCLUDE_FILES(x86intrin.h HAVE_X86INTRIN_H)
|
||||
CHECK_INCLUDE_FILES(intrin.h HAVE_INTRIN_H)
|
||||
if (!APPLE)
|
||||
CHECK_INCLUDE_FILES(arm_neon.h HAVE_ARM_NEON_H)
|
||||
# Parser core library
|
||||
add_library (sfizz_parser STATIC)
|
||||
target_sources (sfizz_parser PRIVATE sfizz/Parser.cpp sfizz/Opcode.cpp)
|
||||
target_include_directories (sfizz_parser PUBLIC sfizz)
|
||||
target_include_directories (sfizz_parser PUBLIC external)
|
||||
target_link_libraries (sfizz_parser PRIVATE absl::strings)
|
||||
|
||||
# Sfizz core library
|
||||
add_library (sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp)
|
||||
target_include_directories (sfizz PUBLIC sfizz)
|
||||
target_include_directories (sfizz PUBLIC .)
|
||||
target_include_directories (sfizz PUBLIC external)
|
||||
target_link_libraries (sfizz PRIVATE sfizz_parser)
|
||||
find_package (Threads REQUIRED)
|
||||
target_link_libraries (sfizz PUBLIC absl::strings)
|
||||
target_link_libraries (sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads)
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries (sfizz PUBLIC atomic)
|
||||
endif()
|
||||
|
||||
# SIMD checks
|
||||
if (HAVE_X86INTRIN_H AND UNIX)
|
||||
add_compile_options(-DHAVE_X86INTRIN_H)
|
||||
set(SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp)
|
||||
elseif (HAVE_INTRIN_H AND WIN32)
|
||||
add_compile_options(/DHAVE_INTRIN_H)
|
||||
set(SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp)
|
||||
elseif (HAVE_ARM_NEON_H AND UNIX)
|
||||
add_compile_options(-DHAVE_ARM_NEON_H)
|
||||
add_compile_options(-mfpu=neon-fp-armv8)
|
||||
add_compile_options(-march=native)
|
||||
add_compile_options(-mtune=cortex-a53)
|
||||
add_compile_options(-funsafe-math-optimizations)
|
||||
set(SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp)
|
||||
else()
|
||||
set(SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp)
|
||||
if (SFIZZ_USE_LTO)
|
||||
set_property (TARGET sfizz_parser PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
set_property (TARGET sfizz PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
|
||||
set(SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES})
|
||||
|
||||
add_library(sfizz_parser STATIC)
|
||||
target_sources(sfizz_parser PRIVATE sfizz/Parser.cpp sfizz/Opcode.cpp)
|
||||
target_include_directories(sfizz_parser PUBLIC sfizz)
|
||||
target_include_directories(sfizz_parser PUBLIC external)
|
||||
target_link_libraries(sfizz_parser PRIVATE absl::strings)
|
||||
|
||||
add_library(sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp)
|
||||
target_include_directories(sfizz PUBLIC sfizz)
|
||||
target_include_directories(sfizz PUBLIC .)
|
||||
target_include_directories(sfizz PUBLIC external)
|
||||
target_link_libraries(sfizz PRIVATE sfizz_parser)
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(sfizz PUBLIC absl::strings)
|
||||
target_link_libraries(sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads)
|
||||
if(UNIX)
|
||||
target_link_libraries(sfizz PUBLIC atomic)
|
||||
endif(UNIX)
|
||||
set_property(TARGET sfizz_parser PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
set_property(TARGET sfizz PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
|
||||
add_library(sfizz::parser ALIAS sfizz_parser)
|
||||
add_library(sfizz::sfizz ALIAS sfizz)
|
||||
add_library (sfizz::parser ALIAS sfizz_parser)
|
||||
add_library (sfizz::sfizz ALIAS sfizz)
|
||||
|
||||
# install(TARGETS sfizz_parser DESTINATION . EXCLUDE_FROM_ALL)
|
||||
# install(TARGETS sfizz DESTINATION . EXCLUDE_FROM_ALL)
|
||||
|
||||
# Shared library and installation target
|
||||
|
||||
if (SFIZZ_SHARED)
|
||||
add_library(sfizz_shared SHARED sfizz.h)
|
||||
set_target_properties(sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h)
|
||||
target_link_libraries(sfizz_shared sfizz::sfizz)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY)
|
||||
if(UNIX)
|
||||
include(GNUInstallDirs)
|
||||
install(TARGETS sfizz_shared
|
||||
add_library (sfizz_shared SHARED sfizz.h)
|
||||
set_target_properties (sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h)
|
||||
target_link_libraries (sfizz_shared sfizz::sfizz)
|
||||
configure_file (${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY)
|
||||
if (UNIX)
|
||||
include (GNUInstallDirs)
|
||||
install (TARGETS sfizz_shared
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
install(FILES
|
||||
install (FILES
|
||||
${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
|
||||
endif()
|
||||
endif(SFIZZ_SHARED)
|
||||
endif ()
|
||||
|
|
|
|||
61
src/CMakeLists.txt.autosave
Normal file
61
src/CMakeLists.txt.autosave
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
project(sfizz)
|
||||
|
||||
set (SFIZZ_SOURCES
|
||||
sfizz/Synth.cpp
|
||||
sfizz/FilePool.cpp
|
||||
sfizz/Region.cpp
|
||||
sfizz/Voice.cpp
|
||||
sfizz/ScopedFTZ.cpp
|
||||
sfizz/SfzHelpers.cpp
|
||||
sfizz/FloatEnvelopes.cpp
|
||||
)
|
||||
include (SfizzSimdSourceFilesCheck)
|
||||
|
||||
# Parser core library
|
||||
add_library (sfizz_parser STATIC)
|
||||
target_sources (sfizz_parser PRIVATE sfizz/Parser.cpp sfizz/Opcode.cpp)
|
||||
target_include_directories (sfizz_parser PUBLIC sfizz)
|
||||
target_include_directories (sfizz_parser PUBLIC external)
|
||||
target_link_libraries (sfizz_parser PRIVATE absl::strings)
|
||||
|
||||
# Sfizz core library
|
||||
add_library (sfizz STATIC ${SFIZZ_SOURCES} sfizz/sfizz_wrapper.cpp)
|
||||
target_include_directories (sfizz PUBLIC sfizz)
|
||||
target_include_directories (sfizz PUBLIC .)
|
||||
target_include_directories (sfizz PUBLIC external)
|
||||
target_link_libraries (sfizz PRIVATE sfizz_parser)
|
||||
find_package (Threads REQUIRED)
|
||||
target_link_libraries (sfizz PUBLIC absl::strings)
|
||||
target_link_libraries (sfizz PRIVATE sndfile absl::flat_hash_map Threads::Threads)
|
||||
|
||||
if (UNIX)
|
||||
target_link_libraries (sfizz PUBLIC atomic)
|
||||
endif()
|
||||
|
||||
if (SFIZZ_USE_LTO)
|
||||
set_property (TARGET sfizz_parser PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
set_property (TARGET sfizz PROPERTY INTERPROCEDURAL_OPTIMIZATION True)
|
||||
endif()
|
||||
|
||||
add_library (sfizz::parser ALIAS sfizz_parser)
|
||||
add_library (sfizz::sfizz ALIAS sfizz)
|
||||
|
||||
# install(TARGETS sfizz_parser DESTINATION . EXCLUDE_FROM_ALL)
|
||||
# install(TARGETS sfizz DESTINATION . EXCLUDE_FROM_ALL)
|
||||
|
||||
# Shared library and installation target
|
||||
if (SFIZZ_SHARED)
|
||||
add_library (sfizz_shared SHARED sfizz.h)
|
||||
set_target_properties (sfizz_shared PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER sfizz.h)
|
||||
target_link_libraries (sfizz_shared sfizz::sfizz)
|
||||
configure_file (${CMAKE_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY)
|
||||
if (UNIX)
|
||||
include (GNUInstallDirs)
|
||||
install (TARGETS sfizz_shared
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
install (FILES
|
||||
${CMAKE_BINARY_DIR}/src/sfizz.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
|
||||
endif()
|
||||
endif()
|
||||
Loading…
Add table
Reference in a new issue