-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
85 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.