Cilk 加上使用 JetBrains Clion IDE 的注释 (C++)



我需要在我的C++程序中使用 cilk 加注释,如下所示:

#inlcude <cilk/cilk.h>
cilk_spawn myFunction();
cilk_sync;

我正在使用 JetBrains CLion IDE,但收到错误宏替换后错误:无法解析类型"_Cilk_spawn"。我想知道是否有任何解决方案。当然,直接从我的终端使用 g++,我只是添加选项 -fcilkplus,但在这种情况下,我不知道如何解决这个问题。以下是我的CMakeLists.txt文件(更新)的内容:

cmake_minimum_required(VERSION 3.8)
project(C__Threads)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
set(CMAKE_CXX_FLAGS "-fcilkplus") // I've also put this one because otherwise the building process fails.
add_executable(C__Threads ${SOURCE_FILES})
target_compile_options(C__Threads PUBLIC -fcilkplus)
set(CMAKE_VERBOSE_MAKEFILE ON)

这是构建输出(更新):

/home/leo/clion-2017.2.3/bin/cmake/bin/cmake --build /home/leo/CLionProjects/C++Threads/cmake-build-debug --target C__Threads -- -j 4
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -H/home/leo/CLionProjects/C++Threads -B/home/leo/CLionProjects/C++Threads/cmake-build-debug --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/make -f CMakeFiles/Makefile2 C__Threads
make[1]: Entering directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -H/home/leo/CLionProjects/C++Threads -B/home/leo/CLionProjects/C++Threads/cmake-build-debug --check-build-system CMakeFiles/Makefile.cmake 0
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -E cmake_progress_start /home/leo/CLionProjects/C++Threads/cmake-build-debug/CMakeFiles 2
/usr/bin/make -f CMakeFiles/Makefile2 CMakeFiles/C__Threads.dir/all
make[2]: Entering directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
/usr/bin/make -f CMakeFiles/C__Threads.dir/build.make CMakeFiles/C__Threads.dir/depend
make[3]: Entering directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
cd /home/leo/CLionProjects/C++Threads/cmake-build-debug && /home/leo/clion-2017.2.3/bin/cmake/bin/cmake -E cmake_depends "Unix Makefiles" /home/leo/CLionProjects/C++Threads /home/leo/CLionProjects/C++Threads /home/leo/CLionProjects/C++Threads/cmake-build-debug /home/leo/CLionProjects/C++Threads/cmake-build-debug /home/leo/CLionProjects/C++Threads/cmake-build-debug/CMakeFiles/C__Threads.dir/DependInfo.cmake --color=
make[3]: Leaving directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
/usr/bin/make -f CMakeFiles/C__Threads.dir/build.make CMakeFiles/C__Threads.dir/build
make[3]: Entering directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
[ 50%] Building CXX object CMakeFiles/C__Threads.dir/main.cpp.o
/usr/bin/c++    -fcilkplus -g   -fcilkplus -std=gnu++11 -o CMakeFiles/C__Threads.dir/main.cpp.o -c /home/leo/CLionProjects/C++Threads/main.cpp
[100%] Linking CXX executable C__Threads
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/C__Threads.dir/link.txt --verbose=1
/usr/bin/c++  -fcilkplus -g   CMakeFiles/C__Threads.dir/main.cpp.o  -o C__Threads 
make[3]: Leaving directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
[100%] Built target C__Threads
make[2]: Leaving directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
/home/leo/clion-2017.2.3/bin/cmake/bin/cmake -E cmake_progress_start /home/leo/CLionProjects/C++Threads/cmake-build-debug/CMakeFiles 0
make[1]: Leaving directory '/home/leo/CLionProjects/C++Threads/cmake-build-debug'
在使用

add_executable 创建目标之前,您需要设置CMAKE_CXX_FLAGS

但是,我建议您改用target_compile_option

target_compile_options(C__Threads PUBLIC -fcilkplus)

当然,这必须在add_executable之后完成。

相关内容

  • 没有找到相关文章

最新更新