Compile on Mac OS Monterey12.1 (Mac Mini M1)
OS: Mac OS Monterey 12.1 Computer: Mac mini (M1, 2020) elmerfem version: 9.0 (devel 7665920e)
1. Prepare
Install gcc, g++, gfortran, cmake, Qt5 and qwt-qt5:
brew install gcc g++ gfortran cmake qt@5 qwt-qt5
The gcc and g++ installed from brew are located in /opt/homebrew/bin/gcc-11 and /opt/homebrew/bin/g++-11.
gfortran is located in /opt/homebrew/bin/gfortran.
We can use command:
brew info qt@5
brew info qwt-qt5
to see where the qt5 and qwt-qt5 are installed (my computer is m1 mac mini, the installation dir is in /opt).
And command: find /opt -name Qt5Config.cmake to find Qt5_DIR
Same as qwt-qt5. Be aware we should install qt@5 instead of qt, so as qwt-qt5 instead of qwt. See https://formulae.brew.sh/formula/qt@5 and https://formulae.brew.sh/formula/qwt-qt5#default.
2. Modify elmerfem/CmakeLists.txt
Modify the Apple section configuration:
if(APPLE)
# message("you need to have gcc-gfrotran installed using HomeBrew")
# set(CMAKE_C_COMPILER "/usr/bin/gcc")
# set(CMAKE_CXX_COMPILER "/usr/bin/g++")
set(CMAKE_C_COMPILER "/opt/homebrew/bin/gcc-11")
set(CMAKE_CXX_COMPILER "/opt/homebrew/bin/g++-11")
set(CMAKE_Fortran_COMPILER "/opt/homebrew/bin/gfortran")
# set(BLA_VENDOR "OpenBLAS")
# option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
# set (CMAKE_GENERATOR "Unix Makefiles" CACHE INTERNAL "" FORCE)
# set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(Qt5_DIR "/opt/homebrew/Cellar/qt@5/5.15.2_1/lib/cmake/Qt5")
set(QWT_INCLUDE_DIR "/opt/homebrew/opt/qwt-qt5/include")
set(QWT_INCLUDE_DIR "/opt/homebrew/Cellar/qwt-qt5/6.2.0/lib/qwt.framework/Versions/6/Headers")
set(QWT_LIBRARY "/opt/homebrew/opt/qwt-qt5/lib/qwt.framework/qwt")
endif()
and
IF(APPLE)
SET(CMAKE_MACOSX_RPATH 1)
# on OSX FindOpenGL uses framework version of OpenGL, but we need X11 version
# FIND_PATH(GLX_INCLUDE_DIR GL/glx.h
# PATHS /opt/X11/include /usr/X11/include /usr/X11R6/include)
# find_library(X11_GL_LIB GL
# PATH /opt/X11/lib /usr/X11/lib /usr/X11R6/lib)
FIND_LIBRARY(OPENGL_gl_LIBRARY GL
PATHS /opt/X11/lib /usr/X11/lib /usr/X11R6/lib)
FIND_LIBRARY(OPENGL_glu_LIBRARY GLU
PATHS /opt/X11/lib /usr/X11/lib /usr/X11R6/lib)
LIST(APPEND LIBS ${OPENGL_gl_LIBRARY})
# INCLUDE_DIRECTORIES(${GLX_INCLUDE_DIR})
ENDIF()
Compile and install
Just make -j6 && sudo make install
Hello, thanks for the work.
This solution may have worked before gcc 12 release, but we need now to precise gcc@11 when installing.
I also made more flexible the variable (to prevent incompatibility to old intel macs).
I made a PR: #393.
Any ideas on how to update to Ventura on an M3? gcc is at 13 now. Are the opengl lib paths the same?
There's no utility find_program as used in CmakeLists.txt. This documentation is very outdated.
find_program is a CMake command. It's not an external utility.
Any ideas on how to update to Ventura on an M3? gcc is at 13 now. Are the opengl lib paths the same?
That's my real question. There's no /opt/X11 in Ventura, but there is /opt/homebrew/opt/X11 which is a simlink which leads to some strange files. But in /opt/homebrew/opt the following files exist