I am compiling my code, in which I use posix threads in C.
I am using CLion and its CMakeLists.txt:
cmake_minimum_required(VERSION 3.7)
project(Test)
set(CMAKE_C_STANDARD 99)
add_definitions(-lpthread)
set(SOURCE_FILES main.c)
add_executable(Test ${SOURCE_FILES})
I am getting errors (eg: undefined reference tosem_init'`). 
The proposed suggestion for solution is adding -lpthread compiler flag, but I already added it. 
I compiled the same code from commandline:
gcc main.c -lpthread
It compiles without any problem.
What can be a possible problem/solution for this?
 
    