Reputation: 180
Im trying to configure CLion so that I can use openMP. When using the default settings on my Mac, the compiler is clang. Default Apple clang does not support openMP.
When I change my compiler to GCC, the debugger will not stop at breakpoints. The program just runs as it would when executing the compiled file.
The CMakeLists.txt file below works perfectly with CLion debugger. When I uncomment out the compiler flags, the debugger ignores the breakpoints.
cmake_minimum_required(VERSION 3.8)
project(CLionTest)
set(CMAKE_C_STANDARD 99)
#set(CMAKE_C_COMPILER /usr/local/bin/gcc-7)
#set(CMAKE_C_FLAGS -fopenmp)
#set(CMAKE_C_FLAGS_DEBUG "-D_DEBUG")
set(MAIN main.c)
add_executable(CLionTest ${MAIN})
add_custom_target(CLionTestMake COMMAND make all WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
How do I fix this?
Toolchain settings: CMake executable: Bundeled CMake 3.8.2 Debugger: Bundled LLDB 3.9.0
main.c:
#include <stdio.h>
#include <unistd.h>
#ifdef _OPENMP
#include <omp.h>
#endif
int main() {
printf("Hello, World!\n");
#pragma omp parallel
{
#ifdef _OPENMP
int size = omp_get_num_threads();
int rank = omp_get_thread_num();
#else
int rank = 0;
int size = 1;
#endif
printf("%d/%d\n", rank, size);
};
return 0;
}
Upvotes: 1
Views: 3130
Reputation: 126937
set(CMAKE_C_FLAGS -fopenmp)
set(CMAKE_C_FLAGS_DEBUG "-D_DEBUG")
You are replacing the C flags instead of appending them, so you are dropping the builtin -g
option that generates debug symbols. Instead, do
set(CMAKE_C_FLAGS "${CMAKE_CFLAGS} -fopenmp")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
Upvotes: 3