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

Compile on Mac OS Monterey12.1 (Mac Mini M1) #313

Open
ouening opened this issue Dec 15, 2021 · 5 comments
Open

Compile on Mac OS Monterey12.1 (Mac Mini M1) #313

ouening opened this issue Dec 15, 2021 · 5 comments

Comments

@ouening
Copy link

ouening commented Dec 15, 2021

OS: Mac OS Monterey 12.1
Computer: Mac mini (M1, 2020)

elmerfem version: 9.0 (devel 7665920)

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

@ShamoX
Copy link

ShamoX commented Apr 12, 2023

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.

@bdlabitt
Copy link

bdlabitt commented Dec 8, 2023

Any ideas on how to update to Ventura on an M3? gcc is at 13 now. Are the opengl lib paths the same?

@bdlabitt
Copy link

bdlabitt commented Dec 9, 2023

There's no utility find_program as used in CmakeLists.txt. This documentation is very outdated.

@nega0
Copy link

nega0 commented Jan 12, 2024

find_program is a CMake command. It's not an external utility.

@bdlabitt
Copy link

bdlabitt commented Feb 5, 2024

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

Screenshot 2024-02-05 at 3 59 38 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants