[CMake] Update/Set _expectedTargets inside exports-release.cmake.
Rashad Kanavath
mohammedrashadkm at gmail.com
Tue Jan 12 05:21:06 EST 2016
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160112/c8def7da/attachment.html>
More information about the CMake
mailing list