[CMake] Linking own header files to a source code

J Decker d3ck0r at gmail.com
Wed Jul 15 03:18:54 EDT 2015


and INCLUDE_DIRECTORIES

On Tue, Jul 14, 2015 at 10:19 AM, Micha Hergarden <micha.hergarden at gmail.com
> wrote:

>  Hello,
>
> You don't seem to tell cmake what executable you want and what sources it
> is made up of. Take a look at the 'add_executable' and 'add_library'
> commands. To create an executable from the sources, you may want to do
> something like: add_executable(test01 test01.cc)
> And for the library: add_library(trace libtrace.h libtrace.cc)
>
> Add these statements between the 'find_package' and
> 'target_link_libraries' statements. If you then run cmake, two actual build
> targets get generated which you can see with 'make help' if you are using
> make.
>
> Regards,
> Micha
>
>
> On 07/14/2015 01:51 PM, Peleg Bar-Sapir wrote:
>
>     Hello,
>
>  I'm trying to configure my own library (called "libtrace") to a test file
> I made.
>
> My source library contains the following files:
>  libtrace.h -- Header file for the libtrace library.
> libtrace.cc -- Source file for the libtrace library.
> test01.cc -- A test file that uses libtrace.
>  CMakeLists.txt -- CMake's config file.
>
>  I also have a MySQL connector linked to my project (in the manner Daniel
> Schepler had helped me with back in late April) - so CMakeLists.txt looks
> like this:
> .......................................................................
> cmake_minimum_required(VERSION 2.8)
>  project( Test )
>
> set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
> "${CMAKE_SOURCE_DIR}/cmake/Modules/")
>
> find_package( MySQL REQUIRED )
> target_link_libraries( Test ${MYSQL_LIBRARY} )
> include_directories(${MYSQL_INCLUDE_DIR})
> .......................................................................
>
>  ...I cannot seem to connect my own library with nay success (I followed
> the tutorial from here: http://www.cmake.org/cmake-tutorial/ ). It keeps
> giving me errors.
>
>  Any help with ordering the CMakeLists.txt file would be greatly
> appreciated.
>
>
>  Thanks,
>
>  Peleg Bar Sapir
>
>
>
>
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150715/f5b50c71/attachment-0001.html>


More information about the CMake mailing list