From 5d47d2b6a9f4193c447f7bb6b8a18ef5b3968e02 Mon Sep 17 00:00:00 2001 From: Konstantin Osipov <kostja.osipov@gmail.com> Date: Thu, 12 May 2011 18:02:02 +0400 Subject: [PATCH] Bug#762091: review comments. Move the cmake check for ObjectiveC compiler to an own file. Tweak the output a bit. --- CMakeLists.txt | 32 +------------------------- cmake/check_objective_c_compiler.cmake | 32 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 cmake/check_objective_c_compiler.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e0063288f5..5ba559d82b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,37 +11,7 @@ find_program(RAGEL ragel) find_program(CONFETTI confetti) -# -# Check if CXX compiler can compile ObjectiveC sources. -# The code was borrowed from CMakeTestCXXCompiler.cmake -# -IF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) - MESSAGE(STATUS "Check for working CXX (ObjectiveC) compiler: ${CMAKE_CXX_COMPILER}") - FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXObjectiveCCompiler.m - "int main(){return 0;}\n") - TRY_COMPILE(CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXObjectiveCCompiler.m - OUTPUT_VARIABLE OUTPUT) - SET(CXX_OBJECTIVEC_TEST_WAS_RUN 1) -ENDIF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) -IF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) - MESSAGE(STATUS "Check for working CXX (ObjectiveC) compiler: ${CMAKE_CXX_COMPILER} -- broken") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the CXX (ObjectiveC) compiler works failed with " - "the following output:\n${OUTPUT}\n\n") - MESSAGE(FATAL_ERROR "The C++ compiler \"${CMAKE_CXX_COMPILER}\" " - "is not able to compile a simple ObjectiveC test program.\nIt fails " - "with the following output:\n ${OUTPUT}\n\n" - "CMake will not be able to correctly generate this project.") -ELSE(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) - IF(CXX_OBJECTIVEC_TEST_WAS_RUN) - MESSAGE(STATUS "Check for working CXX (ObjectiveC) compiler: ${CMAKE_CXX_COMPILER} -- works") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the CXX (ObjectiveC) compiler works passed with " - "the following output:\n${OUTPUT}\n\n") - ENDIF(CXX_OBJECTIVEC_TEST_WAS_RUN) - SET(CMAKE_CXX_OBJETIVEC_COMPILER_WORKS 1 CACHE INTERNAL "") -ENDIF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) +include(cmake/check_objective_c_compiler.cmake) # # This instructs the rest of the build system what product diff --git a/cmake/check_objective_c_compiler.cmake b/cmake/check_objective_c_compiler.cmake new file mode 100644 index 0000000000..7f7eff0860 --- /dev/null +++ b/cmake/check_objective_c_compiler.cmake @@ -0,0 +1,32 @@ +# +# Check if CXX compiler can compile ObjectiveC sources. +# The code was borrowed from CMakeTestCXXCompiler.cmake +# +IF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) + MESSAGE(STATUS "Check for working ObjectiveC compiler: ${CMAKE_CXX_COMPILER}...") + FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXObjectiveCCompiler.m + "int main(){return 0;}\n") + TRY_COMPILE(CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXObjectiveCCompiler.m + OUTPUT_VARIABLE OUTPUT) + SET(CXX_OBJECTIVEC_TEST_WAS_RUN 1) +ENDIF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) +IF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) + MESSAGE(STATUS "Check for working ObjectiveC compiler: ${CMAKE_CXX_COMPILER} -- broken") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the ObjectiveC compiler works failed with " + "the following output:\n${OUTPUT}\n\n") + MESSAGE(FATAL_ERROR "Compiler \"${CMAKE_CXX_COMPILER}\" " + "is not able to compile a simple ObjectiveC test program." + " Please check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log " + "to see how it fails. " + "CMake will not be able to correctly generate this project.") +ELSE(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) + IF(CXX_OBJECTIVEC_TEST_WAS_RUN) + MESSAGE(STATUS "Check for working ObjectiveC compiler: ${CMAKE_CXX_COMPILER} -- works") + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the (ObjectiveC) compiler works passed with " + "the following output:\n${OUTPUT}\n\n") + ENDIF(CXX_OBJECTIVEC_TEST_WAS_RUN) + SET(CMAKE_CXX_OBJETIVEC_COMPILER_WORKS 1 CACHE INTERNAL "") +ENDIF(NOT CMAKE_CXX_OBJECTIVEC_COMPILER_WORKS) -- GitLab