I have a project with the following layout:
.
|_include
| |_GLFW
| |_glfw3.h
|_lib
| |_glfw3.lib
|_src
| |_main.cpp
|_build
|_CMakeLists.txt
The CMakeLists.txt looks like this:
cmake_minimum_required( VERSION 3.14 )
project( example LANGUAGES CXX )
set( INCLUDE_HEADERS
include/GLFW/glfw3.h
)
set( SRC
src/main.cpp
)
source_group( include FILES ${INCLUDE_HEADERS} )
source_group( src FILES ${SRC} )
add_executable( example ${INCLUDE_HEADERS} ${SRC} )
target_link_libraries( example "${CMAKE_BINARY_DIR}/lib/glfw3.lib" )
I go to ./build
and type cmake ..
This creates a Visual Studio 2017 solution as expected. But in the example
project, it lists the dependency path of glfw3.lib
as lib\glfw3.lib
and says it can't find it.
As far as I understand, CMAKE_BINARY_DIR
is supposed to represent the absolute path of the project, and that is what I get if I try to print it out using message
. Why does it change the absolute path to a (faulty) relative path in the Visual Studio solution?
I have also tried using CMAKE_SOURCE_DIR
, CMAKE_CURRENT_BINARY_DIR
and CMAKE_CURRENT_SOURCE_DIR
, and all of them change the absolute path to a relative path.