3 # Build the external object file.
4 TRY_COMPILE(EXTERNAL_OBJECT_BUILT
5 ${ExternalOBJ_BINARY_DIR}/Object
6 ${ExternalOBJ_SOURCE_DIR}/Object
11 SET(EXTERNAL_OBJECT_NAME "external_object${CMAKE_CXX_OUTPUT_EXTENSION}")
12 IF(EXTERNAL_OBJECT_BUILT)
14 "Building ${EXTERNAL_OBJECT_NAME} succeeded with the following output:\n"
17 ELSE(EXTERNAL_OBJECT_BUILT)
19 "Building ${EXTERNAL_OBJECT_NAME} failed with the following output:\n"
22 ENDIF(EXTERNAL_OBJECT_BUILT)
24 # Find the external object file.
25 SET(BASE ${ExternalOBJ_BINARY_DIR}/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)
34 IF(NOT EXTERNAL_OBJECT)
35 FILE(GLOB_RECURSE EXTERNAL_OBJECT
36 "${ExternalOBJ_BINARY_DIR}/Object/${EXTERNAL_OBJECT_NAME}")
37 ENDIF(NOT EXTERNAL_OBJECT)
39 MESSAGE("Found \"${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})