From 0ee96494469eb3409a15d7ec4ff9d84f44eb48ba Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 7 Oct 2015 17:42:12 +0200 Subject: [PATCH] Fixed ObjectiveC cmake language to use the C compiler by default --- .../CMakeDetermineObjectiveCCompiler.cmake | 44 +------------------ .../Modules/CMakeTestObjectiveCCompiler.cmake | 2 + .cmake/Modules/Languages.cmake | 24 +++++----- CMakeLists.txt | 1 - 4 files changed, 17 insertions(+), 54 deletions(-) diff --git a/.cmake/Modules/CMakeDetermineObjectiveCCompiler.cmake b/.cmake/Modules/CMakeDetermineObjectiveCCompiler.cmake index 613cd38..a7a42d1 100644 --- a/.cmake/Modules/CMakeDetermineObjectiveCCompiler.cmake +++ b/.cmake/Modules/CMakeDetermineObjectiveCCompiler.cmake @@ -2,48 +2,8 @@ # Redistribution and use of this file is allowed according to the terms of the MIT license. # For details see the LICENSE file distributed with Criterion. -include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) - -if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") -elseif("${CMAKE_GENERATOR}" MATCHES "Xcode") - set(CMAKE_ObjectiveC_COMPILER_XCODE_TYPE sourcecode.m) - _cmake_find_compiler_path(ObjectiveC) -else() - if(NOT CMAKE_ObjectiveC_COMPILER) - set(CMAKE_ObjectiveC_COMPILER_INIT NOTFOUND) - - if(NOT CMAKE_ObjectiveC_COMPILER_INIT) - set(CMAKE_ObjectiveC_COMPILER_LIST ${_CMAKE_TOOLCHAIN_PREFIX}gcc clang) - endif() - - _cmake_find_compiler(ObjectiveC) - else() - _cmake_find_compiler_path(ObjectiveC) - endif() - mark_as_advanced(CMAKE_ObjectiveC_COMPILER) - - set(CMAKE_ObjectiveC_COMPILER_ID_TEST_FLAGS_FIRST) - set(CMAKE_ObjectiveC_COMPILER_ID_TEST_FLAGS "-c") - -endif() - -if(NOT CMAKE_ObjectiveC_COMPILER_ID_RUN) - set(CMAKE_ObjectiveC_COMPILER_ID_RUN 1) - - # Try to identify the compiler. - set(CMAKE_ObjectiveC_COMPILER_ID) - set(CMAKE_ObjectiveC_PLATFORM_ID) - file(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in - CMAKE_ObjectiveC_COMPILER_ID_PLATFORM_CONTENT) - - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) - - # we use the same compiler id source than C - CMAKE_DETERMINE_COMPILER_ID(ObjectiveC CFLAGS CMakeCCompilerId.c) - -endif() - -include(CMakeFindBinUtils) +set(CMAKE_ObjectiveC_COMPILER_ID ${CMAKE_C_COMPILER_ID}) +set(CMAKE_ObjectiveC_COMPILER ${CMAKE_C_COMPILER}) # configure variables set in this file for fast reload later on configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeObjectiveCCompiler.cmake.in diff --git a/.cmake/Modules/CMakeTestObjectiveCCompiler.cmake b/.cmake/Modules/CMakeTestObjectiveCCompiler.cmake index e6d5ff1..a32b33f 100644 --- a/.cmake/Modules/CMakeTestObjectiveCCompiler.cmake +++ b/.cmake/Modules/CMakeTestObjectiveCCompiler.cmake @@ -22,6 +22,8 @@ if(NOT CMAKE_ObjectiveC_COMPILER_WORKS) "#ifdef __cplusplus\n" "# error \"The CMAKE_ObjectiveC_COMPILER is set to an ObjectiveC++ compiler\"\n" "#endif\n" + "@interface Foo\n" + "@end\n" "int main(int argc, char* argv[])\n" "{ (void)argv; return argc-1;}\n") try_compile(CMAKE_ObjectiveC_COMPILER_WORKS ${CMAKE_BINARY_DIR} diff --git a/.cmake/Modules/Languages.cmake b/.cmake/Modules/Languages.cmake index 0ad61d4..615d067 100644 --- a/.cmake/Modules/Languages.cmake +++ b/.cmake/Modules/Languages.cmake @@ -1,15 +1,17 @@ -if (NOT LANGUAGES) - set(LANGUAGES "") +option(LANG_CXX "Turn on C++ support" ON) +option(LANG_OBJC "Turn on Objective-C support" OFF) + +if (LANG_CXX) + enable_language(CXX) + if (CMAKE_CXX_COMPILER_WORKS) + set(CXX_BRIDGE 1) + endif () endif () -string(REPLACE "," ";" LANGUAGES "${LANGUAGES}") - -foreach (LANG ${LANGUAGES}) - enable_language(${LANG} OPTIONAL) - if (CMAKE_${LANG}_COMPILER_WORKS) - string(TOUPPER ${LANG} LANG_NAME) - set(${LANG_NAME}_BRIDGE 1) +if (LANG_OBJC) + enable_language(ObjectiveC) + if (CMAKE_ObjectiveC_COMPILER_WORKS) + set(OBJC_BRIDGE 1) endif () -endforeach () - +endif () diff --git a/CMakeLists.txt b/CMakeLists.txt index e0313d8..2f0a297 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,7 +49,6 @@ if (NOT MSVC) endif () endif () - if (MSVC) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO") endif ()