BigMac contains a series of CMake variables that facilitate compiling C/C++ code on macOS using the default clang compiler.
BigMac requires the following:
-
XCode : The default IDE for macOS. Needed for developer libraries. Should already be installed, but you may need to update it.
-
Command Line Tools : These are the default macOS compilers etc.. You can install these by running the following in a terminal.
$ xcode-select --install
-
Homebrew : Package manager for macOS. You can install this by running the following in a terminal.
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"If you already have Homebrew installed. Be sure to make sure it is up to date.
$ brew update
BigMac can be installed using Homebrew as follows.
$ brew tap sfarrens/sf $ brew install bigmacThis is recommended as it will also install all of the required dependencies.
BigMac can be installed manually as follows.
$ git clone https://github.com/sfarrens/bigmac.git $ cd bigmac $ mkdir build $ cd build $ cmake .. $ make installIf you install BigMac manually, you will also need to manage all dependencies yourself.
To take advantage of BigMac simply include the following in your CMake project.
find_package(BigMac REQUIRED)This will provide all of the variables described below. Additionally, by providing the flag --log-level=VERBOSE, you can get a report of your system setup. e.g.
$ cmake --log-level=VERBOSEThis should provide something like the following.
-- BigMac Status -- - macOS Version: 12.6 -- - Chip: Apple M1 Max -- - Darwin Version: 21.6.0 -- - XCode Version: 14.0 -- - Homebrew Version: 3.6.6 -- - libomp Version: 15.0.3 -- - Compiler: Clang -- - Compiler Version: 14.0.0.14000029 -- - Which CC: /usr/bin/clang -- - Which CXX: /usr/bin/clang++ -- BigMac -> Setting OpenMP variables for Clang -- - BigMac_CPPFLAGS -Xclang -fopenmp -- - BigMac_OPENMP_CFLAGS -lomp -- - OpenMP_INCLUDE_PATH /opt/homebrew/opt/libomp/include -- - OpenMP_LIB_PATH /opt/homebrew/opt/libomp/lib -- - OpenMP_C_FLAGS -Xclang -fopenmp -lomp -- - OpenMP_CXX_FLAGS -Xclang -fopenmp -lomp -- - OpenMP_C_LIB_NAMES omp -- - OpenMP_CXX_LIB_NAMES omp -- - OpenMP_C_LIBRARIES /opt/homebrew/opt/libomp/lib/libomp.dylib -- - OpenMP_CXX_LIBRARIES /opt/homebrew/opt/libomp/lib/libomp.dylib -- - OpenMP_omp_LIBRARY /opt/homebrew/opt/libomp/lib/libomp.dylib -- - OpenMP_C_VERSION 15.0.3 -- - OpenMP_CXX_VERSION 15.0.3 BigMac_MACOS: macOS versionBigMac_CHIP: Apple chip typeBigMac_DARWIN: Darwin versionBigMac_XCODE: XCode versionBigMac_BREW: Homebrew versionBigMac_LIBOMP: libomp version
BigMac_CPPFLAGS:CPPFLAGSfor external projects (e.g. FFTW, NFFT).BigMac_OPENMP_CFLAGS:OPENMP_CFLAGSfor external projects (e.g. FFTW, NFFT).OpenMP_INCLUDE_PATH: Path to OpenMP headers.OpenMP_LIB_PATH: Path to OpenMP Libraries.OpenMP_C_FLAGS: OpenMP compiler flags for C, separated by spaces.OpenMP_CXX_FLAGS: OpenMP compiler flags for C++, separated by spaces.OpenMP_C_LIB_NAMES: List of libraries for OpenMP programs for C.OpenMP_CXX_LIB_NAMES: List of libraries for OpenMP programs for C++.OpenMP_C_LIBRARIES: A list of libraries needed to link with OpenMP code written in C.OpenMP_CXX_LIBRARIES: A list of libraries needed to link with OpenMP code written in C++.OpenMP_omp_LIBRARY: Location of the individual libraries needed for OpenMP support.OpenMP_C_VERSION: OpenMP version implemented by the C compiler.OpenMP_CXX_VERSION: OpenMP version implemented by the C++ compiler.
BigMac_FFTW: Flags needed to build FFTW as an external project.BigMac_NFFT: Flags needed to build NFFT as an external project.
For the following OpenMP Hello World example.
#include <stdio.h> #include <omp.h> int main(int argc, char** argv){ #pragma omp parallel { printf("Hello from process: %d\n", omp_get_thread_num()); } return 0; }You would include the following in your CMake project.
find_package(BigMac REQUIRED) set(CMAKE_CXX_FLAGS ${OpenMP_CXX_FLAGS}) add_executable(hello_world src/hello_world.cpp)# Download and build FFTW ExternalProject_Add(fftw URL http://www.fftw.org/fftw-3.3.8.tar.gz URL_HASH 8aac833c943d8e90d51b697b27d4384d CONFIGURE_COMMAND ./configure CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ${BigMac_FFTW} BUILD_COMMAND make INSTALL_COMMAND make install )Copy and paste the following in your project README.md to show your support for BigMac.
[](https://github.com/sfarrens/bigmac)