On Thu, 2019-06-27 at 22:24 -0700, dexter810 wrote:
> This is my CMakeLists.txt which is successfully building a shared
> library, I
> just wanted to confirm if it's the right way and it: 
> 
> cmake_minimum_required(VERSION 3.6)
> project(main)
> 
> 
> 
> include_directories(
>         ${CMAKE_CURRENT_SOURCE_DIR}/include
>        
> ${CMAKE_CURRENT_SOURCE_DIR}/build/deps/yara/src/yara/libyara/include)
> 
> add_library(main SHARED main.cpp)
> 
> 
> link_libraries (
>         -L${CMAKE_CURRENT_SOURCE_DIR}/build/src/
>         -
> L${CMAKE_CURRENT_SOURCE_DIR}/build/deps/yara/src/yara/libyara/.libs
>     yaracpp yara pthread ssl crypto)

Rather than specifying -L flags and specifying library names, there are
two other approaches you can take that would be better:

1) Use target_link_directories() in conjunction with
target_link_libraries().
2) Use find_package(Threads) to find pthread, and use find_library()
for everything else.

https://cmake.org/cmake/help/latest/command/find_package.html
https://cmake.org/cmake/help/latest/command/find_library.html

Kyle
-- 

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:
https://cmake.org/mailman/listinfo/cmake

Reply via email to