[CMake] Linking own header files to a source code
Micha Hergarden
micha.hergarden at gmail.com
Tue Jul 14 13:19:39 EDT 2015
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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150714/472dfbf0/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150714/472dfbf0/attachment.sig>
More information about the CMake
mailing list