Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.o
*.exe
build/
34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Comment on lines +11 to +14
Copy link

@giordano giordano Sep 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think hardcoding absolute paths is a good idea at all, even more so if these are homebrew paths. Also, I don't see why hardcoding CMAKE_C_COMPILER at all instead of letting it to be set by users.

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)