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
per target compiler and linker flags
-
- Posts: 775
- Joined: Tue Dec 04, 2012 3:53 pm
- Location: INRIA Rennes, FRANCE
Re: per target compiler and linker flags
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
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
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
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)
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)
-
- Posts: 775
- Joined: Tue Dec 04, 2012 3:53 pm
- Location: INRIA Rennes, FRANCE
Re: per target compiler and linker flags
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
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
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
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
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 can help a lot.
Cheers
Jozef
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
Cheers
Jozef