grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.57k stars 322 forks source link

Needed to add zstd and -lz dependencies to compile faustgen on macOS #911

Open shakfu opened 1 year ago

shakfu commented 1 year ago

On my macOS x86_64 system, I had to modify the faustgen CMakeLists.txt as follows (full file is attached) to get it to work. zstd was provided by homebrew (note the Add faustgen dependencies section):

...
####################################
# compiler dependent settings
if (WIN32)
    set (FAUSTLIBS ${FAUSTLIB}/libfaustwithllvm.lib ${FAUSTLIB}/libOSCFaust.lib)
    set (WINSRC ${MAXSDK}/max-includes/common/dllmain_win.c ${MAXSDK}/max-includes/common/commonsyms.c)
else()

    set (MACLIBS "-framework CoreServices -framework IOKit")
    set (CMAKE_CXX_FLAGS_RELEASE "-O3")

    if(DEFINED FAUST_PATH_IS_ABSOLUTE AND FAUST_PATH_IS_ABSOLUTE MATCHES "1")
    set (FAUSTLIBS ${FAUSTLIB}/libfaustwithllvm.a ${FAUSTLIB}/libOSCFaust.a)
    else()
    execute_process( COMMAND faust-config --system-libs OUTPUT_VARIABLE FC_OUTPUT RESULT_VARIABLE FC_RESULT)
    string(REPLACE " " ";" FC_OUTPUT ${FC_OUTPUT})
    string(STRIP "${FC_OUTPUT}" FC_OUTPUT)
    set (FAUSTLIBS ${FAUSTLIB}/libfaustwithllvm.a ${FC_OUTPUT} -L/usr/local/lib ${FAUSTLIB}/libOSCFaust.a)
    endif()

endif()

####################################
# Add faustgen dependencies
####################################
# execute_process (COMMAND /usr/local/bin/brew --prefix zstd OUTPUT_VARIABLE ZSTD_DIR)
# message("ZSTD_DIR: " ${ZSTD_DIR})
set(ZSTD_DIR /usr/local/opt/zstd)
set(ZSTD_INCLIDE ${ZSTD_DIR}/include)
set(ZSTD_LIB ${ZSTD_DIR}/lib)
set(LIBZSTD ${ZSTD_LIB}/libzstd.a)

####################################
# Add the faustgen target
####################################
...

CMakeLists.txt

sletz commented 1 year ago

Which LLVM version are you using ?

shakfu commented 1 year ago
$ brew info llvm
==> llvm: stable 16.0.4 (bottled), HEAD [keg-only]
Next-gen compiler infrastructure
https://llvm.org/
/usr/local/Cellar/llvm/16.0.4 (6,779 files, 1.6GB)
  Poured from bottle using the formulae.brew.sh API on 2023-05-19 at 04:52:32
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/llvm.rb
License: Apache-2.0 with LLVM-exception
==> Dependencies
Build: cmake ✔, swig ✘
Required: python@3.11 ✔, six ✔, z3 ✔, zstd ✔
==> Options
--HEAD
    Install HEAD version
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
  LDFLAGS="-L/usr/local/opt/llvm/lib/c++ -Wl,-rpath,/usr/local/opt/llvm/lib/c++"

llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have llvm first in your PATH, run:
  echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/sa/.bash_profile

For compilers to find llvm you may need to set:
  export LDFLAGS="-L/usr/local/opt/llvm/lib"
  export CPPFLAGS="-I/usr/local/opt/llvm/include"