Giter VIP home page Giter VIP logo

bigmac's Introduction

bigmac macos-mojave macos-catalina macos-big-sur macos-big-sur License: MIT

BigMac

BigMac contains a series of CMake variables that facilitate compiling C/C++ code on macOS using the default clang compiler.

Installation

Requirements

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

Homebrew

BigMac can be installed using Homebrew as follows.

$ brew tap sfarrens/sf
$ brew install bigmac

This is recommended as it will also install all of the required dependencies.

From Source

BigMac can be installed manually as follows.

$ git clone https://github.com/sfarrens/bigmac.git
$ cd bigmac
$ mkdir build
$ cd build
$ cmake ..
$ make install

If you install BigMac manually, you will also need to manage all dependencies yourself.

Use

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=VERBOSE

This 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 Variables

  • BigMac_MACOS : macOS version
  • BigMac_CHIP : Apple chip type
  • BigMac_DARWIN : Darwin version
  • BigMac_XCODE : XCode version
  • BigMac_BREW : Homebrew version
  • BigMac_LIBOMP : libomp version

OpenMP Variables

  • BigMac_CPPFLAGS : CPPFLAGS for external projects (e.g. FFTW, NFFT).
  • BigMac_OPENMP_CFLAGS : OPENMP_CFLAGS for 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.

External Project Flags

  • BigMac_FFTW : Flags needed to build FFTW as an external project.
  • BigMac_NFFT : Flags needed to build NFFT as an external project.

Hello World Example

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)

FFTW Example

# 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
)

Badge

Copy and paste the following in your project README.md to show your support for BigMac.

[![bigmac](https://img.shields.io/github/v/release/sfarrens/bigmac?label=BigMac&logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABGdBTUEAALGPC%2FxhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAeGVYSWZNTQAqAAAACAAFARIAAwAAAAEAAQAAARoABQAAAAEAAABKARsABQAAAAEAAABSASgAAwAAAAEAAgAAh2kABAAAAAEAAABaAAAAAAAAAEgAAAABAAAASAAAAAEAAqACAAQAAAABAAAADqADAAQAAAABAAAADgAAAAABAtxLAAAACXBIWXMAAAsTAAALEwEAmpwYAAACZmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS40LjAiPgogICA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPgogICAgICA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIgogICAgICAgICAgICB4bWxuczp0aWZmPSJodHRwOi8vbnMuYWRvYmUuY29tL3RpZmYvMS4wLyIKICAgICAgICAgICAgeG1sbnM6ZXhpZj0iaHR0cDovL25zLmFk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BpUZs5%2F%2Fd7I1O9NT2DuOqHb7z6xkMlqPgJw48QV%2FhftdZGgl2rCda3fFlKIOq8WwyJn0zaeHbwz35%2FMKlmY1PxwcC%2B0PSGrwz1zautvd8PGjEnqO%2Bu1tNreK8w8S%2F1%2B2%2FGrktKJNJ0mQGqFp2FQqrnOKaDdTzD77QAxggF14iAAAAAElFTkSuQmCC)](https://github.com/sfarrens/bigmac)

bigmac's People

Contributors

sfarrens avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.