On Wednesday 13 February 2013, Brad King wrote: > On 02/12/2013 05:26 PM, Alexander Neundorf wrote: > >> define a directory property that targets files can populate. It is > >> simply > > > >> a list of target names that must exist by the time the directory is done: > > A first try is now on stage in the ConfigFileTargetChecks4 branch. > > It looks like you rebased an Eclipse change to start the topic. > Please remove that commit. > > > Tests and docs are still missing, error messages are not good yet, etc., > > but it should basically work. > > Please have a look at it, especially at the last commit (c80d330). > > It's a good start. Please add docs/tests. That will be much easier > to review as I can run the test and look at the generated code.
There's another try now in ConfigFileTargetChecks5. The export-file now warns if a target does not exist, but does not error out. Later on in cmComputeLinkDepends cmake checks whether the imported targets actually exist, and errors out if not. This should keep all (accidentially) working projects working, fail at cmake time for all projects which were failing until now at build time, and still warn all projects which have the find_package() order wrong. This is what you get with wrong order: $ make rebuild_cache Running CMake to regenerate build system... ... CMake Warning (dev) at /opt/kf5sb/lib/cmake/kcoreaddons/kcoreaddonsTargets.cmake:97 (message): The following IMPORTED targets are required, but do not exist yet: kdeqt5staging This will cause errors in target_link_libraries() if these IMPORTED targets still do not exist then. Import the targets according to their dependencies to remove this warning. Call Stack (most recent call first): /opt/kf5sb/lib/cmake/kcoreaddons/kcoreaddonsConfig.cmake:37 (include) /opt/extra-cmake-modules/share/ECM-0.0.7/find-modules/FindKF5.cmake:127 (find_package) CMakeLists.txt:13 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. ... -- Configuring done -- Generating done -- Build files have been written to: /home/alex/src/kde- git/KDE/kdelibs/superbuild/b/kconfig $ This is what you get if an imported target is missing: $ make rebuild_cache Running CMake to regenerate build system... ... CMake Warning (dev) at /opt/kf5sb/lib/cmake/kcoreaddons/kcoreaddonsTargets.cmake:97 (message): The following IMPORTED targets are required, but do not exist yet: kdeqt5staging This will cause errors in target_link_libraries() if these IMPORTED targets still do not exist then. Import the targets according to their dependencies to remove this warning. Call Stack (most recent call first): /opt/kf5sb/lib/cmake/kcoreaddons/kcoreaddonsConfig.cmake:37 (include) /opt/extra-cmake-modules/share/ECM-0.0.7/find-modules/FindKF5.cmake:127 (find_package) CMakeLists.txt:13 (find_package) This warning is for project developers. Use -Wno-dev to suppress it. ... -- Configuring done CMake Error at src/core/CMakeLists.txt:15 (add_library): Target "kconfigcore" links to IMPORTED library "kdeqt5staging" , but this library target has not been imported. CMake Error at src/core/CMakeLists.txt:15 (add_library): Target "kconfigcore" links to IMPORTED library "kdeqt5staging" , but this library target has not been imported. ... -- Generating done -- Build files have been written to: /home/alex/src/kde- git/KDE/kdelibs/superbuild/b/kconfig make: *** [rebuild_cache] Error 1 $ Attached is a generated export-file. I'm still working on the tests. I'm not sure I have to add much documentation. Maybe for the internally used variable ? Alex
# Generated by CMake 2.8.10.20130216-g77ecc if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) message(FATAL_ERROR "CMake >= 2.6.0 required") endif() cmake_policy(PUSH) cmake_policy(VERSION 2.6) #---------------------------------------------------------------- # Generated CMake target import file. #---------------------------------------------------------------- # Commands may need to know the format version. set(CMAKE_IMPORT_FILE_VERSION 1) set(_targetsDefined) set(_targetsNotDefined) set(_expectedTargets) foreach(_expectedTarget KF5::kcoreaddons) list(APPEND _expectedTargets ${_expectedTarget}) if(NOT TARGET ${_expectedTarget}) list(APPEND _targetsNotDefined ${_expectedTarget}) endif() if(TARGET ${_expectedTarget}) list(APPEND _targetsDefined ${_expectedTarget}) endif() endforeach() if("${_targetsDefined}" STREQUAL "${_expectedTargets}") set(CMAKE_IMPORT_FILE_VERSION) cmake_policy(POP) return() endif() if(NOT "${_targetsDefined}" STREQUAL "") message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") endif() unset(_targetsDefined) unset(_targetsNotDefined) unset(_expectedTargets) # Compute the installation prefix relative to this file. get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) # Create imported target KF5::kcoreaddons add_library(KF5::kcoreaddons SHARED IMPORTED) # Load information for each installed configuration. get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) file(GLOB CONFIG_FILES "${_DIR}/kcoreaddonsTargets-*.cmake") foreach(f ${CONFIG_FILES}) include(${f}) endforeach() # Cleanup temporary variables. set(_IMPORT_PREFIX) # 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) # Targets in this file do not link against other targets from the # same project which are exported in a separate export set. # Make sure the targets imported from some other project exist. set(CMAKE_CONFIG_REFERENCED_IMPORTED_TARGETS "${CMAKE_CONFIG_REFERENCED_IMPORTED_TARGETS};Qt5::Concurrent;Qt5::Core;kdeqt5staging;" ) # Print a warning for each target which is used but does not exist yet. unset(_cmake_missing_targets) foreach(_target Qt5::Concurrent;Qt5::Core;kdeqt5staging;) if(NOT TARGET ${_target}) list(APPEND _cmake_missing_targets ${_target}) endif() endforeach() if(_cmake_missing_targets) if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.8) set(_cmake_msg_type STATUS) else() set(_cmake_msg_type AUTHOR_WARNING) endif() message(${_cmake_msg_type} "The following IMPORTED targets are required, but do not exist yet: ${_cmake_missing_targets} This will cause errors in target_link_libraries() if these IMPORTED targets still do not exist then. Import the targets according to their dependencies to remove this warning.") unset(_cmake_missing_targets) endif() # Commands beyond this point should not need to know the version. set(CMAKE_IMPORT_FILE_VERSION) cmake_policy(POP)
-- 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://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers