I'm trying to configure cmake for c++ project and link my library. For some reason, I can't make cmake find my library in ./lib// folder. According to the documentation, the library search path should be /lib/.
I have tried with empty prefix and with "./" and in neither case my library is found.
If I give HINT in find_library(), then it is found, but why isn't it found without the hint?
This is my CMakeList.txt:
cmake_minimum_required(VERSION 3.0.0)
project(UntitledProject VERSION 0.1.0)
include(CTest)
enable_testing()
message("ARCH: " ${CMAKE_LIBRARY_ARCHITECTURE})
message("PREFIX: " ${CMAKE_PREFIX_PATH})
message("LIB: " ${CMAKE_LIBRARY_PATH})
find_library(LIBMYLIB mylibrary)
message("MYLIB: " ${LIBMYLIB})
add_executable(UntitledProject main.cpp)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
Shared library indeed exists:
$ file lib/x86_64-linux-gnu/libmylibrary.so
lib/x86_64-linux-gnu/libmylibrary.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e34ba5ae24d6a09bfb847a46cd669ea7e101e8a4, stripped
This is the cmake configure output:
[cmake] The C compiler identification is GNU 7.5.0
[cmake] The CXX compiler identification is GNU 7.5.0
[cmake] Check for working C compiler: /usr/bin/x86_64-linux-gnu-gcc-7
[cmake] Check for working C compiler: /usr/bin/x86_64-linux-gnu-gcc-7 -- works
[cmake] Detecting C compiler ABI info
[cmake] Detecting C compiler ABI info - done
[cmake] Detecting C compile features
[cmake] Detecting C compile features - done
[cmake] Check for working CXX compiler: /usr/bin/x86_64-linux-gnu-g++-7
[cmake] Check for working CXX compiler: /usr/bin/x86_64-linux-gnu-g++-7 -- works
[cmake] Detecting CXX compiler ABI info
[cmake] Detecting CXX compiler ABI info - done
[cmake] Detecting CXX compile features
[cmake] Detecting CXX compile features - done
[cmake] ARCH: x86_64-linux-gnu
[cmake] PREFIX:
[cmake] LIB:
[cmake] MYLIB: LIBMYLIB-NOTFOUND
[cmake] Configuring done
[cmake] Generating done
What am I missing?