Force CMake use the full library path

I have the following problem. I have a separate tree {bin, lib, include} on my Linux machine where CMake and all my libraries that I need for my development are installed. But only the PATH environment variable is set to this bin directory and for several reasons I cannot set LD_LIBRARY_PATH. All programs inside this tree are built using RPATH. CMake 3.3.1, which I use, is also located inside this tree.

Now I want to compile the program using libcurl and install the following CMakeLists.txt file

PROJECT(EXAMPLE)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
FIND_PACKAGE(CURL REQUIRED)
FIND_PACKAGE(OpenSSL REQUIRED) 
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
SET(LIBS ${CURL_LIBRARIES} ${OPENSSL_LIBRARIES}) 

ADD_EXECUTABLE(curl_ex src/curl_ex.c)
TARGET_LINK_LIBRARIES(curl_ex ${LIBS}) 

When I now start CMake, the curl and installation of OpenSSL from my personal software tree are found due to the fact that it is inside the same prefix as CMake.

make VERBOSE=1, :

gcc CMakeFiles/curl_ex.dir/src/curl_ex.c.o  -o curl_ex -rdynamic -lcurl -lssl -lcrypto 

curl openssl, cmake, .

CMake , , ?

+4
1

, , :

, CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES, "" , (. cmComputeLinkInformation::CheckImplicitDirItem() UnixPaths.cmake)

message("CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES: ${CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES}")
+6

Source: https://habr.com/ru/post/1611895/


All Articles