Using CLion with openmp


Hi, i'm new to CLion and i have school assignment with openmp.

What should i do in order to use CLion with openmp (Mac OS).

Thank you very much!


CLion uses CMake as a build system, so you need to configure your CMakeLists.txt to work with OpenMP. Please take a look here:


Thank you I'll try that!


can you please explain that? does it work with mac???


@RR, yes, you can work with OpenMP in CLion on macOS. You need to configure your CMakeLists.txt in the appropriate way. Please see as my colleague suggested in the comment above.


This doesn't work on mac. I've even downloaded gcc and switched my compiler to gcc (shown below). I've been wrestling with this for half a day and I can't get clion to recognize openmp.


@Sethd63, the compiler you installed is not gcc, it's clang. You can check it using --version in Terminal:

You need to install gcc using Homebrew, for example.



# On Mac, 

I got it working along with debugger by changing the CMakeLists.txt. Make sure to change line 2 and line # 12 according to your folder name and file name. Clion is smart to detect it. But yeah, please make sure. I spent whole day to find the solution. : D. 

# Also I used the gcc-13 as a compiler which is downloaded from instead of the default clang compiler in Mac.

cmake_minimum_required(VERSION 3.26)
project(Project1 C)

# Specify the path to GCC-13 (replace with your actual path)
set(CMAKE_C_COMPILER /opt/homebrew/bin/gcc-13)


# Find OpenMP package
find_package(OpenMP REQUIRED)

add_executable(Project1 sequential.c)

# Enable OpenMP support
if (OpenMP_C_FOUND)
    target_link_libraries(Project1 PRIVATE ${OpenMP_C_LIBRARIES})
endif ()


Shresthapritam7, thank you for sharing! 

This is not directly relevant, but still: please note that gcc-13 is a C compiler. In the “C++ Compiler” field, g++-13 should be specified.


Please sign in to leave a comment.