Page 1 of 1

per target compiler and linker flags

Posted: Tue Feb 12, 2013 8:54 pm
by smeeze
Hi,

I'm trying to build a new driver in OV. This driver depends on external software(headers+libs). How do I add compiler and linker flags to this specific driver without having all other created plugins also link to the external libs? Is there a 'per-target' CMakeLists.txt that I can edit?

Yours, Robert

Re: per target compiler and linker flags

Posted: Wed Feb 13, 2013 8:10 am
by jtlindgren
Hi,

does your driver naturally belong under acquisition server, in "openvibe-applications/acquisition-server/trunc/src"? In that case, currently the CMakeLists.txt in the parent folder just recursively finds all source and header files and statically links them to the acquisition server (afaik). You'd need to add Find* script that puts up the necessary flags given that your dependencies are found on the machine, and call it from the CMakeLists. The whole acquisition server then gets linked against them. The drivers do not turn out as individual .dlls in this case. Possibly separate defines can be given for individual sources in CMake somehow, but its not currently done. Maybe CMake documentation can help there?


Happy hacking,
Jussi

Re: per target compiler and linker flags

Posted: Fri Feb 15, 2013 2:11 pm
by smeeze
Thank you, that did the trick. However I'm having other issues now, which probably have to be answered in another topic... It's the ogre.h not being found. Nothing I do makes any difference; installing debian provided packages, compiling ogre myself, cleaning all builds, using the openvibe provided package, setting compiler flags.. any ideas for debian users?

Re: per target compiler and linker flags

Posted: Fri Feb 15, 2013 9:29 pm
by smeeze
answering my own question here. I found what was causing my issues. The -Wall option that is set in the CMakeFiles.txt causes all previous CMAKE_CXX_FLAGS to be erased. I propose the following patch(against svn):

Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 3434)
+++ CMakeLists.txt (working copy)
@@ -7,7 +7,7 @@
IF(WIN32)
SET(CMAKE_CXX_FLAGS "/DWIN32 /D_WINDOWS /W3 /Zm1000 /EHsc /GR /wd4355")
ELSEIF(UNIX)
- SET(CMAKE_CXX_FLAGS "-Wall")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
ELSE(WIN32)
MESSAGE(STATUS "Warning: unknown platform")
ENDIF(WIN32)

Re: per target compiler and linker flags

Posted: Mon Feb 18, 2013 8:13 am
by jtlindgren
Good catch! I'll integrate your fix to the SVN. Thank you for the patch.

Problems with ogre.h solved now? If it was unrelated, let us know. People have had some curious difficulties with it in the past.


Cheers,
Jussi

Re: per target compiler and linker flags

Posted: Mon Feb 18, 2013 12:10 pm
by smeeze
hi,

my ogre.h issues are gone, but i cannot tell for sure if this was the fix. at the same time I made this change, I also found numerous CMake build dirs throughout the source, which off-course I removed since they might conflict. I usually set many compiler flags outside of CMake, so this definitely helps.

thanks

Re: per target compiler and linker flags

Posted: Tue Feb 19, 2013 12:45 pm
by jlegeny
hello smeeze,

the CMake folders will be created all over the source folder if the CMake is, for some reason, launched from the source folder.
The command

Code: Select all

find . -name CMakeFiles | grep -v local-tmp | xargs rm -fr
can help a lot.

Cheers
Jozef