CMake:ExportInterface: Difference between revisions

From KitwarePublic
Jump to navigationJump to search
(New page: =Export Interface for CMake Projects= This page documents a prototype design Alex and Brad created for exporting project information from a CMake project for use by outside projects. Her...)
 
(Replace content with link to new CMake community wiki)
 
(14 intermediate revisions by 8 users not shown)
Line 1: Line 1:
=Export Interface for CMake Projects=
{{CMake/Template/Moved}}


This page documents a prototype design Alex and Brad created for exporting project information from a CMake project for use by outside projects.
This page has moved [https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/ExportInterface here].
 
Here is an example for exporing a simple project from the build tree and install tree:
 
<pre>
EXPORT( # anonymous export must be fully specified here
  FILE myproj-build.cmake
  PREFIX myproj-1.2
  TARGETS mylibA mylibB mygen
  )
INSTALL(
  TARGETS mylibA mylibB mygen
  EXPORT  myproj-install
  RUNTIME DESTINATION bin
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  )
INSTALL(
  EXPORT myproj-install
  DESTINATION lib/myproj-1.2
  FILE myproj-install.cmake
  PREFIX myproj-1.2
  )
</pre>
 
A more complicated project may be organized this way:
 
<pre>
# CMakeLists.txt
EXPORT(myproj-build # named export allows more rules later
  FILE myproj-build.cmake
  PREFIX myproj-1.2
  )
INSTALL(
  EXPORT myproj-install
  DESTINATION lib/myproj-1.2
  FILE myproj-install.cmake
  PREFIX myproj-1.2
  )
 
# lib/CMakeLists.txt
EXPORT(myproj-build
  TARGETS mylibA mylibB
  )
INSTALL(TARGETS mylibA mylibB
  EXPORT myproj-install
  RUNTIME DESTINATION bin
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  )
 
# exe/CMakeLists.txt
EXPORT(myproj-build
  TARGETS mygen
  )
INSTALL(TARGETS mygen
  EXPORT myproj-install
  DESTINATION bin
  )
</pre>

Latest revision as of 15:40, 30 April 2018


The CMake community Wiki has moved to the Kitware GitLab Instance.

This page has moved here.