Custom Command OUTPUTs to understand geenrator expressions?

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

Custom Command OUTPUTs to understand geenrator expressions?

Chris Green
Hi,

I have a case where a custom command produces multiple outputs, at least
some of which depend on a property of a library target, viz:

   if (BD_WANT_PCM)
     set(PCM_OUTPUT
       $<TARGET_PROPERTY:${dictname}_dict,LIBRARY_OUTPUT_DIRECTORY>/${CMAKE_SHARED_LIBRARY_PREFIX}${dictname}_dict_rdict.pcm)
     if (GD_PCM_OUTPUT_VAR)
       set(${GD_PCM_OUTPUT_VAR} ${PCM_OUTPUT} PARENT_SCOPE)
     endif()
   endif()
   add_custom_command(
     OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${dictname}_dict.cpp
     # Extra outputs commented out until custom_command OUTPUT supports
     # generator flags.
     ${SOURCE_OUTPUT} # ${GD_ROOTMAP_OUTPUT} ${PCM_OUTPUT}
   ...

Here, ${PCM_OUTPUT} needs to be specified to be put in the same
directory as the library produced for the target ${dictname}_dict, which
may be something particular to that target rather than its defaulted
value of ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} or ${LIBRARY_OUTPUT_PATH}.
Unfortunately, this fails to work as of CMake 3.9.2. Is this something
which is reasonable to want and/or easy to do. Is there some other way
to have the desired flexibility?

Thanks for any help,

Chris.

--

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: Custom Command OUTPUTs to understand geenrator expressions?

Petr Kmoch
Hi Chris,

you're definitely not the first to want this (see https://gitlab.kitware.com/cmake/cmake/issues/12877). However, as per the comment in that issue, it's not something we can expect in any foreseeable future.

Petr

On 1 November 2017 at 17:35, Chris Green <[hidden email]> wrote:
Hi,

I have a case where a custom command produces multiple outputs, at least some of which depend on a property of a library target, viz:

  if (BD_WANT_PCM)
    set(PCM_OUTPUT
      $<TARGET_PROPERTY:${dictname}_dict,LIBRARY_OUTPUT_DIRECTORY>/${CMAKE_SHARED_LIBRARY_PREFIX}${dictname}_dict_rdict.pcm)
    if (GD_PCM_OUTPUT_VAR)
      set(${GD_PCM_OUTPUT_VAR} ${PCM_OUTPUT} PARENT_SCOPE)
    endif()
  endif()
  add_custom_command(
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${dictname}_dict.cpp
    # Extra outputs commented out until custom_command OUTPUT supports
    # generator flags.
    ${SOURCE_OUTPUT} # ${GD_ROOTMAP_OUTPUT} ${PCM_OUTPUT}
  ...

Here, ${PCM_OUTPUT} needs to be specified to be put in the same directory as the library produced for the target ${dictname}_dict, which may be something particular to that target rather than its defaulted value of ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} or ${LIBRARY_OUTPUT_PATH}. Unfortunately, this fails to work as of CMake 3.9.2. Is this something which is reasonable to want and/or easy to do. Is there some other way to have the desired flexibility?

Thanks for any help,

Chris.

--

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


--

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