繁体   English   中英

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

[英]Cilk plus annotation using JetBrains Clion IDE (C++)

我需要在我的 C++ 程序中使用 cilk plus 注释,例如:

#inlcude <cilk/cilk.h>

cilk_spawn myFunction();
cilk_sync;

我正在使用 JetBrains CLion IDE,但在宏替换后出现错误 Error: can't resolve type '_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'

你需要设置CMAKE_CXX_FLAGS您创建目标与add_executable

但是,我建议您改用target_compile_option

target_compile_options(C__Threads PUBLIC -fcilkplus)

当然,这必须在add_executable之后add_executable

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM