diff --git a/README.md b/README.md index 8b638bd..05bd0e8 100644 --- a/README.md +++ b/README.md @@ -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 +#include + +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) +``` diff --git a/bigmac/BigMacConfig.cmake b/bigmac/BigMacConfig.cmake new file mode 100644 index 0000000..4841af8 --- /dev/null +++ b/bigmac/BigMacConfig.cmake @@ -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}") diff --git a/bigmac/CMakeLists.txt b/bigmac/CMakeLists.txt index a275e31..ff7f0ca 100644 --- a/bigmac/CMakeLists.txt +++ b/bigmac/CMakeLists.txt @@ -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) diff --git a/bigmac/lib/cmake/BigMacConfig.cmake b/bigmac/lib/cmake/BigMacConfig.cmake deleted file mode 100644 index a9e804f..0000000 --- a/bigmac/lib/cmake/BigMacConfig.cmake +++ /dev/null @@ -1,9 +0,0 @@ -# Enable OpenMP for Clang -message(STATUS "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}) diff --git a/bigmac/src/hello_world.cpp b/bigmac/src/hello_world.cpp deleted file mode 100644 index 9f41d8a..0000000 --- a/bigmac/src/hello_world.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include - -int main(int argc, char** argv){ - - #pragma omp parallel - { - printf("Hello from process: %d\n", omp_get_thread_num()); - } - - return 0; -}