[CMake] Overriding the include path, library path of OpenSSL, Zlib and libcurl

Michael Ellery mellery451 at gmail.com
Fri Apr 21 14:03:56 EDT 2017


after find_package is invoked, several variables will be set. You use these to augment your compiler and linker information, e.g.:

target_include_directories(mytarget $ZLIB_INCLUDE_DIRS)
target_link_libraries(mytarget $ZLIB_LIBRARIES)

…and so on for other modules you find (OpenSSL, for example).  You can also choose to add the include paths “globally” using include_directories(), but it’s usually considered best practice to modify individual target properties where possible.

-Mike
..
> On Apr 21, 2017, at 10:58 AM, Alex Chen <alex_chen at filemaker.com> wrote:
> 
> Although cmake uses the path I supplied for OpenSSL and Zlib, I do not see the –I flag being used in compiling the code. (I set VERBOSE=1 to make to see what it does.)
> When I run ‘ldd’ against the resulting .so files, reference to libssl.so or libcrypto.so is empty, i.e ‘libssl.so => not found’, but libz.so still links to /lib64/libz.so. (It seems to ignore the fact it does find a new path of zlib.)
>  
> How to I set the linker flag, i.e. –L and –Wl,-rpath=$myLibPath ?
>  
> Alex Chen
>  
> From: CMake <cmake-bounces at cmake.org> on behalf of Alex Chen <alex_chen at filemaker.com>
> Date: Friday, April 21, 2017 at 10:28 AM
> To: CMake <cmake at cmake.org>
> Subject: Re: [CMake] Overriding the include path, library path of OpenSSL, Zlib and libcurl
>  
> Thanks for the help.  I will try that. 
>  
> Alex Chen
>  
> From: Michael Ellery <mellery451 at gmail.com>
> Date: Thursday, April 20, 2017 at 8:13 PM
> To: Alex Chen <alex_chen at filemaker.com>
> Cc: CMake <cmake at cmake.org>
> Subject: Re: [CMake] Overriding the include path, library path of OpenSSL, Zlib and libcurl
>  
> It doesn’t look like that find module directly supports HINTS or PATHS, so you can try setting CMAKE_LIBRARY_PATH and CMAKE_INCLUDE_PATH  (https://cmake.org/cmake/help/v3.7/variable/CMAKE_LIBRARY_PATH.html) before calling the curl finder. I think you can add to those variables whatever paths are appropriate to search for CURL on your systems.
>  
> -Mike
>  
>> On Apr 20, 2017, at 6:06 PM, Alex Chen <alex_chen at filemaker.com> wrote:
>> The source code I want to compile on Linux uses ‘FindOpenSSL’, ‘FindZLIB’, and ‘FindCURL’ to resolve the paths of these libraries.
>> However, I have newer version of these libraries in different locations.  How to I override these to use my paths?
>> I am able to use OPENSSL_ROOT_DIR, from FindOpenSSL module, and ZLIB_ROOT, from FindZLIB module, to override the paths.  
>> But I cannot find anything in FindCURL module to override the path of libcurl.
>>   
>>   
>> Alex Chen
>> -- 
>> Powered by www.kitware.com
>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>> CMake Support: http://cmake.org/cmake/help/support.html
>> CMake Consulting: http://cmake.org/cmake/help/consulting.html
>> CMake Training Courses: http://cmake.org/cmake/help/training.html
>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/cmake
>  
>  
> -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQKitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake



More information about the CMake mailing list