Here is my CMakeList.text:
cmake_minimum_required(VERSION 3.12)
project(project)
set(CMAKE_CXX_STANDARD 14)
FIND_PACKAGE(Boost 1.66 REQUIRED date_time program_options thread filesystem system unit_test_framework)
IF(${Boost_FOUND})
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
ENDIF()
add_executable(project main.cpp)
target_link_libraries(project ${Boost_LIBRARIES})
It configures well and according to the output info it did find where the boost is.
However, when I tried to run my program, it shows the error:
gmake[3]: *** No rule to make target '/usr/include/_ansi.h', needed by 'CMakeFiles/project.dir/main.cpp.o'. Stop.
gmake[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/project.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/project.dir/rule] Error 2
gmake: *** [Makefile:118: project] Error 2
where _ansi.h
is the first header file in my /usr/include/
and boost is also located at /usr/include/boost
. I have checked that the file does exist and if I removed it, it would say no rule to make target on {the second header file}
.
Any idea how to fix this?
This snipped is adapted directly from the official documentation :
find_package(Boost 1.66 REQUIRED COMPONENTS date_time program_options thread filesystem system unit_test_framework)
if (Boost_FOUND)
add_executable(pro main.cpp)
target_link_libraries(pro Boost::date_time Boost::program_options Boost::thread Boost::filesystem Boost::system Boost::unit_test_framework)
endif()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.