Quantcast

Cmake

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cmake

aishwarya selvaraj
Hi Everyone,
Myself Aishwarya .I wanted to make use of Cmake , but I'm really new to this and doesn't have a clear idea about it.

1) My Goal :
I'm using Praat a speech Processing Software to create plug - in for my Algorithm on Pitch and Time scaling .(I have the .cpp file)
In order to do that I need to use the binary file obtained by compiling .cpp file
​in my Praat Script .
I intent to share this plug - in with others ,Hence I want it to be machine independent .The binary file I obtained is using gcc in Linux (16.0.2), which clearly wont work in Mac or Windows or even in lower Linux Version.
To solve this Problem I understand that I need to make use of Cmake files .

2) My .cpp file called TSM_CODE_V3.cpp is compiled as
g++ TSM_CODE_V3.cpp -larmadillo -lsndfile -o TSM

where armadillo and sndfile are two depended libraries.

3) What I have done :
​I have gone through a loot of tutorials for cmake .I have wage idea , but I'm not able to solve my problem mentioned above .
​My folder TSM consists of
build - the folder which consists the final executable binary file and the related cmake files required to create binary file
src - consists of my TSM_CODE_V3.cpp code
CMakeLists.txt - The top level Cmake file :

         cmake_minimum_required(VERSION 2.8.9)
         project(directory_TSM)
         include_directories(include)
         file(GLOB SOURCES "src/*.cpp")
         add_executable(tsm ${SOURCES})


I need to include the library armadillo and lidsndfile .
I dont know how to include it into my cmakefile .
I have come across find_package ,find_library  but I am sure about it .
 To create my Praat Plug - in I need to compile the source code no matter in which system it is ,which may or may not have these two libraries already installed.
So how how do I add libraries using cmake ?
I hope you got my point .
Could help me ?


Hoping for your reply .

--
Regards,
Aishwarya Selvaraj

--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cmake

Stuermer, Michael  SP/HZA-ZSEP

Hello,

 

To add your mentioned libraries to the executable you have to link against them. For this the cmake command

 

target_link_libraries() is used: https://cmake.org/cmake/help/v3.7/command/target_link_libraries.html

 

In your case the cmake code should look similar to this:

 

target_link_libraries(tsm armadillo lidsndfile)

 

best regards,

Michael

 

From: CMake [mailto:[hidden email]] On Behalf Of aishwarya selvaraj
Sent: Wedn
esday, December 21, 2016 12:52 PM
To: [hidden email]
Subject: [CMake] Cmake

 

Hi Everyone,

Myself Aishwarya .I wanted to make use of Cmake , but I'm really new to this and doesn't have a clear idea about it.

1) My Goal :

I'm using Praat a speech Processing Software to create plug - in for my Algorithm on Pitch and Time scaling .(I have the .cpp file)

In order to do that I need to use the binary file obtained by compiling .cpp file

​in my Praat Script .

I intent to share this plug - in with others ,Hence I want it to be machine independent .The binary file I obtained is using gcc in Linux (16.0.2), which clearly wont work in Mac or Windows or even in lower Linux Version.

To solve this Problem I understand that I need to make use of Cmake files .

2) My .cpp file called TSM_CODE_V3.cpp is compiled as

g++ TSM_CODE_V3.cpp -larmadillo -lsndfile -o TSM

where armadillo and sndfile are two depended libraries.

 

3) What I have done :

​I have gone through a loot of tutorials for cmake .I have wage idea , but I'm not able to solve my problem mentioned above .

​My folder TSM consists of
build - the folder which consists the final executable binary file and the related cmake files required to create binary file

src - consists of my TSM_CODE_V3.cpp code

CMakeLists.txt - The top level Cmake file :

         cmake_minimum_required(VERSION 2.8.9)
         project(directory_TSM)
         include_directories(include)
         file(GLOB SOURCES "src/*.cpp")
         add_executable(tsm ${SOURCES})

I need to include the library armadillo and lidsndfile .

I dont know how to include it into my cmakefile .

I have come across find_package ,find_library  but I am sure about it .

 To create my Praat Plug - in I need to compile the source code no matter in which system it is ,which may or may not have these two libraries already installed.

So how how do I add libraries using cmake ?

I hope you got my point .

Could help me ?

Hoping for your reply .


--

Regards,
Aishwarya Selvaraj


--

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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cmake

Dan Liew
In reply to this post by aishwarya selvaraj
Hi Aishwarya,

On 21 December 2016 at 11:51, aishwarya selvaraj
<[hidden email]> wrote:

> Hi Everyone,
> Myself Aishwarya .I wanted to make use of Cmake , but I'm really new to this
> and doesn't have a clear idea about it.
>
> 1) My Goal :
> I'm using Praat a speech Processing Software to create plug - in for my
> Algorithm on Pitch and Time scaling .(I have the .cpp file)
> In order to do that I need to use the binary file obtained by compiling .cpp
> file
> in my Praat Script .
> I intent to share this plug - in with others ,Hence I want it to be machine
> independent .The binary file I obtained is using gcc in Linux (16.0.2),
> which clearly wont work in Mac or Windows or even in lower Linux Version.
> To solve this Problem I understand that I need to make use of Cmake files .

CMake is not going make your binaries machine independent. It can give
a way to build your application that will successfully compile on
different platforms but you will have to compile the binary on each
platform that you are targeting.

> 2) My .cpp file called TSM_CODE_V3.cpp is compiled as
> g++ TSM_CODE_V3.cpp -larmadillo -lsndfile -o TSM
>
> where armadillo and sndfile are two depended libraries.
>
> 3) What I have done :
> I have gone through a loot of tutorials for cmake .I have wage idea , but
> I'm not able to solve my problem mentioned above .
> My folder TSM consists of
> build - the folder which consists the final executable binary file and the
> related cmake files required to create binary file
> src - consists of my TSM_CODE_V3.cpp code
> CMakeLists.txt - The top level Cmake file :
>
>          cmake_minimum_required(VERSION 2.8.9)
>          project(directory_TSM)
>          include_directories(include)
>          file(GLOB SOURCES "src/*.cpp")
>          add_executable(tsm ${SOURCES})

Do not use `file(GLOB ...)` to find source files. It is very bad
practice because it prevents CMake from re-generating itself
automatically. You should list the source files explicitly. That way
when you add/remove a source file the fact you updated the
`CMakeLists.txt` file will trigger a re-configure of the build system.

>
> I need to include the library armadillo and lidsndfile .
> I dont know how to include it into my cmakefile .
> I have come across find_package ,find_library  but I am sure about it .
>  To create my Praat Plug - in I need to compile the source code no matter in
> which system it is ,which may or may not have these two libraries already
> installed.
> So how how do I add libraries using cmake ?

Use `target_link_libraries()` to link libraries into your target. If
you're not sure how to use it I highly recommend you read the
documentation for it [1].

In terms of finding the library if there is no package for those
libraries you can use the `find_library()` command. Again if you're
not sure how to use it check out the documentation [2].

Seeing as you are very new to CMake I would also recommend reading [3]
which explains some important high level concepts in CMake.

[1] https://cmake.org/cmake/help/v3.6/command/target_link_libraries.html
[2] https://cmake.org/cmake/help/v3.6/command/find_library.html
[3] https://cmake.org/cmake/help/v3.6/manual/cmake-buildsystem.7.html
--

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
Loading...