Skip to content

Commit

Permalink
Updated package
Browse files Browse the repository at this point in the history
  • Loading branch information
sfarrens committed Aug 6, 2020
1 parent b1d7318 commit 71df6fa
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 48 deletions.
64 changes: 63 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,64 @@
# BigMac
macOS configuration tools
BigMac contains a series of CMake variables that facilitate compiling C/C++ code on macOS using the default clang compiler.

## Installation

BigMac can be installed using [Homebrew](https://brew.sh/) as follows.

```bash
$ brew tap sfarrens/sf
$ brew install bigmac
```

## Use

To take advantage of BigMac simply include the following in your CMake project.

```cmake
find_package(BigMac REQUIRED)
```

Then use variables provided.

### BigMac Variables

#### OpenMP Variables

- `OpenMP_INCLUDE_PATH` : Path to OpenMP headers
- `OpenMP_LIB_PATH` : Path to OpenMP Libraries
- `OpenMP_CXX_FLAGS` : OpenMP Flags
- `OpenMP_CXX_LIB_NAMES` : OpenMP Library Names
- `OpenMP_CXX_LIBRARIES` : OpenMP Libraries

#### FFTW Variables

- `FFTW_OMP_FLAGS` : OpenMP flags for building FFTW
- `FFTW_CXX_FLAGS` : FFTW flags

### Hello World Example

For the following OpenMP Hello World example.

```cpp
#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.
```cmake
find_package(BigMac REQUIRED)
set(CMAKE_CXX_FLAGS ${OpenMP_CXX_FLAGS})
add_executable(hello_world src/hello_world.cpp)
```
21 changes: 21 additions & 0 deletions bigmac/BigMacConfig.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Enable OpenMP for Clang
message(STATUS "BigMac -> Setting OpenMP variables for ${CMAKE_CXX_COMPILER_ID}")
set(OpenMP_INCLUDE_PATH "/usr/local/include")
set(OpenMP_LIB_PATH "/usr/local/lib")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -lomp")
set(OpenMP_CXX_LIB_NAMES "omp")
set(OpenMP_CXX_LIBRARIES "${OpenMP_LIB_PATH}/libomp.dylib")
include_directories(${OpenMP_INCLUDE_PATH})
link_directories(${OpenMP_LIB_PATH})
message(STATUS " - OpenMP_INCLUDE_PATH ${OpenMP_INCLUDE_PATH}")
message(STATUS " - OpenMP_LIB_PATH ${OpenMP_LIB_PATH}")
message(STATUS " - OpenMP_CXX_FLAGS ${OpenMP_CXX_FLAGS}")
message(STATUS " - OpenMP_CXX_LIB_NAMES ${OpenMP_CXX_LIB_NAMES}")
message(STATUS " - OpenMP_CXX_LIBRARIES ${OpenMP_CXX_LIBRARIES}")

# Set FFTW flags for Clang
message(STATUS "BigMac -> Setting FFTW variables for ${CMAKE_CXX_COMPILER_ID}")
set(FFTW_OMP_FLAGS "-lomp")
set(FFTW_CXX_FLAGS "-Xpreprocessor -fopenmp")
message(STATUS " - FFTW_OMP_FLAGS ${FFTW_OMP_FLAGS}")
message(STATUS " - FFTW_CXX_FLAGS ${FFTW_CXX_FLAGS}")
27 changes: 1 addition & 26 deletions bigmac/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,4 @@
cmake_minimum_required(VERSION 3.0)
project(bigmac)

# Enable OpenMP for Clang
set(OpenMP_INCLUDE_PATH "/usr/local/include")
set(OpenMP_LIB_PATH "/usr/local/lib")
set(OpenMP_CXX_FLAGS "-Xpreprocessor -fopenmp -lomp")
set(OpenMP_CXX_LIB_NAMES "omp")
set(OpenMP_CXX_LIBRARIES "${OpenMP_LIB_PATH}/libomp.dylib")
include_directories(${OpenMP_INCLUDE_PATH})
link_directories(${OpenMP_LIB_PATH})
if(USE_FFTW)
set(FFTW_OMP_FLAGS "-lomp")
set(FFTW_CXX_FLAGS "-Xpreprocessor -fopenmp")
endif(USE_FFTW)

message(STATUS "OpenMP_CXX_FLAGS ${OpenMP_CXX_FLAGS}")

# Set CXX FLAGS
set(CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS}")

set(CPP_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(SOURCE_LIST hello_world)

foreach(program ${SOURCE_LIST})
add_executable(${program} ${CPP_SOURCE_DIR}/${program}.cpp)
endforeach(program)

INSTALL(TARGETS ${SOURCE_LIST} DESTINATION bin)
install(FILES BigMacConfig.cmake DESTINATION lib/cmake/BigMac)
9 changes: 0 additions & 9 deletions bigmac/lib/cmake/BigMacConfig.cmake

This file was deleted.

12 changes: 0 additions & 12 deletions bigmac/src/hello_world.cpp

This file was deleted.

0 comments on commit 71df6fa

Please sign in to comment.