title: Python and C++: How to use pybind11 with Cmakelists including GSL libraries
body: <p>I want to be able to call my C++ code as a python package. To do this I am using <code>pybind11</code> with CMakelists (following this example <a href="https://github.com/pybind/cmake_example" rel="noreferrer">https://github.com/pybind/cmake_example</a>). My problem is that I have to include GSL libraries in the compilation of the code, and these need an explicit linker   <code>-lgsl</code> . </p>
  
  <p>If I were just to compile and run the C++  without wrapping it with python, the following Cmakelists.txt file does the job </p>
  
  <pre><code>cmake_minimum_required(VERSION 3.0)
  
  set(CMAKE_BUILD_TYPE Debug)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  
  project(myProject)
  
  
  add_executable(
      myexecutable
      main.cpp
      function1.cpp
  )
  
  find_package(GSL REQUIRED)
  target_link_libraries(myexecutable GSL::gsl GSL::gslcblas)
  </code></pre>
  
  <p>but when using <code>pybind11</code> the template I found doesn't allow the <code>add_executable</code> therefore  <code>target_link_libraries</code> doesn't work. </p>
  
  <p>I have trie this</p>
  
  <pre><code>project(myProject)
  
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_CXX_STANDARD_REQUIRED YES)   # See below (1)
  
  
  
  # Set source directory
  set(SOURCE_DIR "project")
  
  # Tell CMake that headers are also in SOURCE_DIR
  include_directories(${SOURCE_DIR})
  set(SOURCES "${SOURCE_DIR}/functions.cpp")
  
  
  # Generate Python module
  add_subdirectory(lib/pybind11)
  pybind11_add_module(namr ${SOURCES} "${SOURCE_DIR}/bindings.cpp")
  
  
  FIND_PACKAGE(GSL REQUIRED)
  target_link_libraries(GSL::gsl GSL::gslcblas)
  </code></pre>
  
  <p>but this produces errors in the building. </p>
  
  <p>Any idea ? </p>