diff options
author | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:34:34 +0900 |
---|---|---|
committer | Sehong Na <sehong.na@samsung.com> | 2014-05-31 12:34:34 +0900 |
commit | cc1a12d36421addf6726f86a5b24f913024d8b3a (patch) | |
tree | 253958b9b8d3ffe9120c78cf3bd5389b8e4a0ea0 /Tests/ExternalOBJ | |
download | cmake-tizen_2.3.tar.gz cmake-tizen_2.3.tar.bz2 cmake-tizen_2.3.zip |
Initialize Tizen 2.3tizen_2.3_releasesubmit/tizen_2.3/20150202.102300submit/tizen_2.3/20140531.0637312.3a_releasetizen_2.3
Diffstat (limited to 'Tests/ExternalOBJ')
-rw-r--r-- | Tests/ExternalOBJ/CMakeLists.txt | 61 | ||||
-rw-r--r-- | Tests/ExternalOBJ/Object/CMakeLists.txt | 13 | ||||
-rw-r--r-- | Tests/ExternalOBJ/Object/external_main.cxx | 4 | ||||
-rw-r--r-- | Tests/ExternalOBJ/Object/external_object.cxx | 4 | ||||
-rw-r--r-- | Tests/ExternalOBJ/executable.cxx | 5 |
5 files changed, 87 insertions, 0 deletions
diff --git a/Tests/ExternalOBJ/CMakeLists.txt b/Tests/ExternalOBJ/CMakeLists.txt new file mode 100644 index 0000000..f12de11 --- /dev/null +++ b/Tests/ExternalOBJ/CMakeLists.txt @@ -0,0 +1,61 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT (ExternalOBJ) + +IF(APPLE) + # set _CMAKE_OSX_MACHINE to umame -m + EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE _CMAKE_OSX_MACHINE) + # check for Power PC and change to ppc + IF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") + SET(_CMAKE_OSX_MACHINE ppc) + ENDIF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") + SET(CMAKE_OSX_ARCHITECTURES ${_CMAKE_OSX_MACHINE}) +ENDIF(APPLE) + +# Build the external object file. +TRY_COMPILE(EXTERNAL_OBJECT_BUILT + ${ExternalOBJ_BINARY_DIR}/Object + ${ExternalOBJ_SOURCE_DIR}/Object + Object + external + OUTPUT_VARIABLE OUTPUT + ) +IF(EXTERNAL_OBJECT_BUILT) + MESSAGE( + "Building external_object.cxx succeeded with the following output:\n" + "[${OUTPUT}]" + ) +ELSE(EXTERNAL_OBJECT_BUILT) + MESSAGE(FATAL_ERROR + "Building external_object.cxx failed with the following output:\n" + "[${OUTPUT}]" + ) +ENDIF(EXTERNAL_OBJECT_BUILT) + +# Find the external object file. +SET(DIR ${ExternalOBJ_BINARY_DIR}/Object) +FILE(GLOB_RECURSE EXTERNAL_OBJECT + "${DIR}/external_object*${CMAKE_CXX_OUTPUT_EXTENSION}") +IF(EXTERNAL_OBJECT) + LIST (GET EXTERNAL_OBJECT 0 EXTERNAL_OBJECT) + MESSAGE("Found \"${EXTERNAL_OBJECT}\".") +ELSE(EXTERNAL_OBJECT) + MESSAGE(FATAL_ERROR "Could not find external object.") +ENDIF(EXTERNAL_OBJECT) + +# Test creation of external objects by custom commands. +SET(CUSTOM_OBJECT + ${CMAKE_CURRENT_BINARY_DIR}/custom_object${CMAKE_C_OUTPUT_EXTENSION}) +ADD_CUSTOM_COMMAND( + OUTPUT ${CUSTOM_OBJECT} + COMMAND ${CMAKE_COMMAND} -E copy ${EXTERNAL_OBJECT} ${CUSTOM_OBJECT} + DEPENDS ${EXTERNAL_OBJECT} + ) + +message("${EXTERNAL_OBJECT}") +# Build an executable using the external object file. +ADD_EXECUTABLE(ExternalOBJ executable.cxx ${CUSTOM_OBJECT}) +# A bug showed up in VS2010 where an object file that was +# part of a custom commad output worked, but ones that were +# not didn't work. So, repeat the executable using the object +# directly and not from the output of the copy. +ADD_EXECUTABLE(ExternalOBJ2 executable.cxx ${EXTERNAL_OBJECT}) diff --git a/Tests/ExternalOBJ/Object/CMakeLists.txt b/Tests/ExternalOBJ/Object/CMakeLists.txt new file mode 100644 index 0000000..6f1d7e3 --- /dev/null +++ b/Tests/ExternalOBJ/Object/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required (VERSION 2.6) +PROJECT(Object) +IF(APPLE) + # set _CMAKE_OSX_MACHINE to umame -m + EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE _CMAKE_OSX_MACHINE) + # check for Power PC and change to ppc + IF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") + SET(_CMAKE_OSX_MACHINE ppc) + ENDIF("${_CMAKE_OSX_MACHINE}" MATCHES "Power") + SET(CMAKE_OSX_ARCHITECTURES ${_CMAKE_OSX_MACHINE}) +ENDIF(APPLE) + +ADD_EXECUTABLE(external external_object.cxx external_main.cxx) diff --git a/Tests/ExternalOBJ/Object/external_main.cxx b/Tests/ExternalOBJ/Object/external_main.cxx new file mode 100644 index 0000000..f8b643a --- /dev/null +++ b/Tests/ExternalOBJ/Object/external_main.cxx @@ -0,0 +1,4 @@ +int main() +{ + return 0; +} diff --git a/Tests/ExternalOBJ/Object/external_object.cxx b/Tests/ExternalOBJ/Object/external_object.cxx new file mode 100644 index 0000000..5b4adaf --- /dev/null +++ b/Tests/ExternalOBJ/Object/external_object.cxx @@ -0,0 +1,4 @@ +int external_object_function() +{ + return 0; +} diff --git a/Tests/ExternalOBJ/executable.cxx b/Tests/ExternalOBJ/executable.cxx new file mode 100644 index 0000000..f9ec61d --- /dev/null +++ b/Tests/ExternalOBJ/executable.cxx @@ -0,0 +1,5 @@ +extern int external_object_function(); +int main() +{ + return external_object_function(); +} |