CMake: Reference test targets only when BUILD_TESTING is ON

You cannot set a property on a target that's not there, and
these targets are not there when BUILD_TESTING is OFF.

Thanks to Sankhesh Jhaveri for the bug report.
This commit is contained in:
David Cole 2011-09-14 10:38:04 -04:00
parent 2a3441b65f
commit c336778c52
1 changed files with 10 additions and 6 deletions

View File

@ -231,11 +231,13 @@ MACRO (CMAKE_BUILD_UTILITIES)
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}_c "${kwsys_folder}")
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}EncodeExecutable "${kwsys_folder}")
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}ProcessFwd9x "${kwsys_folder}")
if(BUILD_TESTING)
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestDynload "${kwsys_folder}")
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestProcess "${kwsys_folder}")
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsC "${kwsys_folder}")
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestsCxx "${kwsys_folder}")
CMAKE_SET_TARGET_FOLDER(${KWSYS_NAMESPACE}TestSharedForward "${kwsys_folder}")
endif()
#---------------------------------------------------------------------
# Setup third-party libraries.
@ -598,7 +600,9 @@ ADD_SUBDIRECTORY(Source)
ADD_SUBDIRECTORY(Utilities)
ADD_SUBDIRECTORY(Tests)
CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
if(BUILD_TESTING)
CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
endif()
CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat")
CMAKE_SET_TARGET_FOLDER(documentation "Documentation")