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 via email to