STYLE: Nightly Version update
[cmake.git] / Tests / ExternalOBJ / CMakeLists.txt
blob7607f69059ed3d031c41c89d4ee5d52a323dc90d
1 PROJECT (ExternalOBJ)
3 # Build the external object file.
4 TRY_COMPILE(EXTERNAL_OBJECT_BUILT
5   ${ExternalOBJ_BINARY_DIR}/Object
6   ${ExternalOBJ_SOURCE_DIR}/Object
7   Object
8   external
9   OUTPUT_VARIABLE OUTPUT
10   )
11 SET(EXTERNAL_OBJECT_NAME "external_object${CMAKE_CXX_OUTPUT_EXTENSION}")
12 IF(EXTERNAL_OBJECT_BUILT)
13   MESSAGE(
14     "Building ${EXTERNAL_OBJECT_NAME} succeeded with the following output:\n"
15     "[${OUTPUT}]"
16     )
17 ELSE(EXTERNAL_OBJECT_BUILT)
18   MESSAGE(FATAL_ERROR
19     "Building ${EXTERNAL_OBJECT_NAME} failed with the following output:\n"
20     "[${OUTPUT}]"
21     )
22 ENDIF(EXTERNAL_OBJECT_BUILT)
24 # Find the external object file.
25 SET(BASE ${ExternalOBJ_BINARY_DIR}/Object)
26 SET(EXTERNAL_OBJECT)
27 FOREACH(dir external.dir . ${CMAKE_CONFIGURATION_TYPES})
28   IF(NOT EXTERNAL_OBJECT)
29     IF(EXISTS ${BASE}/${dir}/${EXTERNAL_OBJECT_NAME})
30       SET(EXTERNAL_OBJECT ${BASE}/${dir}/${EXTERNAL_OBJECT_NAME})
31     ENDIF(EXISTS ${BASE}/${dir}/${EXTERNAL_OBJECT_NAME})
32   ENDIF(NOT EXTERNAL_OBJECT)
33 ENDFOREACH(dir)
34 IF(NOT EXTERNAL_OBJECT)
35   FILE(GLOB_RECURSE EXTERNAL_OBJECT
36     "${ExternalOBJ_BINARY_DIR}/Object/${EXTERNAL_OBJECT_NAME}")
37 ENDIF(NOT EXTERNAL_OBJECT)
38 IF(EXTERNAL_OBJECT)
39   MESSAGE("Found \"${EXTERNAL_OBJECT}\".")
40 ELSE(EXTERNAL_OBJECT)
41   MESSAGE(FATAL_ERROR "Could not find ${EXTERNAL_OBJECT_NAME}.")
42 ENDIF(EXTERNAL_OBJECT)
44 # Build an executable using the external object file.
45 ADD_EXECUTABLE(executable executable.cxx ${EXTERNAL_OBJECT})