[CMake] Conditional install() rules based on CPack generator

Mathieu Malaterre mathieu.malaterre at gmail.com
Wed Jun 5 06:00:19 EDT 2019


Hi there,

I am trying to use NuGet generator for GDCM project. Typically my
install rules are as follow:

add_library(foo SHARED foo.c)
install(TARGETS foo
  EXPORT ${MY_TARGETS_NAME}
  RUNTIME DESTINATION ${MY_INSTALL_BIN_DIR} COMPONENT Applications
  LIBRARY DESTINATION ${MY_INSTALL_LIB_DIR} COMPONENT Libraries
  INCLUDES DESTINATION ${MY_INSTALL_INCLUDE_DIR}
  ARCHIVE DESTINATION ${MY_INSTALL_LIB_DIR} COMPONENT DebugDevel
)

where:

MY_INSTALL_BIN_DIR='bin'
MY_INSTALL_LIB_DIR='lib'
MY_INSTALL_INCLUDE_DIR='include'

this works quite nicely for basic 'make install', as well as binary
zip or NSIS installer.
However this directory layout does not seems to be compatible with
Windows RIDs[*]. For example my native *.dll files would need to be
moved from the 'bin' directory to something like 'lib/win7-x64'.

How can I handle conditional install() rules based on CPack generator
(NuGet in my case) ?

Thanks,

[*] https://docs.microsoft.com/en-us/dotnet/core/rid-catalog

-- 
Mathieu


More information about the CMake mailing list