Update/Set _expectedTargets inside exports-release.cmake.

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Update/Set _expectedTargets inside exports-release.cmake.

Rashad M
Hello all,

Is it possible to update or set the "_expectedTargets" cmake variable inside the exports.cmake or exports-release.cmake file

I know this file is autogenerated and it generates all so files and use cmake add_library IMPROTED option etc..

I have an issue with this method.

Lets say, I have 3 so files(libCore, libCommon, libGui)  in Project1

when i have the export() call inside the root cmakelists of project1., I get all three inside my export file.

Here is part from Project1Exports.cmake file.

# Loop over all imported files and verify that they actually exist
foreach(target ${_IMPORT_CHECK_TARGETS} )
  foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
    if(NOT EXISTS "${file}" )
      message(FATAL_ERROR "The imported target \"${target}\" references the file
   \"${file}\"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   \"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
    endif()
  endforeach()
  unset(_IMPORT_CHECK_FILES_FOR_${target})
endforeach()
unset(_IMPORT_CHECK_TARGETS)


Now if I do find_package(project1 REQUIRED COMPONENTS libCore)

which will find the Project1Config.cmake and that include the Project1Exports.cmake

Now if I have only installed one or two component cmake will fail with below message.
"The imported target \"${target}\" references the file
   \"${file}\"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   \"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
"

I am having this when I build packages for debian where I split components into separate packages project1-core, project1-gui etc..

The only option so far is to do an in-place sed and change FATAL_ERROR to STATUS. But I would prefer a cmake solution.

I propose to have:

foreach(target ${_IMPORT_CHECK_TARGETS} )
  foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} )
    if(NOT EXISTS "${file}" )

##add a check to see if the target is listed in the components argument of ##find_package. If there is no components specified, the it must check all targets like now.

      message(FATAL_ERROR "The imported target \"${target}\" references the file
   \"${file}\"
but this file does not exist.  Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
   \"${CMAKE_CURRENT_LIST_FILE}\"
but not all the files it references.
")
    endif()
  endforeach()
  unset(_IMPORT_CHECK_FILES_FOR_${target})
endforeach()
unset(_IMPORT_CHECK_TARGETS)



--
Regards,
   Rashad

--

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
Reply | Threaded
Open this post in threaded view
|

Re: Update/Set _expectedTargets inside exports-release.cmake.

Stephen Kelly-2
Rashad Kanavath wrote:

> I am having this when I build packages for debian where I split components
> into separate packages project1-core, project1-gui etc..

I think you need to patch the buildsystems of the software you are packaging
so that they support that kind of split by exporting to a different export-
set per split component.

ie:

install(TARGETS project1-core EXPORT CoreExports ...)
install(TARGETS project1-gui EXPORT GuiExports ...)
install(TARGETS project1-network EXPORT NetworkExports ...)

and put conditional includes for the resulting files in the
Project1Config.cmake file.

Thanks,

Steve.


--

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
Reply | Threaded
Open this post in threaded view
|

Re: Update/Set _expectedTargets inside exports-release.cmake.

Rashad M
Hello Stephen,

On Tue, Jan 12, 2016 at 8:58 PM, Stephen Kelly <[hidden email]> wrote:
Rashad Kanavath wrote:

> I am having this when I build packages for debian where I split components
> into separate packages project1-core, project1-gui etc..

I think you need to patch the buildsystems of the software you are packaging
so that they support that kind of split by exporting to a different export-
set per split component.

ie:

install(TARGETS project1-core EXPORT CoreExports ...)
install(TARGETS project1-gui EXPORT GuiExports ...)
install(TARGETS project1-network EXPORT NetworkExports ...)

Thanks for your reply. I will check with upstream if this is possible to have such a modification.

If there is some cmake way without modifying upstream I would prefer that.
 

and put conditional includes for the resulting files in the
Project1Config.cmake file.

Thanks,

Steve.


--

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



--
Regards,
   Rashad

--

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