I have a project called myproject
, with a build directory myhome/myproject/build
.
I have a library called libmylibrary.so
that lives in myhome/folder/lib
with headers in myhome/folder/include
Then I have a CMakeLists.txt in myhome/myproject
which looks like:
cmake_minimum_required(VERSION 3.5.1)
project (myproject)
file(GLOB SOURCES "src/*.cpp")
add_executable(myproject ${SOURCES})
find_library(MYLIB mylibrary REQUIRED)
target_link_libraries(myproject PRIVATE mylibrary)
I run cmake ../
in the build directory, and then make
, and I get:
/usr/bin/ld: cannot find -lmylibrary
collect2: error: ld returned 1 exit status
I simply do not understand how this is so difficult. What am I missing? I have tried what feels like every combination of random but extremely similarly named CMake directives, with no success (and no information about the reasons for success or failure, so it's literally just trial and error).
How can I tell [whatever thing needs to know] where my library is, so that CMake can find it, without it being hard-coded in the CMake script? Thanks.
Thanks