[Cmake-commits] [cmake-commits] king committed CMakeLists.txt 1.63 1.64

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Aug 20 11:45:18 EDT 2008


Update of /cvsroot/CMake/CMake/Tests/Complex/Executable
In directory public:/mounts/ram/cvs-serv27448/Tests/Complex/Executable

Modified Files:
	CMakeLists.txt 
Log Message:
ENH: Add if(TARGET) command

It is useful to be able to test if a target has been created.  Often
targets are created only inside conditions.  Rather than storing the
result of the condition manually for testing by other parts of the
project, it is much easier for the other parts to just test for the
target's existence.  This will also be useful when find-modules start
reporting results with IMPORTED targets and projects want to test if a
certain target is available.


Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Tests/Complex/Executable/CMakeLists.txt,v
retrieving revision 1.63
retrieving revision 1.64
diff -C 2 -d -r1.63 -r1.64
*** CMakeLists.txt	7 Feb 2008 13:55:56 -0000	1.63
--- CMakeLists.txt	20 Aug 2008 15:45:16 -0000	1.64
***************
*** 17,20 ****
--- 17,37 ----
  ENDIF(COMPLEX_TEST_CMAKELIB)
  
+ # Create an imported target for if(TARGET) test below.
+ ADD_LIBRARY(ExeImportedTarget UNKNOWN IMPORTED)
+ 
+ # Test if(TARGET) command.
+ IF(NOT TARGET CMakeTestLibrary)
+   MESSAGE(FATAL_ERROR "IF(NOT TARGET CMakeTestLibrary) returned true!")
+ ENDIF(NOT TARGET CMakeTestLibrary)
+ IF(NOT TARGET ExeImportedTarget)
+   MESSAGE(FATAL_ERROR "IF(NOT TARGET ExeImportedTarget) returned true!")
+ ENDIF(NOT TARGET ExeImportedTarget)
+ IF(TARGET LibImportedTarget)
+   MESSAGE(FATAL_ERROR "IF(TARGET LibImportedTarget) returned true!")
+ ENDIF(TARGET LibImportedTarget)
+ IF(TARGET NotATarget)
+   MESSAGE(FATAL_ERROR "IF(TARGET NotATarget) returned true!")
+ ENDIF(TARGET NotATarget)
+ 
    # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to 
  SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)



More information about the Cmake-commits mailing list