[cmake-commits] alex committed CMakeLists.txt 1.77 1.78

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Aug 27 15:15:28 EDT 2007


Update of /cvsroot/CMake/CMake/Tests/SimpleInstall
In directory public:/mounts/ram/cvs-serv29227

Modified Files:
	CMakeLists.txt 
Log Message:

COMP: add a test for exporting and importing targets

Alex


Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/SimpleInstall/CMakeLists.txt,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- CMakeLists.txt	27 Aug 2007 18:44:32 -0000	1.77
+++ CMakeLists.txt	27 Aug 2007 19:15:26 -0000	1.78
@@ -134,6 +134,15 @@
     INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
 
   INSTALL_TARGETS(/MyTest/bin SimpleInstallS2)
+
+# try to import the exported targets again
+  SET(SimpleInstallS1_DIR ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
+  FIND_PACKAGE(SimpleInstallS1 REQUIRED)
+  GET_TARGET_PROPERTY(simpleInstallLocation S1_SimpleInstall LOCATION)
+  IF(NOT simpleInstallLocation)
+    MESSAGE(FATAL_ERROR "Target S1_SimpleInstall could not be imported, location: ${simpleInstallLocation}")
+  ENDIF(NOT simpleInstallLocation)
+
 ELSE(STAGE2)
   # Wipe out the install directory to do a fresh test.
   FILE(REMOVE_RECURSE ${CMAKE_INSTALL_PREFIX}/MyTest)
@@ -164,11 +173,12 @@
   ADD_DEPENDENCIES(test2 test3)
   ADD_DEPENDENCIES(test4 test2)
 
-  INSTALL(TARGETS SimpleInstall test1 test2 test3
+  INSTALL(TARGETS SimpleInstall test1 test2 test3 EXPORT SimpleInstallS1
     RUNTIME DESTINATION MyTest/bin        COMPONENT Runtime     # .exe, .dll
     LIBRARY DESTINATION MyTest/lib        COMPONENT Runtime     # .so, mod.dll
     ARCHIVE DESTINATION MyTest/lib/static COMPONENT Development # .a, .lib
     )
+
   INSTALL(TARGETS test4 PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE
     RUNTIME DESTINATION MyTest/bin
     LIBRARY DESTINATION MyTest/lib
@@ -191,6 +201,12 @@
     scripts/sample_script scripts/sample_script.bat)
   INSTALL_PROGRAMS(/MyTest/share/old2
     scripts/sample_script scripts/sample_script.bat)
+
+# "export" the targets collected in "SimpleInstallS1"
+  INSTALL(EXPORT SimpleInstallS1 FILENAME SimpleInstallS1Config.cmake 
+                                 DESTINATION MyTest/lib 
+                                 PREFIX S1_ )
+
   ADD_SUBDIRECTORY(scripts)
 
   # Test optional installation.



More information about the Cmake-commits mailing list