Re: [CMake] Flags when building objects or a target
On 11/02/2010 01:58 AM, mina adel wrote: > Hi > > > I have a problem when cmake builds the objects for shared library. > > I have the following in my cmaklists.txt > > set(SIMULATOR_SOURCES circuit.cc matrix.cc plot.cc sources.cc > sparse.cc btzdense.cc element.cc util.cc parse.c > netlist_parse.y netlist_lex.l circuit_step.cc zmatrix.cc > hash_key.cc zsparse.cc zbtzdense.cc mtutil.cc) > > add_library(simulator SHARED ${SIMULATOR_SOURCES}) > > set_target_properties(simulator PROPERTIES LINK_FLAGS > "-I../sparse-libs/include") > target_link_libraries(simulator ${LIBS} "models/libmodels.a > ../sparse-libs/libsparse.a") > > > > However, target_link_libraries does not include the flags when building the > objects. it only does when building the library. [...] As the name LINK_FLAGS denotes, these settings are applied when a target is linked, i.e. built from its object files and checked for references to libraries. They don't come into play when sources are compiled to object files, so "-I" within LINK_FLAGS is of no use. > [...] And I do not want to add > (-I../sparse-libs/include) for all my objects. Consider to set the COMPILE_FLAGS source property on those files which you want to be compiled with "-I" flags for special include directories. Regards, Michael ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] Flags when building objects or a target
Am Tuesday 02 November 2010 schrieb mina adel: > Hi Please don't start a new discussion by replying to an old one. This completely breaks threading. > I have a problem when cmake builds the objects for shared library. > > I have the following in my cmaklists.txt > > set(SIMULATOR_SOURCES circuit.cc matrix.cc plot.cc sources.cc > sparse.cc btzdense.cc element.cc util.cc parse.c > netlist_parse.y netlist_lex.l circuit_step.cc zmatrix.cc > hash_key.cc zsparse.cc zbtzdense.cc mtutil.cc) > > add_library(simulator SHARED ${SIMULATOR_SOURCES}) > > set_target_properties(simulator PROPERTIES LINK_FLAGS > "-I../sparse-libs/include") > target_link_libraries(simulator ${LIBS} "models/libmodels.a > ../sparse-libs/libsparse.a") You shouldn't add the libraries quoted as a single string here I thing. And if you have build those by your project then simply add their target names: target_link_libraries(simulator ${LIBS} models sparse) > However, target_link_libraries does not include the flags when building the > objects. it only does when building the library. And I do not want to add > (-I../sparse-libs/include) for all my objects. I don't think adding relative paths is a good idea. You should add something like ${CMAKE_CURRENT_SOURCE_DIR}/../sparse-libs/include. The destination directory would otherwise depend on the subdirectory the target is located in. If you do INCLUDE_DIRECTORIES() in one subdir it will not populate upwards, i.e. only this subdirectory and those included with ADD_SUBDIRECTORY() in this CMakeLists.txt after the INCLUDE_DIRECTORIES() call will get this. Eike signature.asc Description: This is a digitally signed message part. ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake