faust icon indicating copy to clipboard operation
faust copied to clipboard

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

Open shakfu opened this issue 1 year ago • 2 comments

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

shakfu avatar Jun 02 '23 06:06 shakfu

Which LLVM version are you using ?

sletz avatar Jun 02 '23 06:06 sletz

$ 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: [email protected] ✔, 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"

shakfu avatar Jun 02 '23 06:06 shakfu