Re: [CMake] RPM packaging dependencies expressed in subdirectories
Thank you again Nils for the guidelines, now its time to experiment :). Thibault On Wed, Jul 16, 2014 at 5:40 PM, Nils Gladitz wrote: > On 16.07.2014 16:37, Thibault Hild wrote: > >> Thanks Nils for the hint. >> >> I guess you had to use Cmake constructs like: >> if("new dep" MATCHES "a regex built with ${pack_deps}") >> in order to decide whether a new dependency is allowed. >> >> As I am quite new to CMake functions, can you detail a bit how do you >> operate such validation ? >> > > I got the current list of dependencies with get_property(). > Then I looped over the list with foreach(). > Every list item I split into name and version (with regex) and then > compared it to the new dependency. > I used message(FATAL_ERROR) to issue a (fatal) diagnostic if a different > version of a dependency has already been requested. > > > Is there some sort of function repository to share these custom CMake >> function tools ? >> > > I am not aware of any except for cmake's own module repository[1] ... > which might not be the right place for this though. > Perhaps the Wiki. > > Nils > > [1] http://www.cmake.org/cmake/help/v3.0/manual/cmake-modules.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
Re: [CMake] RPM packaging dependencies expressed in subdirectories
On 16.07.2014 16:37, Thibault Hild wrote: Thanks Nils for the hint. I guess you had to use Cmake constructs like: if("new dep" MATCHES "a regex built with ${pack_deps}") in order to decide whether a new dependency is allowed. As I am quite new to CMake functions, can you detail a bit how do you operate such validation ? I got the current list of dependencies with get_property(). Then I looped over the list with foreach(). Every list item I split into name and version (with regex) and then compared it to the new dependency. I used message(FATAL_ERROR) to issue a (fatal) diagnostic if a different version of a dependency has already been requested. Is there some sort of function repository to share these custom CMake function tools ? I am not aware of any except for cmake's own module repository[1] ... which might not be the right place for this though. Perhaps the Wiki. Nils [1] http://www.cmake.org/cmake/help/v3.0/manual/cmake-modules.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
Re: [CMake] RPM packaging dependencies expressed in subdirectories
Thanks Nils for the hint. I guess you had to use Cmake constructs like: if("new dep" MATCHES "a regex built with ${pack_deps}") in order to decide whether a new dependency is allowed. As I am quite new to CMake functions, can you detail a bit how do you operate such validation ? Is there some sort of function repository to share these custom CMake function tools ? Thibault On Wed, Jul 16, 2014 at 3:39 PM, Nils Gladitz wrote: > On 16.07.2014 15:08, Thibault Hild wrote: > >> Hello, >> >> I'm quite new to CMake and after experimenting a bit, I am currently >> considering a way to express RPM dependencies in subdirectories instead of >> specifying them at the top level. >> After googling a bit, I did not find something that fulfills my >> expectations but I have probably missed a post or something in the CPack >> documentation. If you already know of a discussion thread or explanation on >> this particular subject, can you please redirect me to it ? >> >> > For DEB I used custom function()s to maintain a custom GLOBAL property > (set_property(), get_property()). > > The custom function I used to append dependencies to the property would > check if the dependency already exists. > If it existed with the same version requirement it would be ignored; if > the version differed I threw an error. > > Somewhere at the end of my root CMakeLists.txt (but before include(CPack)) > I added a call to my second custom function which would set the appropriate > CPACK_ variable (with PARENT_SCOPE) based on the content of the GLOBAL > property. > > Nils > -- 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
Re: [CMake] RPM packaging dependencies expressed in subdirectories
On 16.07.2014 15:08, Thibault Hild wrote: Hello, I'm quite new to CMake and after experimenting a bit, I am currently considering a way to express RPM dependencies in subdirectories instead of specifying them at the top level. After googling a bit, I did not find something that fulfills my expectations but I have probably missed a post or something in the CPack documentation. If you already know of a discussion thread or explanation on this particular subject, can you please redirect me to it ? For DEB I used custom function()s to maintain a custom GLOBAL property (set_property(), get_property()). The custom function I used to append dependencies to the property would check if the dependency already exists. If it existed with the same version requirement it would be ignored; if the version differed I threw an error. Somewhere at the end of my root CMakeLists.txt (but before include(CPack)) I added a call to my second custom function which would set the appropriate CPACK_ variable (with PARENT_SCOPE) based on the content of the GLOBAL property. Nils -- 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
[CMake] RPM packaging dependencies expressed in subdirectories
Hello, I'm quite new to CMake and after experimenting a bit, I am currently considering a way to express RPM dependencies in subdirectories instead of specifying them at the top level. After googling a bit, I did not find something that fulfills my expectations but I have probably missed a post or something in the CPack documentation. If you already know of a discussion thread or explanation on this particular subject, can you please redirect me to it ? To clarify, I currently have the following source hierarchy: [build@build src]$ ls -R .: CMakeLists.txt hello world ./hello: CMakeLists.txt hello.cpp ./world: CMakeLists.txt world.cpp world.h The top level CMakeLists.txt contains: [build@build src]$ cat ./CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(cmake_testbed) set(CMAKE_INSTALL_PREFIX "/some/where") # use, i.e. don't skip the full RPATH for the build tree set(CMAKE_SKIP_BUILD_RPATH false) # when building, don't use the install RPATH already # (but later on when installing) set(CMAKE_BUILD_WITH_INSTALL_RPATH false) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") # add the automatically determined parts of the RPATH # which point to directories outside the build tree to the install RPATH set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true) # the RPATH to be used when installing, but only if it's not a system # directory list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) if("${isSystemDir}" STREQUAL "-1") set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") endif("${isSystemDir}" STREQUAL "-1") add_subdirectory(world) add_subdirectory(hello) set(CPACK_PACKAGING_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") set(CPACK_GENERATOR "RPM") set(CPACK_RPM_PACKAGE_REQUIRES "ruby >= 1.8") include(CPack) As you can see, I am currently expressing a RPM dependency on ruby in the top level CMakeLists.txt but in fact this dependency comes from the hello subdirectory because hello.cpp states this: [build@build src]$ cat hello/hello.cpp #include "world.h" #include #include using namespace std; int main(int argc, char* argv[]) { cout << "hello " << world() << endl; system("/usr/bin/ruby --version"); return 0; } hello/CmakeLists.txt current content is: [build@build src]$ cat hello/CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(hello) include_directories(${world_SOURCE_DIR}) add_executable(hello hello.cpp) target_link_libraries(hello world) install(TARGETS hello DESTINATION bin) Is there a way to express this RPM dependency in "hello/CMakeLists.txt" instead of "./CMakeLists.txt" ? The common use case for this is the integration of multiple components which would all comes with there own dependencies without requiring the integrator to dig in each subdirectory in order to find its induced dependencies (which are well known by the component's author). I understand that this also raises the problem of multiple dependencies over the same component (let say "hello" needs "ruby >=2.8" and "world" needs "ruby >= 3.0"). I do not currently know how rpmbuild would behave if he find two requirements on the same dependency (I would expect it to take the stronger requirement i.e. "ruby >= 3.0" which is nonetheless not always the right solution in case of a backward compatibility breakage). Is anyone having the same kind of need over expressing packaging dependencies (RPM or other)? If so, did you find a way to express them in the CMakeLists.txt of the subdirectories? Thanks for reading me until the end, regards, Thibault Hild -- 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