Issue with CMAKE: Target was not found
On executing the command cmake .
I get the following error:
CMake Warning (dev) in CMakeLists.txt:
No project() command is present. The top-level CMakeLists.txt file must
contain a literal, direct call to the project() command. Add a line of
code such as
project(ProjectName)
near the top of the file, but after cmake_minimum_required().
CMake is pretending there is a "project(Project)" command on the first
line.
This warning is for project developers. Use -Wno-dev to suppress it.
-- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: IOStreams Filesystem Regex Serialization System Timer program_options
-- Configuring done
CMake Error at CMakeLists.txt:12 (TARGET_LINK_LIBRARIES):
Target "driver" links to:
Boost::IOStreams
but the target was not found. Possible reasons include:
* There is a typo in the target name.
* A find_package call is missing for an IMPORTED target.
* An ALIAS target is missing.
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
The content of the CMakeLists.txt file is following:
cmake_minimum_required(VERSION 3.13)
set(BOOST_COMPONENTS IOStreams Filesystem Regex Serialization System Timer program_options)
FIND_PACKAGE( Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
set(CMAKE_CXX_FLAGS "-std=c++11 -O2 ${CMAKE_CXX_FLAGS}")
aux_source_directory(. SRC)
set (CMAKE_CXX_STANDARD 11)
ADD_EXECUTABLE( driver driver.cpp ${SRC})
include_directories(${Boost_INCLUDE_DIRS})
TARGET_LINK_LIBRARIES( driver ${Boost_LIBRARIES} )
Could you please let me know what is the issue? CMake version: 3.25.1 Boost version: 1.71.0.0ubuntu2 OS: Ubuntu 20.04.3 LTS
Thanks
Edited by Aakash