From 6995949b2c71f78b56265cf798c6ef76635871fb Mon Sep 17 00:00:00 2001 From: Fangjun Zhou Date: Mon, 13 Feb 2023 12:48:00 -0600 Subject: [PATCH] Added: CMake Support --- .gitignore | 1 + CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 CMakeLists.txt diff --git a/.gitignore b/.gitignore index 25a7384..3d7ed6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.o *.exe +build/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..60e1ef0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,34 @@ +# -------------------- Project Information ------------------- # + +cmake_minimum_required(VERSION 3.25.1) + +project(stream) + +# ------------------- Environment Settings ------------------- # + +if (APPLE) + # Need llvm installed. + set(CMAKE_CXX_COMPILER /usr/local/opt/llvm/bin/clang++) + set(CMAKE_C_COMPILER /usr/local/opt/llvm/bin/clang) + # Link llvm libraries. + link_directories(/usr/local/opt/llvm/lib) +elseif(UNIX AND NOT APPLE) + # Use g++ on Linux. + set(CMAKE_CXX_COMPILER g++) + set(CMAKE_C_COMPILER gcc) +else() + # TODO: Windows support. + message("Platform not support.") +endif() + +# ------------------ Executable Compilation ------------------ # + +file( + GLOB + SRC + stream.c +) +# Build with OpenMP +add_executable(${PROJECT_NAME} ${SRC}) +target_link_libraries(${PROJECT_NAME} PRIVATE -fopenmp) +target_compile_options(${PROJECT_NAME} PRIVATE -O2 -fopenmp) \ No newline at end of file