Re: [CMake] Setting IMPORTED_LOCATION_* for existing packages
On 09/21/2011 09:07 AM, Hauke Heibel wrote: Hi, I started to work with imported targets and thus with setting the property IMPORTED_LOCATION and the like. I stumbled over a case (GTest) where the standard find_package call returns me a list of libs for 'debug' and 'optimized' modes and I am setting them like this find_package(GTest REQUIRED) add_library(GTest UNKNOWN IMPORTED) foreach(arg ${GTEST_LIBRARIES}) if(${arg} MATCHES ^(debug|optimized)$) set(_doing ${arg}) elseif(${_doing} MATCHES ^debug$) message(setting debug lib to: ${arg}) set_target_properties(GTest PROPERTIES IMPORTED_LOCATION_DEBUG ${arg}) else() message(setting optimized lib to: ${arg}) set_target_properties(GTest PROPERTIES IMPORTED_LOCATION ${arg}) endif() endforeach() AFAICS, you've a single imported target GTest, and you are continuously setting *this* target's location - sometimes for a debug configuration, sometimes without configuration - to the location of its *prerequisite* libraries reported by the GTest package's find module or config file. IMO, this doesn't make any sense. Possibly, you want to set the GTest target's IMPORTED_LINK_INTERFACE_LIBRARIES[_CONFIG] properties in place of the IMPORTED_LOCATION[_CONFIG] ones. Moreover, note that TARGET_LINK_LIBRARIES()'s debug/optimized/general switches apply to the immediately following library only, so you probably need to re- set the _doing variable in the ELSEIF() and ELSE() branches in order to obtain the expected result. I am just wondering whether there is a more simple method to do this. It looks a bit cumbersome. What do you actually intent to achieve? Introduce a GTest imported target and set up its prerequisites reported in GTEST_LIBRARIES as it would be done for imported targets from the first? Doesn't the GTEST_LIBRARIES variable per se work for you? Regards, Hauke 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] Setting IMPORTED_LOCATION_* for existing packages
Hi Michael, First, thank you for the feedback. On Thu, Sep 22, 2011 at 7:19 PM, Michael Hertling mhertl...@online.de wrote: AFAICS, you've a single imported target GTest, and you are continuously setting *this* target's location - sometimes for a debug configuration, sometimes without configuration - to the location of its *prerequisite* libraries reported by the GTest package's find module or config file. If I am not totally wrong, in this case I am only setting the GTest libraries and no additional *prerequisite*. The variable GTEST_LIBRARIES only contains full qualified paths to gtest.lib and gtestd.lib. IMO, this doesn't make any sense. Possibly, you want to set the GTest target's IMPORTED_LINK_INTERFACE_LIBRARIES[_CONFIG] properties in place of the IMPORTED_LOCATION[_CONFIG] ones. Maybe I am wrong, but I just tried to copy what is done in the FindQt4.cmake file or in other words to manually define what the export() directive generates. I recognized an issue since I forgot to define the property IMPORTED_CONFIGURATIONS. If I did not misunderstand things completely, you were right if GTEST_LIBRARIES would contain non GTest libs (the prerequisites). What do you actually intent to achieve? Introduce a GTest imported target and set up its prerequisites reported in GTEST_LIBRARIES as it would be done for imported targets from the first? I think that's pretty much what I want to do. Create the import target as if GTest were compiled with an export() directive. Doesn't the GTEST_LIBRARIES variable per se work for you? To be honest, in this case it does. Maybe the example was bad. I think I really need it for shared library targets, such as e.g. OpenCL. I want to prepare my libraries such that in the future a CMake based installation also collects and installs DLLs of interface libraries. I am further assuming that if I define a target of mine and link it against an imported (let's say) OpenCL target with properly specified IMPORTED_LOCATION (the DLL for shared libs), install() will copy it for me. Maybe that's long shot - I need to read more about the actual installation process and how it deals with dependencies. Regards, Hauke -- 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] Setting IMPORTED_LOCATION_* for existing packages
On 09/22/2011 09:21 PM, Hauke Heibel wrote: Hi Michael, First, thank you for the feedback. On Thu, Sep 22, 2011 at 7:19 PM, Michael Hertling mhertl...@online.de wrote: AFAICS, you've a single imported target GTest, and you are continuously setting *this* target's location - sometimes for a debug configuration, sometimes without configuration - to the location of its *prerequisite* libraries reported by the GTest package's find module or config file. If I am not totally wrong, in this case I am only setting the GTest libraries and no additional *prerequisite*. The variable GTEST_LIBRARIES only contains full qualified paths to gtest.lib and gtestd.lib. IMO, this doesn't make any sense. Possibly, you want to set the GTest target's IMPORTED_LINK_INTERFACE_LIBRARIES[_CONFIG] properties in place of the IMPORTED_LOCATION[_CONFIG] ones. Maybe I am wrong, but I just tried to copy what is done in the FindQt4.cmake file or in other words to manually define what the export() directive generates. I recognized an issue since I forgot to define the property IMPORTED_CONFIGURATIONS. If I did not misunderstand things completely, you were right if GTEST_LIBRARIES would contain non GTest libs (the prerequisites). What do you actually intent to achieve? Introduce a GTest imported target and set up its prerequisites reported in GTEST_LIBRARIES as it would be done for imported targets from the first? I think that's pretty much what I want to do. Create the import target as if GTest were compiled with an export() directive. Doesn't the GTEST_LIBRARIES variable per se work for you? To be honest, in this case it does. Maybe the example was bad. I think I really need it for shared library targets, such as e.g. OpenCL. I want to prepare my libraries such that in the future a CMake based installation also collects and installs DLLs of interface libraries. I am further assuming that if I define a target of mine and link it against an imported (let's say) OpenCL target with properly specified IMPORTED_LOCATION (the DLL for shared libs), install() will copy it for me. No, it won't: CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(IMPORTTARGET C) SET(CMAKE_VERBOSE_MAKEFILE ON) FILE(WRITE ${CMAKE_BINARY_DIR}/main.c int main(void){return 0;}\n) ADD_EXECUTABLE(main main.c) FIND_LIBRARY(M_LIBRARY m PATHS /usr/lib NO_DEFAULT_PATH) ADD_LIBRARY(m SHARED IMPORTED) SET_TARGET_PROPERTIES(m PROPERTIES IMPORTED_LOCATION ${M_LIBRARY}) TARGET_LINK_LIBRARIES(main m) INSTALL(TARGETS main RUNTIME DESTINATION bin) As you'll see after cmake -DCMAKE_INSTALL_PREFIX=/dev/shm/usr ..., e.g., a make install will install the main executable but not the prerequisite libm.so library. Imported targets are meant to inform the project about targets already built - and possibly installed - by other projects; they don't suit to resolve a project's external dependencies during the installation. If you need this, you should definitely have a look at the BundleUtilities. Maybe that's long shot - I need to read more about the actual installation process and how it deals with dependencies. Regards, Hauke 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
[CMake] Setting IMPORTED_LOCATION_* for existing packages
Hi, I started to work with imported targets and thus with setting the property IMPORTED_LOCATION and the like. I stumbled over a case (GTest) where the standard find_package call returns me a list of libs for 'debug' and 'optimized' modes and I am setting them like this find_package(GTest REQUIRED) add_library(GTest UNKNOWN IMPORTED) foreach(arg ${GTEST_LIBRARIES}) if(${arg} MATCHES ^(debug|optimized)$) set(_doing ${arg}) elseif(${_doing} MATCHES ^debug$) message(setting debug lib to: ${arg}) set_target_properties(GTest PROPERTIES IMPORTED_LOCATION_DEBUG ${arg}) else() message(setting optimized lib to: ${arg}) set_target_properties(GTest PROPERTIES IMPORTED_LOCATION ${arg}) endif() endforeach() I am just wondering whether there is a more simple method to do this. It looks a bit cumbersome. Regards, Hauke ___ 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